Re:libgccjit: question about the GCC_JIT_FUNCTION_IMPORTED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



after many try, I solute it. for some one has the same problem, here is the solution:


1. add the link option -Wl,-E

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-E")


2. check if the compiled binary has the function
objdump -d bin | grep wrap_return_var
if there isn't, may be gcc optimize it. add the __attribute__((used))


extern "C" __attribute__((used)) void *wrap_return_var(void *s) {
    return 0;
}

3. mingw still don't work, I dont't know why, may be this link is the answer https://stackoverflow.com/questions/39759060/compile-to-dll-with-some-undefined-references-with-mingw





At 2023-12-07 00:21:05, "zhao xin" <esrrhs@xxxxxxx> wrote:

Hi, I was trying to write a toy luajit, use the libgccjit. 
and I want to call my defined functon from the jit code. not the libc function like printf or getchar. but it failed with error:

undefined reference to `wrap_return_var'
collect2.exe: error: ld returned 1 exit status
libgccjit.so: error: error invoking gcc driver


I checked my code, it seems ok, and if I change the name to printf, it compile success.
so I wonder maybe the gccjit could not call user defined function?


thanks.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux