#988313 libgccjit-8-dev: Smoke test of libgccjit fails

#988313#5
Date:
2021-05-10 09:47:23 UTC
From:
To:
Dear Maintainer,

Short: the libgccjit example from the GNU GCC tutorial on JIT segfaults.


I tried to compile Emacs from GIT HEAD (aa354dd55b213b86ee8e3aa0365a6ad915838458), but
during ./configure --with-native-compilation it spit out this text:

...
checking for library containing inflateEnd... -lz
checking for dladdr... yes
checking for dlfunc... no
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: Installed libgccjit has failed passing the smoke test.
You can verify it yourself compiling:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
Please report the issue to your distribution if libgccjit was installed through
that.
Here instructions on how to compile and install libgccjit from source:
<https://gcc.gnu.org/wiki/JIT>.




I then tried the tutorial01.html example as well, and the compilation step of that
page worked so far. But running it gave me this error:

$ ./tut01-hello-world
Segmentation fault




While I wrote this error report, I also install libgccjit-8-dbg via apt-get and used GDB.
The following backtrace happens:

$ gdb ./tut01-hello-world
Reading symbols from ./tut01-hello-world...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/schurig/.doom.d/emacs.git/tut01-hello-world

Program received signal SIGSEGV, Segmentation fault.
0xb74c07ba in do_add_prefix (pprefix=0xbffff250, prefix=0x4446b0 "/home/schurig/.local/bin/", first=false)
    at ../../src/gcc/file-find.c:139
139	../../src/gcc/file-find.c: No such file or directory.
(gdb) bt
#0  0xb74c07ba in do_add_prefix (pprefix=0xbffff250, prefix=0x4446b0 "/home/schurig/.local/bin/", first=false)
    at ../../src/gcc/file-find.c:139
#1  0xb74c07ee in add_prefix (pprefix=0xbffff250, prefix=0x4446b0 "/home/schurig/.local/bin/")
    at ../../src/gcc/file-find.c:147
#2  0xb74c08e8 in prefix_from_string (
    p=0xbfffff44 "/home/schurig/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games",
    pprefix=0xbffff250) at ../../src/gcc/file-find.c:201
#3  0xb74c09ac in prefix_from_env (env=0xb755b6ec "PATH", pprefix=0xbffff250) at ../../src/gcc/file-find.c:168
#4  0xb67fc4e4 in gcc::jit::playback::context::invoke_embedded_driver (this=0xbffff414, argvec=0xbffff2b4)
    at ../../src/gcc/jit/jit-playback.c:2513
#5  0xb67fee9d in gcc::jit::playback::context::invoke_driver (this=0xbffff414,
    ctxt_progname=0xb754eec8 "libgccjit.so", input_file=0x40ae90 "/tmp/libgccjit-wIeDdd/fake.s",
    output_file=0x40aec0 "/tmp/libgccjit-wIeDdd/fake.so", tv_id=TV_ASSEMBLE, shared=true, run_linker=true)
    at ../../src/gcc/jit/jit-playback.c:2492
#6  0xb67ffeb7 in gcc::jit::playback::context::convert_to_dso (this=0xbffff414,
    ctxt_progname=0xb754eec8 "libgccjit.so") at ../../src/gcc/jit/jit-tempdir.h:59
#7  0xb67fff26 in gcc::jit::playback::compile_to_memory::postprocess (this=0xbffff414,
    ctxt_progname=0xb754eec8 "libgccjit.so") at ../../src/gcc/jit/jit-playback.c:1900
#8  0xb67fe93d in gcc::jit::playback::context::compile (this=0xbffff414) at ../../src/gcc/jit/jit-playback.c:1873
#9  0xb67f4911 in gcc::jit::recording::context::compile (this=0x40a8c0) at ../../src/gcc/jit/jit-recording.c:1352
#10 0xb67e85b9 in gcc_jit_context_compile (ctxt=0x40a8c0) at ../../src/gcc/jit/libgccjit.c:2679
#11 0x00401466 in main ()


Note that this is on i386, not on amd64, maybe this is related. However, because I develop for
embedded x86 devices, I'd rather stay on i386 as long as possible.