* 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; 2+ 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] 2+ 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; 2+ 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] 2+ messages in thread
end of thread, other threads:[~2020-03-25 2:58 UTC | newest]
Thread overview: 2+ 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
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).