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

rebar.config: add -fPIC #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

rebar.config: add -fPIC #208

wants to merge 1 commit into from

Conversation

ffontaine
Copy link

Add -fPIC to avoid the following build failure:

/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
sh(/home/buildroot/autobuild/instance-3/output-1/host/bin/x86_64-linux-g++ c_src/decoder.o c_src/encoder.o c_src/jiffy.o c_src/termstack.o c_src/utf8.o c_src/util.o c_src/doubles.o c_src/objects.o c_src/double-conversion/bignum-dtoa.o c_src/double-conversion/bignum.o c_src/double-conversion/cached-powers.o c_src/double-conversion/diy-fp.o c_src/double-conversion/double-conversion.o c_src/double-conversion/fast-dtoa.o c_src/double-conversion/fixed-dtoa.o c_src/double-conversion/strtod.o  -flto -lstdc++ -flto -lstdc++ -shared  -L/home/buildroot/autobuild/instance-3/output-1/host/x86_64-buildroot-linux-uclibc/sysroot/usr/lib/erlang/lib/erl_interface-3.13.1/lib -lei -o priv/jiffy.so)
failed with return code 1 and the following output:
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

ERROR: Command [compile] failed!

Fixes:

Signed-off-by: Fabrice Fontaine fontaine.fabrice@gmail.com

Add -fPIC to avoid the following build failure:

/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
sh(/home/buildroot/autobuild/instance-3/output-1/host/bin/x86_64-linux-g++ c_src/decoder.o c_src/encoder.o c_src/jiffy.o c_src/termstack.o c_src/utf8.o c_src/util.o c_src/doubles.o c_src/objects.o c_src/double-conversion/bignum-dtoa.o c_src/double-conversion/bignum.o c_src/double-conversion/cached-powers.o c_src/double-conversion/diy-fp.o c_src/double-conversion/double-conversion.o c_src/double-conversion/fast-dtoa.o c_src/double-conversion/fixed-dtoa.o c_src/double-conversion/strtod.o  -flto -lstdc++ -flto -lstdc++ -shared  -L/home/buildroot/autobuild/instance-3/output-1/host/x86_64-buildroot-linux-uclibc/sysroot/usr/lib/erlang/lib/erl_interface-3.13.1/lib -lei -o priv/jiffy.so)
failed with return code 1 and the following output:
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: /tmp/cc0ULrdG.ltrans1.ltrans.o: relocation R_X86_64_PC32 against symbol `dec_destroy' can not be used when making a shared object; recompile with -fPIC
/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/8.3.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

ERROR: Command [compile] failed!

Fixes:
 - http://autobuild.buildroot.org/results/9ac6e1bf9eaf922c0b7f869416ec33f40ed3543c

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
@davisp
Copy link
Owner

davisp commented Feb 22, 2022

Guess I've been a bad maintainer since I hadn't noticed this until just now. What platform/compiler was this on?

@ffontaine
Copy link
Author

This build failure was raised with LTO enabled.
We had an interesting discussion on buildroot here: https://patchwork.ozlabs.org/project/buildroot/patch/20201224101440.3427472-1-fontaine.fabrice@gmail.com/

The conclusion of this discussion was:

However, the real question is: why does rebar add -fPIC during build but not
during link? I think this is something that should be fixed at the level of rebar itself, not in individual packages.

So, feel free to close this PR if you think that this issue should be fixed in rebar.

@davisp
Copy link
Owner

davisp commented Feb 22, 2022

@ffontaine Ah! Thanks for the quick update. I think I'm in agreement with you. I'll report it on the port_compiler plugin issue tracker.

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

Successfully merging this pull request may close these issues.

2 participants