Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #4925

Open
andrewrk opened this issue Apr 3, 2020 · 1 comment
Labels
arch-mips 32-bit and 64-bit MIPS os-linux
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Apr 3, 2020

#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)
@andrewrk andrewrk added os-linux arch-mips 32-bit and 64-bit MIPS labels Apr 3, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Apr 3, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
messense added a commit to rust-cross/cargo-zigbuild that referenced this issue Feb 24, 2022
@xbjfk
Copy link

xbjfk commented Apr 7, 2023

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.

messense added a commit to rust-cross/cargo-zigbuild that referenced this issue Apr 7, 2023
Previously it fails to link with the following error:

```
ld.lld: error: relocation R_MIPS_32 cannot be used against local symbol; recompile with -fPIC
```

See ziglang/zig#4925 (comment)
messense added a commit to rust-cross/cargo-zigbuild that referenced this issue Apr 7, 2023
Previously it fails to link with the following error:

```
ld.lld: error: relocation R_MIPS_32 cannot be used against local symbol; recompile with -fPIC
```

See ziglang/zig#4925 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-mips 32-bit and 64-bit MIPS os-linux
Projects
None yet
Development

No branches or pull requests

2 participants