unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40205: 28.0.50; 32bit or LTO movemail build fails on macOS
@ 2020-03-24  3:14 YAMAMOTO Mitsuharu
  2020-03-25  2:58 ` bug#40205: " Paul Eggert
  0 siblings, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2020-03-24  3:14 UTC (permalink / raw)
  To: 40205

On macOS, movemail cannot be built with CC='cc -arch i386':

    CCLD     movemail
  Undefined symbols for architecture i386:
    "_rpl_getopt$UNIX2003", referenced from:
	_main in movemail-1f1ea0.o
  ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[1]: *** [movemail] Error 1
  make: *** [lib-src] Error 2

This is due to the following part in the system getopt.h:

  #ifndef _GETOPT
  #define	_GETOPT
  int	 getopt(int, char * const [], const char *) __DARWIN_ALIAS(getopt);

  extern char *optarg;			/* getopt(3) external variables */
  extern int optind, opterr, optopt;
  #endif

which is expanded to:

  int rpl_getopt(int, char * const [], const char *) __asm("_" "rpl_getopt" "$UNIX2003");

  extern char *rpl_optarg;
  extern int rpl_optind, rpl_opterr, rpl_optopt;

I think the Gnulib getopt does not expect the __asm line above.

64-bit LTO build with CC='cc -flto' fails, too.

    CCLD     movemail
  ld: reference to symbol (which has not been assigned an address) _rpl_getopt in '_main' from /var/folders/69/m7h39yv92g70qy7p3xdlghdm0000gn/T/cc-907a5d.o for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[1]: *** [movemail] Error 1
  make: *** [lib-src] Error 2

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40205: 32bit or LTO movemail build fails on macOS
  2020-03-24  3:14 bug#40205: 28.0.50; 32bit or LTO movemail build fails on macOS YAMAMOTO Mitsuharu
@ 2020-03-25  2:58 ` Paul Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2020-03-25  2:58 UTC (permalink / raw)
  To: YAMAMOTO Mitsuharu; +Cc: Zack Weinberg, Gnulib bugs, 40205

[-- Attachment #1: Type: text/plain, Size: 238 bytes --]

Thanks for the bug report. Does the attached patch to getopt-pfx-core.h fix the 
bug for you?

I'll CC: this to bug-gnulib and to Zack Weinberg, who wrote that file. For those 
new to this thread, please see <https://bugs.gnu.org/40205>.

[-- Attachment #2: getopt-apple.diff --]
[-- Type: text/x-patch, Size: 771 bytes --]

diff --git a/lib/getopt-pfx-core.h b/lib/getopt-pfx-core.h
index 31a747d67..a4891bc80 100644
--- a/lib/getopt-pfx-core.h
+++ b/lib/getopt-pfx-core.h
@@ -48,6 +48,14 @@
 # define optind __GETOPT_ID (optind)
 # define optopt __GETOPT_ID (optopt)
 
+/* Work around a a problem on macOS, which declares getopt with a
+   trailing __DARWIN_ALIAS(getopt) that would expand to something like
+   __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
+   hack to suppress the macOS declaration <https://bugs.gnu.org/40205>.  */
+# ifdef __APPLE__
+#  define _GETOPT
+# endif
+
 /* The system's getopt.h may have already included getopt-core.h to
    declare the unprefixed identifiers.  Undef _GETOPT_CORE_H so that
    getopt-core.h declares them with prefixes.  */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#40205: 32bit or LTO movemail build fails on macOS
       [not found] <547efadc-1a0c-2d47-4b03-5c4cd426f128@cs.ucla.edu>
@ 2020-03-25  4:07 ` YAMAMOTO Mitsuharu
  2020-03-25 20:43   ` Paul Eggert
  2020-03-25 13:14 ` Zack Weinberg
  1 sibling, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2020-03-25  4:07 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Zack Weinberg, Gnulib bugs, 40205

On Wed, 25 Mar 2020 11:58:19 +0900,
Paul Eggert wrote:
> 
> Thanks for the bug report. Does the attached patch to
> getopt-pfx-core.h fix the bug for you?

Yes, this works for both -arch i386 and -flto cases.  Thanks.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40205: 32bit or LTO movemail build fails on macOS
       [not found] <547efadc-1a0c-2d47-4b03-5c4cd426f128@cs.ucla.edu>
  2020-03-25  4:07 ` YAMAMOTO Mitsuharu
@ 2020-03-25 13:14 ` Zack Weinberg
  1 sibling, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2020-03-25 13:14 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 40205, Gnulib bugs

On Tue, Mar 24, 2020 at 10:58 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Thanks for the bug report. Does the attached patch to getopt-pfx-core.h fix the
> bug for you?
>
> I'll CC: this to bug-gnulib and to Zack Weinberg, who wrote that file. For those
> new to this thread, please see <https://bugs.gnu.org/40205>.

Patch seems plausible enough to me.  I didn't think very hard about
the ways a system declaration of getopt could interfere when I wrote
this file.

zw





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#40205: 32bit or LTO movemail build fails on macOS
  2020-03-25  4:07 ` YAMAMOTO Mitsuharu
@ 2020-03-25 20:43   ` Paul Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2020-03-25 20:43 UTC (permalink / raw)
  To: YAMAMOTO Mitsuharu; +Cc: Zack Weinberg, 40205-done, Gnulib bugs

On 3/24/20 9:07 PM, YAMAMOTO Mitsuharu wrote:

> Yes, this works for both -arch i386 and -flto cases.

Thanks for checking. I installed the patch into Gnulib and propagated the fix 
into Emacs master, and am marking this Emacs bug as done.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-25 20:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-24  3:14 bug#40205: 28.0.50; 32bit or LTO movemail build fails on macOS YAMAMOTO Mitsuharu
2020-03-25  2:58 ` bug#40205: " Paul Eggert
     [not found] <547efadc-1a0c-2d47-4b03-5c4cd426f128@cs.ucla.edu>
2020-03-25  4:07 ` YAMAMOTO Mitsuharu
2020-03-25 20:43   ` Paul Eggert
2020-03-25 13:14 ` Zack Weinberg

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).