Subject: Re: 32bit or LTO movemail build fails on macOS

From: Paul Eggert <[email-masked]>
Date: Tue, 24 Mar 2020 19:58:19 -0700

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>.
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.  */