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

lld: error: relocation R_X86_64_PC32 cannot be used against symbol entry; recompile with -fPIC #3852

Open
GoNZooo opened this issue Dec 5, 2019 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@GoNZooo
Copy link

GoNZooo commented Dec 5, 2019

Environment info:

$ zig version
0.5.0+1baaf9a50
$ uname -a
Linux chaosknight 4.15.0-70-generic #79-Ubuntu SMP Tue Nov 12 10:36:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I tried my hand at making a natively implemented function for Erlang/Elixir and ran into the following issue when using build-lib:

$ zig build-lib --disable-gen-h --library c -I /usr/lib/erlang/usr/include/ --name zig_hello_world -dynamic -fPIC hello_world.zig
Build Dependencies...lld: error: relocation R_X86_64_PC32 cannot be used against symbol entry; recompile with -fPIC
>>> defined in ./zig_hello_world.o
>>> referenced by hello_world.zig:65 (/home/gonz/code/elixir/nif_sandbox/nif/hello_world.zig:65)
>>>               ./zig_hello_world.o:(nif_init)

The code being compiled (as well as the automatically generated cimport.zig file) can be found here:

https://gist.github.com/GoNZooo/973571ca3011834026bb539a28336650

Removing extern on line 64 fixes the issue but it's unclear to me why.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Dec 6, 2019
@andrewrk andrewrk added this to the 0.7.0 milestone Dec 6, 2019
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 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
@20kano
Copy link

20kano commented Apr 19, 2023

Has any progress been made on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants