Created attachment 723280 [details] config.log Emacs as of v28 (not yet released, so this is with 28.0.9999) supports using libgccjit (sys-devel/gcc[jit]) to compile lisp code not only to byte code, but also to native code. This fails with a somewhat confusing error message when using ccache: ``` checking for gcc_jit_context_acquire in -lgccjit... yes checking libgccjit.h usability... yes checking libgccjit.h presence... yes checking for libgccjit.h... yes configure: error: The installed libgccjit failed to compile and run a test program using the libgccjit library; see config.log for the details of the failure. The test program can be found here: <https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>. You can try compiling it yourself to investigate the issues. Please report the issue to your distribution if libgccjit was installed through that. You can find the instructions on how to compile and install libgccjit from source on this site: <https://gcc.gnu.org/wiki/JIT>. !!! Please attach the following file when seeking support: !!! /tmp/portage/app-editors/emacs-28.0.9999/work/emacs/config.log * ERROR: app-editors/emacs-28.0.9999::gentoo failed (configure phase): * econf failed ``` relevant portion of config.log (see attachment for full file): ``` configure:17126: checking libgccjit.h presence configure:17126: x86_64-pc-linux-gnu-gcc -E conftest.c configure:17126: $? = 0 configure:17126: result: yes configure:17126: checking for libgccjit.h configure:17126: result: yes configure:17192: x86_64-pc-linux-gnu-gcc -o conftest -O2 -pipe -march=native -g -pthread -isystem /usr/include/librsvg-2.0 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/libmount -isys tem /usr/include/blkid -isystem /usr/include/cairo -isystem /usr/lib64/libffi/include -isystem /usr/include/pixman-1 -isystem /usr/include/uuid -isystem /usr/include/freetype2 -isystem /usr/includ e/harfbuzz -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/libpng16 -isystem /usr/include/cairo -isystem /usr/lib64/libffi/include -isystem /usr/include/p ixman-1 -isystem /usr/include/uuid -isystem /usr/include/freetype2 -isystem /usr/include/harfbuzz -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/libpng16 -Wl,-O1 -Wl,--as-needed conftest.c -lgccjit >&5 configure:17192: $? = 0 configure:17192: ./conftest ld: cannot find crtbeginS.o: No such file or directory ld: cannot find -lgcc ld: cannot find -lgcc_s libgccjit.so: error: error invoking gcc driver configure:17192: $? = 1 configure: program exited with status 1 ``` I guessed that ccache was the problem, and it worked fine after overriding with FEATURES=-ccache. This is of course no proof, but it sounds reasonable to me that ccache is the culprit. Probably distcc won’t work either, but I don’t have it set up here, so I can’t test that.
(In reply to Thomas Schneider from comment #0) I can reproduce the problem, and it looks like a regression. Configure also fails with commit e761e12498 from the Emacs master branch, which is the version I had tested when adding the jit flag to the ebuild. So it doesn't seem to be caused by changes in Emacs. CCing toolchain maintainers, any idea what would would cause this error: > ld: cannot find crtbeginS.o: No such file or directory > ld: cannot find -lgcc > ld: cannot find -lgcc_s > libgccjit.so: error: error invoking gcc driver
Created attachment 723316 [details] a.c Extracted config.log test into a.c. ccache's PATH interferes with gccjit's driver path discovery: $ gcc a.c -o a -lgccjit && ./a $ gcc a.c -o a -lgccjit && PATH=/usr/lib/ccache/bin:$PATH ./a ld: cannot find crtbeginS.o: No such file or directory ld: cannot find -lgcc ld: cannot find -lgcc_s libgccjit.so: error: error invoking gcc driver stracing the details. Good: # gcc a.c -o a -lgccjit && strace -f -etrace=execve ./a execve("./a", ["./a"], 0x7ffef6ecc2c0 /* 32 vars */) = 0 strace: Process 399994 attached [pid 399994] execve("/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/bin/as", ["/usr/lib/gcc/x86_64-pc-linux-gnu"..., "--64", "-o", "/tmp/ccABa2Ug.o", "/tmp/libgccjit-tjiTFw/fake.s"], 0x55ccc5b1a810 /* 35 vars */) = 0 [pid 399994] +++ exited with 0 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=399994, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- strace: Process 399995 attached [pid 399995] execve("/usr/libexec/gcc/x86_64-pc-linux-gnu/11.1.0/collect2", ["/usr/libexec/gcc/x86_64-pc-linux"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-tjiTFw/fake.so", "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/lib/../lib64", "-L/usr/lib/../lib64", "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "/tmp/ccABa2Ug.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "/usr/lib/gcc/x86_64-pc-linux-gnu"...], 0x55ccc5b1a9d0 /* 37 vars */) = 0 strace: Process 399996 attached [pid 399996] execve("/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/bin/ld", ["/usr/lib/gcc/x86_64-pc-linux-gnu"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-tjiTFw/fake.so", "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/lib/../lib64", "-L/usr/lib/../lib64", "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "-L/usr/lib/gcc/x86_64-pc-linux-g"..., "/tmp/ccABa2Ug.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "/usr/lib/gcc/x86_64-pc-linux-gnu"..., "/usr/lib/gcc/x86_64-pc-linux-gnu"...], 0x7ffef72ad908 /* 37 vars */) = 0 [pid 399996] +++ exited with 0 +++ [pid 399995] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=399996, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- [pid 399995] +++ exited with 0 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=399995, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- +++ exited with 0 +++ Bad: # gcc a.c -o a -lgccjit && PATH=/usr/lib/ccache/bin:$PATH strace -f -etrace=execve ./a execve("./a", ["./a"], 0x7ffc2b3f7d30 /* 32 vars */) = 0 strace: Process 400006 attached [pid 400006] execve("/usr/lib/ccache/bin/as", ["as", "--64", "-o", "/tmp/ccal5ZVU.o", "/tmp/libgccjit-ami65f/fake.s"], 0x555fab77b810 /* 35 vars */) = -1 ENOENT (No such file or directory) [pid 400006] execve("/usr/local/sbin/as", ["as", "--64", "-o", "/tmp/ccal5ZVU.o", "/tmp/libgccjit-ami65f/fake.s"], 0x555fab77b810 /* 35 vars */) = -1 ENOENT (No such file or directory) [pid 400006] execve("/usr/local/bin/as", ["as", "--64", "-o", "/tmp/ccal5ZVU.o", "/tmp/libgccjit-ami65f/fake.s"], 0x555fab77b810 /* 35 vars */) = -1 ENOENT (No such file or directory) [pid 400006] execve("/usr/sbin/as", ["as", "--64", "-o", "/tmp/ccal5ZVU.o", "/tmp/libgccjit-ami65f/fake.s"], 0x555fab77b810 /* 35 vars */) = -1 ENOENT (No such file or directory) [pid 400006] execve("/usr/bin/as", ["as", "--64", "-o", "/tmp/ccal5ZVU.o", "/tmp/libgccjit-ami65f/fake.s"], 0x555fab77b810 /* 35 vars */) = 0 [pid 400006] +++ exited with 0 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=400006, si_uid=0, si_status=0, si_utime=0, si_stime=0} --- strace: Process 400007 attached [pid 400007] execve("/usr/lib/ccache/bin/ld", ["ld", "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-ami65f/fake.so", "/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64", "-L/usr/lib/../lib64", "/tmp/ccal5ZVU.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "crtendS.o", "/usr/lib/../lib64/crtn.o"], 0x555fab77b9d0 /* 37 vars */) = -1 ENOENT (No such file or directory) [pid 400007] execve("/usr/local/sbin/ld", ["ld", "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-ami65f/fake.so", "/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64", "-L/usr/lib/../lib64", "/tmp/ccal5ZVU.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "crtendS.o", "/usr/lib/../lib64/crtn.o"], 0x555fab77b9d0 /* 37 vars */) = -1 ENOENT (No such file or directory) [pid 400007] execve("/usr/local/bin/ld", ["ld", "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-ami65f/fake.so", "/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64", "-L/usr/lib/../lib64", "/tmp/ccal5ZVU.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "crtendS.o", "/usr/lib/../lib64/crtn.o"], 0x555fab77b9d0 /* 37 vars */) = -1 ENOENT (No such file or directory) [pid 400007] execve("/usr/sbin/ld", ["ld", "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-ami65f/fake.so", "/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64", "-L/usr/lib/../lib64", "/tmp/ccal5ZVU.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "crtendS.o", "/usr/lib/../lib64/crtn.o"], 0x555fab77b9d0 /* 37 vars */) = -1 ENOENT (No such file or directory) [pid 400007] execve("/usr/bin/ld", ["ld", "--eh-frame-hdr", "-m", "elf_x86_64", "-shared", "-o", "/tmp/libgccjit-ami65f/fake.so", "/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64", "-L/usr/lib/../lib64", "/tmp/ccal5ZVU.o", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "-lc", "-lgcc", "--push-state", "--as-needed", "-lgcc_s", "--pop-state", "crtendS.o", "/usr/lib/../lib64/crtn.o"], 0x555fab77b9d0 /* 37 vars */) = 0 ld: cannot find crtbeginS.o: No such file or directory ld: cannot find -lgcc ld: cannot find -lgcc_s [pid 400007] +++ exited with 1 +++ --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=400007, si_uid=0, si_status=1, si_utime=0, si_stime=0} --- libgccjit.so: error: error invoking gcc driver +++ exited with 1 +++
The difference of 'as' load is not too bad: /usr/x86_64-pc-linux-gnu/binutils-bin/2.36.1/as vs /usr/bin/as The difference of 'ld' is bigger: /usr/libexec/gcc/x86_64-pc-linux-gnu/11.1.0/collect2 vs /usr/bin/ld As if gcc's driver was bypassed completely. As a result we lost all the startfiles. Probably a gcc/gccjit driver bug.
Looks like the issue is related to this gcc/jit upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87808#c8
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5bd9495d157f02609a2942992e42cf08121ea15a commit 5bd9495d157f02609a2942992e42cf08121ea15a Author: Ulrich Müller <ulm@gentoo.org> AuthorDate: 2021-07-11 18:45:12 +0000 Commit: Ulrich Müller <ulm@gentoo.org> CommitDate: 2021-07-11 18:45:32 +0000 app-editors/emacs: Work around jit not working with ccache Bug: https://bugs.gentoo.org/801580 Package-Manager: Portage-3.0.20, Repoman-3.0.3 Signed-off-by: Ulrich Müller <ulm@gentoo.org> app-editors/emacs/emacs-28.0.9999.ebuild | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
I've worked around it for now by setting LIBRARY_PATH explicitly. Please test. Still, this should be fixed properly, therefore leaving this bug open.
Created attachment 723508 [details] tut01-hello-world.c It also fails with the hello world program from the libgccjit tutorial (attaching it here for later reference): https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html $ gcc tut01-hello-world.c -o tut01-hello-world -lgccjit $ ./tut01-hello-world hello world $ PATH=/usr/lib/ccache/bin:${PATH} ./tut01-hello-world ld: cannot find crtbeginS.o: No such file or directory ld: cannot find -lgcc ld: cannot find -lgcc_s libgccjit.so: error: error invoking gcc driver So this definitely isn't an Emacs bug.
(In reply to Ulrich Müller from comment #6) > I've worked around it for now by setting LIBRARY_PATH explicitly. Please > test. > > Still, this should be fixed properly, therefore leaving this bug open. Yes, this works now for app-editors/emacs-28.0.9999.
Hello, sorry I am wondering where should I point the LIBRARY_PATH? I have ccache enabled on package level, both sys-devel/gcc and app-editors/emacs are enabled, but even when I "disable" the packages for ccache in /etc/portage/package.env file, recompile them, I am unable to install spacemacs into emacs. Everytime it fails with: Debugger entered--Lisp error: (native-ice "failed to compile" "/home/djmanas/.emacs.d/eln-cache/28.2-d445f548/sub..." "error invoking gcc driver") sys-devel/gcc version 11.3.0 USE="cxx fortran graphite jit lto multilib nls nptl openmp pie sanitize ssp vtv -ada -cet -custom-cflags -d -debug -doc -fixed-point -go -hardened -libssp -objc -objc++ -objc-gc -pch -pgo -systemtap -test -valgrind -vanilla -zstd" app-editors/emacs version 28.2-r2 USE="acl alsa cairo dbus dynamic-loading games gfile gif gmp gpm gsettings gtk gui gzip-el inotify jit jpeg json lcms libxml2 png ssl svg systemd threads tiff xft xpm xwidgets zlib -Xaw3d -aqua -athena -harfbuzz -imagemagick -kerberos -livecd -m17n-lib -mailutils -motif -selinux -sound -source -toolkit-scroll-bars -wide-int" Thanks, Regards, Petr Sourek
(In reply to Petr Šourek from comment #9) > Hello, > > sorry I am wondering where should I point the LIBRARY_PATH? I have ccache > enabled on package level, both sys-devel/gcc and app-editors/emacs are > enabled, but even when I "disable" the packages for ccache in > /etc/portage/package.env file, recompile them, I am unable to install > spacemacs into emacs. Everytime it fails with: > > Debugger entered--Lisp error: (native-ice "failed to compile" > "/home/djmanas/.emacs.d/eln-cache/28.2-d445f548/sub..." "error invoking gcc > driver") > This shouldn't make any difference to when building stuff as a user.
(In reply to Sam James from comment #10) > This shouldn't make any difference to when building stuff as a user. Oh ok. So its emacs error then? I am only trying to install and setup spacemacs from scratch, but wasn't able since I had switched from MacOS. Tried more versions of emacs, all of them failed with this exact same error about: > ld: cannot find crtbeginS.o: No such file or directory > ld: cannot find -lgcc > ld: cannot find -lgcc_s > libgccjit.so: error: error invoking gcc driver So I had thought its gentoo related. I will try it there. Thanks, Regards, Petr Sourek
(In reply to Petr Šourek from comment #11) > (In reply to Sam James from comment #10) > > > This shouldn't make any difference to when building stuff as a user. > > Oh ok. So its emacs error then? I am only trying to install and setup > spacemacs from scratch, but wasn't able since I had switched from MacOS. > Tried more versions of emacs, all of them failed with this exact same error > about: > > ld: cannot find crtbeginS.o: No such file or directory > > ld: cannot find -lgcc > > ld: cannot find -lgcc_s > > libgccjit.so: error: error invoking gcc driver > Hm. I'd expect it to Just Work because gcc _itself_ knows how to find these things. What does 'gcc-config -l' show? Does it get any better if you run . /etc/profile first?
Sorry, I was completely wrong there -- I didn't re-read the bug and went off memory. If you built Emacs (or possibly spacemacs) with ccache, it will affect it.
I had rebuilt it with ccache disabled, and it did not work. It seems there is problem with the path to library. Now I am trying to install Emacs Doom and specifying the path on the start of doom seems to work. Hope it will take it into account when generating env variables. LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/ ~/.emacs.d/bin/doom install Maybee adding this variable to .spacemacs.env would work too. Thanks. It seems its ok for me with this workaround.