jimeh/emacs-builds

Emacs builds expecting GCC to be installed

Opened this issue · 18 comments

Since Emacs.2021-06-23.7be75f1.master I get the same message: "Library not loaded: /usr/local/lib/gcc/11/libgcc_s.1.dylib".

This is required by subr--trampoline on this build and subsequent ones.

jimeh commented

This is an issue I'm tracking over on the bulidscript project here: jimeh/build-emacs-for-macos#53

However, I'm surprised to hear it started with the 2021-06-23 build for you. I was under the impression this has been an issue since the beginning, and I just never noticed cause I've always had GCC installed locally.

I'll do a bit more digging into this tomorrow, but also it would be great if you could confirm this did not happen before the build you've mentioned :)

I can confirm that previous builds worked fine. For me it all started with the change from zip files do DMG and the notarization. I was on the 2021-06-01 so I thought I would change to 2021-07-01 and Emacs didn't opened. I picked one from the previously known good build lists: 2021-06-23, but the error was still present so I started to roll back one by one and 2021-06-20 was the one without any errors.

jimeh commented

That's very interesting. It must have been a change in the master branch of emacs that's behind it then, cause the zip/dmg/signing shouldn't have any effect on eln files built at runtime by Emacs.

I'll do some digging and see what I can find :)

jimeh commented

Actually, it doesn't seem to be due to a change in Emacs itself, cause with the 2021-06-20 build, all runtime *.eln files still link against /usr/local/lib/gcc/11/libgcc_s.1.dylib, but despite the file missing from the system is seems to find it. I assume it finds the one embedded into Emacs.app. And it seems later builds do not find it, potentially cause the file was modified by the signing process. I'm not sure.

I'll need to do some further testing on a clean macOS VM that's never had homebrew/gcc/anything installed to narrow down explanations and see how it goes.

shmul commented

Any updates on this? I'm also unable to run the emacs-app-good (the Finder info says the application was built on 13 July 2021 at 3:49). Can I assist in debugging this issue show how?

emacs: dlopen(/Applications/Emacs.app/Contents/MacOS/../Frameworks/native-lisp/28_0_50-006389d9/preloaded/window-0d1b8b93-63c191c3.eln, 1): Library not loaded: /usr/local/lib/gcc/11/libgcc_s.1.dylib
  Referenced from: /Applications/Emacs.app/Contents/Frameworks/native-lisp/28_0_50-006389d9/preloaded/window-0d1b8b93-63c191c3.eln
  Reason: image not found

Thanks,
Shmul

jimeh commented

I'm afraid for now the gcc homebrew formula is required for native-comp enabled builds which are codesigned :(

The latest nightlies do re-link the *.eln files bundled within the app against the embedded libgcc shared library, but that in itself is causing on and off again issues with code signing instead, to the point I believe I will need to stop re-linking them in the short term, and try to get some help from the emacs mailing list.

Also, even if I re-link the bundled *.eln files, any *.eln files built on your machine, still end up with linking to /usr/local/lib/gcc/11/libgcc_s.1.dylib even if they were built with the libgcc_s.1.dylib bundled into Emacs.app. This is the main thing I'll be asking for help with on the mailing list.

shmul commented

Thanks for looking into it. I'm afraid that even after (re)installing gcc and emacs-app-good I still get the same error. For what it is worth, the specific dylib is absent from

ζ ll /opt/homebrew/Cellar/gcc/11.2.0/lib/gcc/11                                                                                                                                                          [621a6ff]
total 95936
drwxr-xr-x  3 shmulikregev  admin    96B May  5 00:25 gcc
-r--r--r--  1 shmulikregev  admin   110K Aug  5 09:51 libatomic.1.dylib
-r--r--r--  1 shmulikregev  admin   253K May  5 00:25 libatomic.a
lrwxr-xr-x  1 shmulikregev  admin    17B May  5 00:25 libatomic.dylib -> libatomic.1.dylib
-rw-r--r--  1 shmulikregev  admin   1.9M May  5 00:25 libcc1.0.so
lrwxr-xr-x  1 shmulikregev  admin    11B May  5 00:25 libcc1.so -> libcc1.0.so
-r--r--r--  1 shmulikregev  admin   110K Aug  5 09:51 libgcc_s.1.1.dylib
-r--r--r--  1 shmulikregev  admin   1.6M Aug  5 09:51 libgfortran.5.dylib
-r--r--r--  1 shmulikregev  admin   7.6M May  5 00:25 libgfortran.a
lrwxr-xr-x  1 shmulikregev  admin    19B May  5 00:25 libgfortran.dylib -> libgfortran.5.dylib
-r--r--r--  1 shmulikregev  admin   188B May  5 00:25 libgfortran.spec
-r--r--r--  1 shmulikregev  admin   383K Aug  5 09:51 libgomp.1.dylib
-r--r--r--  1 shmulikregev  admin   1.7M May  5 00:25 libgomp.a
lrwxr-xr-x  1 shmulikregev  admin    15B May  5 00:25 libgomp.dylib -> libgomp.1.dylib
-r--r--r--  1 shmulikregev  admin   169B May  5 00:25 libgomp.spec
-r--r--r--  1 shmulikregev  admin   262K Aug  5 09:51 libitm.1.dylib
-r--r--r--  1 shmulikregev  admin   1.4M May  5 00:25 libitm.a
lrwxr-xr-x  1 shmulikregev  admin    14B May  5 00:25 libitm.dylib -> libitm.1.dylib
-r--r--r--  1 shmulikregev  admin   162B May  5 00:25 libitm.spec
-r--r--r--  1 shmulikregev  admin   162K Aug  5 09:51 libobjc-gnu.4.dylib
-r--r--r--  1 shmulikregev  admin   450K May  5 00:25 libobjc-gnu.a
lrwxr-xr-x  1 shmulikregev  admin    19B May  5 00:25 libobjc-gnu.dylib -> libobjc-gnu.4.dylib
-rw-r--r--  1 shmulikregev  admin    72K Aug  5 09:51 libssp.0.dylib
-r--r--r--  1 shmulikregev  admin    60K May  5 00:25 libssp.a
lrwxr-xr-x  1 shmulikregev  admin    14B May  5 00:25 libssp.dylib -> libssp.0.dylib
-r--r--r--  1 shmulikregev  admin   2.2K May  5 00:25 libssp_nonshared.a
-rw-r--r--  1 shmulikregev  admin   3.3M Aug  5 09:51 libstdc++.6.dylib
-r--r--r--  1 shmulikregev  admin    22M May  5 00:25 libstdc++.a
-r--r--r--  1 shmulikregev  admin   2.4K Aug  5 09:51 libstdc++.a-gdb.py
lrwxr-xr-x  1 shmulikregev  admin    17B May  5 00:25 libstdc++.dylib -> libstdc++.6.dylib
-r--r--r--  1 shmulikregev  admin   4.8M May  5 00:25 libstdc++fs.a
-r--r--r--  1 shmulikregev  admin   952K May  5 00:25 libsupc++.a

I don't know why but I just downloaded Emacs.2021-09-18.fc8df25.master on a whim and now everything works. No errors, warnings, messages. Nothing. Everything is fine (by now).

jimeh commented

@arzoriac that's rather interesting, are you sure you don't have the gcc homebrew formula installed, or at least /usr/local/lib/gcc/11/libgcc_s.1.dylib available on disk? Cause I tested that build in a VM with a fresh macOS install without luck.

On somewhat more useful news though, all builds now store the unsigned app as a build artifact, which I believe should work without gcc. I haven't had time to double check it myself yet though, so I can't guarantee it. The artifact is simply called unsigned-app, latest successful master build atm is: https://github.com/jimeh/emacs-builds/actions/runs/1335353813

I don't have Homebrew Installed and I have nothing on /usr/local/ at all.

jimeh commented

@arzoriac That's very interesting. I think I'll need to do some additional testing in a VM it seems :)

Though I do have a few questions for you if you don't mind. Have you tried any later builds or is it just that specific one? And do you have native-comp enabled so packages you install yourself become native-compiled too?

I don't know why but certain builds doesn't run. I also test with -Q but the result is the same. Because of this I don't run the latest HEAD or update it regularly. If you want I can download the builds on a daily basis and report if it works or if there's any issues, etc.

I have native compilation enabled but I use (setq comp-deferred-compilation t) and never had any problems with it.

jimeh commented

@arzoriac I've finally managed to figure out what the issue was that prevented the bundled GCC libraries from being used, so starting with build 2021-11-27 tomorrow, native-comp should work without Homebrew or GCC installed, and be truly self-contained.

If you want to try a build early, there's a test build that I used to verify things worked. Simply download the "dmg" artifact from here: https://github.com/jimeh/emacs-builds/actions/runs/1509465027

You should get a zip file caled dmg.zip, within which you'll have Emacs.2021-11-26.9721dcf.master.macOS-10-15.x86_64.test.rpath2.dmg.

Details about the root cause of the issue, and the fix/fixes, are on this PR: jimeh/build-emacs-for-macos#62

Everything works now, bravo! Thank you so much for fixing this.

shmul commented

I can confirm it works for me as well. Thanks for solving this!

jimeh commented

@arzoriac @shmul Thanks for your help and patience with this issue :)

shmul commented

We're emacs folks, patience brought us this far ;)

FWIW, I just installed Emacs.2022-03-02.8c8093a.master (I'm a first time emacs-build user) and I saw a bunch of native-comp issues at startup. (However, no issues when launched with -Q.)

Although the error message was different, I found this thread and installed gcc using Homebrew, and now everything works. 😅

I unfortunately didn't save the full error message, but it included this bit:

ld: library not found for -lSystem