Bug ID 1185529
Summary libgccjit does not find libgcc/crtbegin.o
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware Other
OS Other
Status NEW
Severity Normal
Priority P5 - None
Component Development
Assignee screening-team-bugs@suse.de
Reporter opensusebz@halobates.de
QA Contact qa-bugs@suse.de
Found By ---
Blocker ---

Trying to compile current emacs with libgccjit11, but the test of libgccjit at
configure time fails:

(t.c is below)
gcc t.c -lgccjit
./a.out
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


strace shows that the paths seem to be incorrect:

strace -e execve -f ./a.out
...
[pid 23720] execve("/usr/bin/ld", ["ld", "--build-id", "--eh-frame-hdr", "-m",
"elf_x86_64", "-shared", "-o", "/tmp/libgccjit-X37gMf/fake.so",
"/usr/lib/../lib64/crti.o", "crtbeginS.o", "-L/lib/../lib64",
"-L/usr/lib/../lib64", "/tmp/ccgGNXSP.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"], 0x14203a0 /* 105 vars */) = 0

crtbegin etc. are in /usr/lib64/gcc/x86_64-suse-linux/ 
but the driver is not telling the linker that.

t.c:

 #include <libgccjit.h>
       #include <stdlib.h>
       #include <stdio.h>
       int
       main (int argc, char **argv)
       {
         gcc_jit_context *ctxt;
         gcc_jit_result *result;
         ctxt = gcc_jit_context_acquire ();
         if (!ctxt)
           exit (1);
         gcc_jit_type *int_type =
           gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
         gcc_jit_function *func =
           gcc_jit_context_new_function (ctxt, NULL,
                                         GCC_JIT_FUNCTION_EXPORTED,
                                         int_type, "foo", 0, NULL, 0);
         gcc_jit_block *block = gcc_jit_function_new_block (func, "foo");
         gcc_jit_block_end_with_return (
           block,
           NULL,
           gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
         result = gcc_jit_context_compile (ctxt);
         if (!result)
           exit (1);
         typedef int (*fn_type) (void);
         fn_type foo =
           (fn_type)gcc_jit_result_get_code (result, "foo");
         if (!foo)
           exit (1);
         if (foo () != 1)
           exit (1);
         gcc_jit_context_release (ctxt);
         gcc_jit_result_release (result);
         return 0;
       }


You are receiving this mail because: