jiffy icon indicating copy to clipboard operation
jiffy copied to clipboard

rebar.config: add -fPIC

Open ffontaine opened this issue 3 years ago • 3 comments

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 [email protected]

ffontaine avatar Dec 24 '20 10:12 ffontaine

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

davisp avatar Feb 22 '22 21:02 davisp

This build failure was raised with LTO enabled. We had an interesting discussion on buildroot here: https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

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.

ffontaine avatar Feb 22 '22 21:02 ffontaine

@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.

davisp avatar Feb 22 '22 21:02 davisp