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

Build breaks because -fPIC is missing: ld: error: relocation R_X86_64_32S cannot be used against local symbol; recompile with -fPIC #19

Open
yurivict opened this issue May 3, 2024 · 5 comments

Comments

@yurivict
Copy link

yurivict commented May 3, 2024

ld: error: relocation R_X86_64_PC32 cannot be used against symbol '__stack_chk_guard'; recompile with -fPIC
>>> defined in /lib/libc.so.7
>>> referenced by samplerate.c
>>>               samplerate.c.o:(src_new) in archive _deps/libsamplerate-build/src/libsamplerate.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in _deps/libsamplerate-build/src/libsamplerate.a(src_linear.c.o)
>>> referenced by src_linear.c
>>>               src_linear.c.o:(linear_get_name) in archive _deps/libsamplerate-build/src/libsamplerate.a

ld: error: relocation R_X86_64_32S cannot be used against local symbol; recompile with -fPIC
>>> defined in _deps/libsamplerate-build/src/libsamplerate.a(samplerate.c.o)
>>> referenced by samplerate.c
>>>               samplerate.c.o:(src_new) in archive _deps/libsamplerate-build/src/libsamplerate.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in _deps/libsamplerate-build/src/libsamplerate.a(src_linear.c.o)
>>> referenced by src_linear.c
>>>               src_linear.c.o:(linear_get_description) in archive _deps/libsamplerate-build/src/libsamplerate.a

FreeBSD 14.0

@Epiphero
Copy link

I had a similar issue trying to install within the AWS public.ecr.aws/lambda/python:3.11 Docker image for a lambda layer. My workaround was to add CFLAGS and (well most likely or would work) CXXFLAGS environment variables. Stripped down version of what worked for me:

FROM public.ecr.aws/lambda/python:3.11
ENTRYPOINT []

RUN yum install -y cmake3 gcc gcc-c++ git make
RUN ln -s /usr/bin/cmake3 /usr/bin/cmake

ENV CFLAGS="-fPIC"
ENV CXX_FLAGS="-fPIC"
RUN pip install samplerate

@oyvindln
Copy link

oyvindln commented May 17, 2024

I get the same error when building the wheel when trying to install it on fedora 40. It doesn't happen on ubuntu 24.04 or cachyos (arch based) and builds fine on those, not sure why there is the difference between distros - maybe some difference between default compile flags?

Edit, someone is also getting the same error on OpenSUSE in #17

@fakufaku
Copy link
Collaborator

@oyvindln Have you tried the fix above? I don't know enough to decide if adding -fPIC by default is a good solution or not.
It may depend on what compiler is used.

@oyvindln
Copy link

Tested and doing CFLAGS="-fPIC" CXX_FLAGS="-fPIC" pip install samplerate inside a virtual python environment does make the install suceed so that is a workaround at least.

I don't really use fedora I was just testing if it was installable as I use it in a project.

@vxgmichel
Copy link

I just had that same issue with cibuildwheel here while building wheels for a project that depends on python-samplerate:

        /opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: _deps/libsamplerate-build/src/libsamplerate.a(samplerate.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

I'd rather not use the -fPIC workaround because I don't want to change the way cibuildwheel does its magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants