unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57849: 29.0.50; MacOS ld warning from native compilation
@ 2022-09-16  5:48 Gerd Möllmann
  2022-09-16 10:51 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16  5:48 UTC (permalink / raw)
  To: 57849

In GNU Emacs 29.0.50 (build 1, aarch64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.6 (Build 21G115)) of 2022-09-15 built on
 Mini.fritz.box
Repository revision: 70e4388c59a030f0c1bec9bfcf3e94cc6d80dd1f
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.6

Configured using:
 'configure --cache-file /Users/gerd/tmp/config.cache.master
 --with-native-compilation'

After upgrading to Xcode 14.0 (14A309) tonight, native compilation
now emits lots of warnings

ld: warning: -undefined dynamic_lookup may not work with chained fixups

~/emacs/master/src/ > ld -v
@(#)PROGRAM:ld  PROJECT:ld64-819.6
BUILD 14:58:44 Aug  5 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: LLVM version 14.0.0, (clang-1400.0.29.102) (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 14.0.0 (tapi-1400.0.11)

I cannot find anything at all about the warning on the web.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16  5:48 bug#57849: 29.0.50; MacOS ld warning from native compilation Gerd Möllmann
@ 2022-09-16 10:51 ` Lars Ingebrigtsen
  2022-09-16 12:34   ` Gerd Möllmann
  2022-09-16 12:44   ` Gregory Heytings
  0 siblings, 2 replies; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-16 10:51 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: 57849

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> I cannot find anything at all about the warning on the web.

There's:

https://githublab.com/profile/kateinoigakukun

But er where's the actual link to the patch?  Confusing interface.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 10:51 ` Lars Ingebrigtsen
@ 2022-09-16 12:34   ` Gerd Möllmann
  2022-09-16 12:39     ` Lars Ingebrigtsen
  2022-09-16 12:44   ` Gregory Heytings
  1 sibling, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 12:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 57849

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
>> I cannot find anything at all about the warning on the web.
>
> There's:
>
> https://githublab.com/profile/kateinoigakukun
>
> But er where's the actual link to the patch?  Confusing interface.

Maybe it's a libgccjit thing?  It seems to pass that to ld.

/opt/homebrew/opt/ > strings /opt/homebrew/Cellar/libgccjit/12.2.0/lib/gcc/current/libgccjit.0.dylib|grep dynamic_lookup
-Wl,-undefined,dynamic_lookup





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 12:34   ` Gerd Möllmann
@ 2022-09-16 12:39     ` Lars Ingebrigtsen
  2022-09-16 12:44       ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-16 12:39 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: 57849

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Maybe it's a libgccjit thing?  It seems to pass that to ld.
>
> /opt/homebrew/opt/ > strings
> /opt/homebrew/Cellar/libgccjit/12.2.0/lib/gcc/current/libgccjit.0.dylib|grep
> dynamic_lookup
> -Wl,-undefined,dynamic_lookup

They mention "-bundle_loader", but since I can't find the link to the
actual patch, I'm not sure what, if anything, they're talking about...





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 10:51 ` Lars Ingebrigtsen
  2022-09-16 12:34   ` Gerd Möllmann
@ 2022-09-16 12:44   ` Gregory Heytings
  2022-09-16 12:50     ` Gerd Möllmann
  1 sibling, 1 reply; 19+ messages in thread
From: Gregory Heytings @ 2022-09-16 12:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Gerd Möllmann, 57849


>> I cannot find anything at all about the warning on the web.
>
> There's:
>
> https://githublab.com/profile/kateinoigakukun
>
> But er where's the actual link to the patch?  Confusing interface.
>

There's no patch AFAICS, but the discussion is here: 
https://githublab.com/repository/issues/chef/ffi-yajl/114

See another similar discussion here: 
https://github.com/ruby/ruby/pull/6193

Apparently the solution is to use the -bundle_loader option.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 12:39     ` Lars Ingebrigtsen
@ 2022-09-16 12:44       ` Gerd Möllmann
  0 siblings, 0 replies; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 12:44 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 57849

On 22-09-16 14:39 , Lars Ingebrigtsen wrote:
> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> 
>> Maybe it's a libgccjit thing?  It seems to pass that to ld.
>>
>> /opt/homebrew/opt/ > strings
>> /opt/homebrew/Cellar/libgccjit/12.2.0/lib/gcc/current/libgccjit.0.dylib|grep
>> dynamic_lookup
>> -Wl,-undefined,dynamic_lookup
> 
> They mention "-bundle_loader", but since I can't find the link to the
> actual patch, I'm not sure what, if anything, they're talking about...

Yeah, that's my problem, too :-)

The ld man page says

    Options when creating a bundle
      -bundle_loader executable
              This specifies the executable that will be loading the bundle
              output file being linked.  Undefined symbols from the 
bundle are
              checked against the specified executable like it was one 
of the
              dynamic libraries the bundle was linked with.

That doesn't look like the right thing.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 12:44   ` Gregory Heytings
@ 2022-09-16 12:50     ` Gerd Möllmann
  2022-09-16 13:05       ` Gerd Möllmann
  2022-09-16 21:53       ` Andrea Corallo
  0 siblings, 2 replies; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 12:50 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Lars Ingebrigtsen, 57849

Gregory Heytings <gregory@heytings.org> writes:

>>> I cannot find anything at all about the warning on the web.
>>
>> There's:
>>
>> https://githublab.com/profile/kateinoigakukun
>>
>> But er where's the actual link to the patch?  Confusing interface.
>>
>
> There's no patch AFAICS, but the discussion is here:
> https://githublab.com/repository/issues/chef/ffi-yajl/114
>
> See another similar discussion here:
> https://github.com/ruby/ruby/pull/6193
>
> Apparently the solution is to use the -bundle_loader option.

He writes

   On the other hand, -undefined dynamic_lookup is already deprecated on
   all darwin platforms except for macOS,

Aha, that's interesting.

   so it's good time to get rid of
   the option. ld64 also provides -bundle_loader <executable> option,
   which allows to resolve symbols defined in the executable symtab while
   linking. It behaves almost the same with -undefined dynamic_lookup,
   but it makes the following changes:

   Require that unresolved symbols among input objects must be defined
   in the executable.

I'm not sure this is true for elns.  What if a function in a.eln calls a
function F in b.eln?  In that case, F wouldn't be defined in the
executable.

   Lazy symbol binding will lookup only the symtab of the bundle loader
   executable. (-undefined dynamic_lookup lookups all symtab as flat
   namespace)

Not sure what he's saying...





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 12:50     ` Gerd Möllmann
@ 2022-09-16 13:05       ` Gerd Möllmann
  2022-09-16 13:39         ` Gerd Möllmann
  2022-09-16 21:53       ` Andrea Corallo
  1 sibling, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 13:05 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Lars Ingebrigtsen, 57849

And trying libgccjit HEAD fails...

/opt/homebrew/opt/ > brew install libgccjit --HEAD
==> Cloning https://gcc.gnu.org/git/gcc.git
Cloning into '/Users/gerd/Library/Caches/Homebrew/libgccjit--git'...
Updating files: 100% (117196/117196), done.
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> ../configure --prefix=/opt/homebrew/Cellar/libgccjit/HEAD-39dc665 
--libdir=/opt/homebrew/Cellar/libgccjit/HEAD-3
==> make
Last 15 lines from /Users/gerd/Library/Logs/Homebrew/libgccjit/02.make:
checking for struct tms... yes
checking for clock_t... yes
checking for F_SETLKW... yes
checking for O_CLOEXEC... yes
checking for fcntl.h... (cached) yes
checking whether O_NONBLOCK is declared... yes
checking for AF_UNIX... yes
checking for AF_INET6... yes
checking for _LK_LOCK... no
checking if mkdir takes one argument... no
/private/tmp/libgccjit-20220916-39022-19zntmh/gcc/configure: line 12693: 
test: =: unary operator expected
*** Configuration aarch64-apple-darwin21 not supported
make[2]: *** [configure-stage1-gcc] Error 1
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 13:05       ` Gerd Möllmann
@ 2022-09-16 13:39         ` Gerd Möllmann
  2022-09-16 13:52           ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 13:39 UTC (permalink / raw)
  To: Gregory Heytings; +Cc: Lars Ingebrigtsen, 57849

And trying to pass "-Wl,-w", with "-w" being an ld options to suppress 
warnings, doesn't work either (not that it would be a good idea...)

(let ((native-comp-compiler-options '("-Wl,-w")))
   (native-compile "/Users/gerd/emacs/crash.el"))

Compiling 
/Users/gerd/.emacs.d/eln-cache/29_0_50-72ec8db5/crash-e892b236-cea0f727.eln...
libgccjit.so: error: command-line option '-Wl,-w' is valid for the 
driver but not for

For what it doesn't say, but I guess it means for libgccjit.so :-). 
"gcc -Wl,w some.c" works just fine.

So, I guess we're hosed.  Unless someone has another idea.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 13:39         ` Gerd Möllmann
@ 2022-09-16 13:52           ` Eli Zaretskii
  2022-09-16 14:01             ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2022-09-16 13:52 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: gregory, larsi, 57849

> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 57849@debbugs.gnu.org
> Date: Fri, 16 Sep 2022 15:39:02 +0200
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> 
> And trying to pass "-Wl,-w", with "-w" being an ld options to suppress 
> warnings, doesn't work either (not that it would be a good idea...)
> 
> (let ((native-comp-compiler-options '("-Wl,-w")))
>    (native-compile "/Users/gerd/emacs/crash.el"))
> 
> Compiling 
> /Users/gerd/.emacs.d/eln-cache/29_0_50-72ec8db5/crash-e892b236-cea0f727.eln...
> libgccjit.so: error: command-line option '-Wl,-w' is valid for the 
> driver but not for

There's also native-comp-driver-options; did you try that?

native-comp-compiler-options are for the compiler, i.e. cc1.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 13:52           ` Eli Zaretskii
@ 2022-09-16 14:01             ` Gerd Möllmann
  0 siblings, 0 replies; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-16 14:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, larsi, 57849

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 57849@debbugs.gnu.org
>> Date: Fri, 16 Sep 2022 15:39:02 +0200
>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> 
>> And trying to pass "-Wl,-w", with "-w" being an ld options to suppress 
>> warnings, doesn't work either (not that it would be a good idea...)
>> 
>> (let ((native-comp-compiler-options '("-Wl,-w")))
>>    (native-compile "/Users/gerd/emacs/crash.el"))
>> 
>> Compiling 
>> /Users/gerd/.emacs.d/eln-cache/29_0_50-72ec8db5/crash-e892b236-cea0f727.eln...
>> libgccjit.so: error: command-line option '-Wl,-w' is valid for the 
>> driver but not for
>
> There's also native-comp-driver-options; did you try that?
>
> native-comp-compiler-options are for the compiler, i.e. cc1.

Thanks, that works!

(let ((native-comp-driver-options '("-Wl,-w")))
  (native-compile "/Users/gerd/emacs/crash.el"))
"/Users/gerd/.emacs.d/eln-cache/29_0_50-72ec8db5/crash-e892b236-cea0f727.eln"

Now I guess the question is how to proceed with this... Or maybe wait
for libgccjit to do something?





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 12:50     ` Gerd Möllmann
  2022-09-16 13:05       ` Gerd Möllmann
@ 2022-09-16 21:53       ` Andrea Corallo
  2022-09-17  4:45         ` Gerd Möllmann
  1 sibling, 1 reply; 19+ messages in thread
From: Andrea Corallo @ 2022-09-16 21:53 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Gregory Heytings, Lars Ingebrigtsen, 57849

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Gregory Heytings <gregory@heytings.org> writes:
>
>>>> I cannot find anything at all about the warning on the web.
>>>
>>> There's:
>>>
>>> https://githublab.com/profile/kateinoigakukun
>>>
>>> But er where's the actual link to the patch?  Confusing interface.
>>>
>>
>> There's no patch AFAICS, but the discussion is here:
>> https://githublab.com/repository/issues/chef/ffi-yajl/114
>>
>> See another similar discussion here:
>> https://github.com/ruby/ruby/pull/6193
>>
>> Apparently the solution is to use the -bundle_loader option.
>
> He writes
>
>    On the other hand, -undefined dynamic_lookup is already deprecated on
>    all darwin platforms except for macOS,
>
> Aha, that's interesting.
>
>    so it's good time to get rid of
>    the option. ld64 also provides -bundle_loader <executable> option,
>    which allows to resolve symbols defined in the executable symtab while
>    linking. It behaves almost the same with -undefined dynamic_lookup,
>    but it makes the following changes:
>
>    Require that unresolved symbols among input objects must be defined
>    in the executable.
>
> 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.

  Andrea





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-16 21:53       ` Andrea Corallo
@ 2022-09-17  4:45         ` Gerd Möllmann
  2022-09-17  7:16           ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-17  4:45 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Gregory Heytings, Lars Ingebrigtsen, 57849

Andrea Corallo <akrl@sdf.org> writes:

> Gerd Möllmann <gerd.moellmann@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.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-17  4:45         ` Gerd Möllmann
@ 2022-09-17  7:16           ` Gerd Möllmann
  2022-09-17  7:31             ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-17  7:16 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Gregory Heytings, Lars Ingebrigtsen, 57849

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Andrea Corallo <akrl@sdf.org> writes:
>
>> Gerd Möllmann <gerd.moellmann@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.






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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-17  7:16           ` Gerd Möllmann
@ 2022-09-17  7:31             ` Eli Zaretskii
  2022-09-17  8:17               ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2022-09-17  7:31 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: gregory, larsi, 57849, akrl

> Cc: Gregory Heytings <gregory@heytings.org>, Lars Ingebrigtsen <larsi@gnus.org>,
>  57849@debbugs.gnu.org
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Date: Sat, 17 Sep 2022 09:16:20 +0200
> 
> 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/aa
 rch64-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?

Is this somehow an Emacs-specific problem, or is this a general
problem with libgccjit on those versions of macOS?  If the latter, I
think this should be taken up with the libgccjit developers first, and
we should then do as they say, if that makes sense.

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

If what the libgccjit developers say doesn't fit our needs, or if this
is an Emacs-specific problem, thgen yes, using -Wl,-w is probably the
way to go.

> I didn't check if emacs-28 has the same problem, but I don't see why it
> wouldn't.

It's okay to make that change on the emacs-28 branch, if someone can
verify that it works on that branch.

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

I think -w is such an old option that it'd be unthinkable for it not
to be supported.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-17  7:31             ` Eli Zaretskii
@ 2022-09-17  8:17               ` Gerd Möllmann
  2022-09-17  8:57                 ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-17  8:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, larsi, 57849, akrl

Eli Zaretskii <eliz@gnu.org> writes:

> Is this somehow an Emacs-specific problem, or is this a general
> problem with libgccjit on those versions of macOS?

I think it's a general problem with macOS 12.6/Xcode 14, but I'm not sure.
The link Gregory and/or Lars posted concerned Ruvy, IIRC.

> If the latter, I
> think this should be taken up with the libgccjit developers first, and
> we should then do as they say, if that makes sense.

Maybe Andrea can say more.  I don't know libgccjit and the native
compiler well enough.

>> 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.
>
> If what the libgccjit developers say doesn't fit our needs, or if this
> is an Emacs-specific problem, thgen yes, using -Wl,-w is probably the
> way to go.
>
>> I didn't check if emacs-28 has the same problem, but I don't see why it
>> wouldn't.
>
> It's okay to make that change on the emacs-28 branch, if someone can
> verify that it works on that branch.

I've tried this in emacs-28, which seems to work, with a caveat

@@ -178,14 +178,15 @@ native-comp-compiler-options
   :type '(repeat string)
   :version "28.1")
 
-(defcustom native-comp-driver-options nil
+(defcustom native-comp-driver-options (when (eq system-type 'darwin)
+                                        '("-Wl,-w"))
   "Options passed verbatim to the native compiler's back-end driver.
 Note that not all options are meaningful; typically only the options
 affecting the assembler and linker are likely to be useful.
 
 Passing these options is only available in libgccjit version 9
 and above."
-  :type '(repeat string)                ; FIXME is this right?
+  :type '(repeat string)
   :version "28.1")
 
 (defcustom comp-libgccjit-reproducer nil

The caveat being that I see, after starting that Emacs, in the log
buffer

uncompressing time-date.el.gz...done
ld: library not found for -lemutls_w
libgccjit.so: error: error invoking gcc driver
/Users/gerd/emacs/emacs-28/nextstep/Emacs.app/Contents/Resources/lisp/emacs-lisp/comp.el.gz: Error: Internal native compiler error failed to compile

The build was from git clean -xdf.  Don't know what's going on there.
Maybe it's not related to my change.  I'll try without the change later
today.

>
>> 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.
>
> I think -w is such an old option that it'd be unthinkable for it not
> to be supported.

That's likely, yes.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-17  8:17               ` Gerd Möllmann
@ 2022-09-17  8:57                 ` Gerd Möllmann
  2022-09-19  5:19                   ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-17  8:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, larsi, 57849, akrl

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> uncompressing time-date.el.gz...done
> ld: library not found for -lemutls_w
> libgccjit.so: error: error invoking gcc driver
> /Users/gerd/emacs/emacs-28/nextstep/Emacs.app/Contents/Resources/lisp/emacs-lisp/comp.el.gz: Error: Internal native compiler error failed to compile
>

This is not my day...

I can't reproduce the error above anymore, with or without the change in
compl.el.  It would be good if someone else could double-check.






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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-17  8:57                 ` Gerd Möllmann
@ 2022-09-19  5:19                   ` Gerd Möllmann
  2024-05-18  6:30                     ` Gerd Möllmann
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Möllmann @ 2022-09-19  5:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, larsi, 57849, akrl

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
>> uncompressing time-date.el.gz...done
>> ld: library not found for -lemutls_w
>> libgccjit.so: error: error invoking gcc driver
>> /Users/gerd/emacs/emacs-28/nextstep/Emacs.app/Contents/Resources/lisp/emacs-lisp/comp.el.gz:
>> Error: Internal native compiler error failed to compile
>>
>
> This is not my day...
>
> I can't reproduce the error above anymore, with or without the change in
> compl.el.  It would be good if someone else could double-check.

I've now tested this with a script over night, and the error did not
re-appear in almost 200 runs.

So I've now pushed this to emacs-28.





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

* bug#57849: 29.0.50; MacOS ld warning from native compilation
  2022-09-19  5:19                   ` Gerd Möllmann
@ 2024-05-18  6:30                     ` Gerd Möllmann
  0 siblings, 0 replies; 19+ messages in thread
From: Gerd Möllmann @ 2024-05-18  6:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gregory, larsi, 57849, akrl

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
>> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>
>>> uncompressing time-date.el.gz...done
>>> ld: library not found for -lemutls_w
>>> libgccjit.so: error: error invoking gcc driver
>>> /Users/gerd/emacs/emacs-28/nextstep/Emacs.app/Contents/Resources/lisp/emacs-lisp/comp.el.gz:
>>> Error: Internal native compiler error failed to compile
>>>
>>
>> This is not my day...
>>
>> I can't reproduce the error above anymore, with or without the change in
>> compl.el.  It would be good if someone else could double-check.
>
> I've now tested this with a script over night, and the error did not
> re-appear in almost 200 runs.
>
> So I've now pushed this to emacs-28.

No further remarks, so I'm closing this as fixed.





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

end of thread, other threads:[~2024-05-18  6:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  5:48 bug#57849: 29.0.50; MacOS ld warning from native compilation Gerd Möllmann
2022-09-16 10:51 ` Lars Ingebrigtsen
2022-09-16 12:34   ` Gerd Möllmann
2022-09-16 12:39     ` Lars Ingebrigtsen
2022-09-16 12:44       ` Gerd Möllmann
2022-09-16 12:44   ` Gregory Heytings
2022-09-16 12:50     ` Gerd Möllmann
2022-09-16 13:05       ` Gerd Möllmann
2022-09-16 13:39         ` Gerd Möllmann
2022-09-16 13:52           ` Eli Zaretskii
2022-09-16 14:01             ` Gerd Möllmann
2022-09-16 21:53       ` Andrea Corallo
2022-09-17  4:45         ` Gerd Möllmann
2022-09-17  7:16           ` Gerd Möllmann
2022-09-17  7:31             ` Eli Zaretskii
2022-09-17  8:17               ` Gerd Möllmann
2022-09-17  8:57                 ` Gerd Möllmann
2022-09-19  5:19                   ` Gerd Möllmann
2024-05-18  6:30                     ` Gerd Möllmann

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).