GNU bug report logs -
#57849
29.0.50; MacOS ld warning from native compilation
Previous Next
Reported by: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Date: Fri, 16 Sep 2022 05:49:02 UTC
Severity: minor
Found in version 29.0.50
Fixed in version 30.1
Done: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #44 received at 57849 <at> debbugs.gnu.org (full text, mbox):
Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
> Andrea Corallo <akrl <at> sdf.org> writes:
>
>> Gerd Möllmann <gerd.moellmann <at> gmail.com> writes:
>
>>> I'm not sure this is true for elns. What if a function in a.eln calls a
>>> function F in b.eln?
>>
>> This is never the case. Functions in .eln files either call functions in
>> Emacs core or either call functions in the same .eln file.
>
> Thanks, good to know.
>
> I'll give it a spin with -bundle... later today.
That failed miserably. What I tried:
(1) See with which options elns are compiled/linked.
(let ((native-comp-driver-options '("-v")))
(native-compile "/Users/gerd/emacs/crash.el"))
gives an output ending with
/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin21/12/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/ -dynamic -arch arm64 -macosx_version_min 12.0.0 -o /var/folders/1d/k_6t25f94sl83szqbf8gpkrh0000gn/T//libgccjit-YMST3m/fake.so -L/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin21/12 -L/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin21/12/../../.. /var/folders/1d/k_6t25f94sl83szqbf8gpkrh0000gn/T//ccbfcNDH.o -undefined dynamic_lookup -dylib -dylib_install_name crash-e892b236-cea0f727.eln -lemutls_w -lgcc -lSystem -lgcc -no_compact_unwind -rpath @loader_path -rpath /opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/current/gcc/aarch64-apple-darwin21/12 -rpath /opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/current/gcc -rpath /opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/current
ld: warning: -undefined dynamic_lookup may not work with chained fixups
That is, it builds a shared object (-dynamic).
(2) -bundle_loader requires -bundle. Ld gives an error if
-bundle_loader is used without -bundle. A "bundle" in Mach-O, which is
what MacOS is using instead of ELF, say, is something different than a
shared library. Example:
gcc -v -o eln.dylib -twolevel_namespace -undefined dynamic_lookup -dylib -bundle_loader hansi eln.c
ld: -bundle_loader can only be used with -bundle
(3) Tried to add -bundle like this
(let ((native-comp-driver-options '("-v" "-bundle")))
(native-compile "/Users/gerd/emacs/crash.el"))
but it fails
Compiling /Users/gerd/.emacs.d/eln-cache/29_0_50-72ec8db5/crash-e892b236-cea0f727.eln...
Using built-in specs.
aarch64-apple-darwin21-gcc-12: error: -bundle not allowed with -dynamiclib
COLLECT_GCC=aarch64-apple-darwin21-gcc-12
I odn't know how to remove the -dynamic from (1).
As an aside, -bundler_loader actually requires an argument <executable>,
which would be Emacs in our case. What that means for Emacs' build
process is unclear to me, but it doesn't feel good.
So, I declare this a complete failure.
Anyone with an idea what else to try? Otherwise my proposal is to
either add something to etc/PROBLEMS describing how to add "-Wl,-w", or
add that option by default on Darwin.
I didn't check if emacs-28 has the same problem, but I don't see why it
wouldn't.
If we add -Wl by default, an open question is if -w is supported on all
all versions of MacOS that Emacs supports, which I can't find a definite
answer to.
This bug report was last modified 1 year and 96 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.