unable to link shared object for mipsel-linux: lld: error: can't create dynamic relocation R_MIPS_32 against symbol: DW.ref.__gxx_personality_v0 in readonly segment
andrewrk opened this issue · 1 comments
andrewrk commented
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}zig build-lib -dynamic --c-source hello.cpp -lc++ -lc -target mipsel-linux-musl
It outputs this error many times. Here are the first 3:
lld: error: can't create dynamic relocation R_MIPS_32 against symbol: DW.ref.__gxx_personality_v0 in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o
>>> referenced by hello.cpp
>>> zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o:(.eh_frame+0xAB0B)
lld: error: can't create dynamic relocation R_MIPS_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o
>>> referenced by hello.cpp
>>> zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o:(.eh_frame+0xAB25)
lld: error: can't create dynamic relocation R_MIPS_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o
>>> referenced by hello.cpp
>>> zig-cache/o/wBiI-p6eCZdmTuXt5tRTRWO2FhNemqh2pP_OHQZkLg3tpaS7QxKY8XE-koliaV8r/hello.o:(.eh_frame+0xAB55)
xbjfk commented
Seems to be a problem with ld.lld: llvm/llvm-project#58377, https://reviews.llvm.org/D80392
To workaround this one can pass -Wl,-z,notext to the linker.