Fix linking relocatable objects on Sparc
PATCH 1/1 Fix linking relocatable objects on Sparc
On Sparc, gcc implicitly passes --relax to the linker, but -r is incompatible with this. Therefore, if --no-relax is supported, it should be passed to the linker.
Signed-off-by James Clarke <[email protected]>
--- configure | 13 +++++++++++++ rules.mak | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)
configure +13 -0
@@ -4508,6 +4508,18 @@ if compile_prog "" "" ; then have_fsxattr=yes fi +################################################# +# Sparc implicitly links with --relax, which is +# incompatible with -r. It does no harm to give +# it on other platforms too. + +cat > $TMPC << EOF +int foo(void) { return 0; } +EOF +if compile_prog "" "-nostdlib -Wl,-r -Wl,--no-relax"; then + LD_REL_FLAGS="-Wl,--no-relax" +fi + ########################################## # End of CC checks # After here, no more $cc or $ld runs
@@ -5513,6 +5525,7 @@ else fi echo "LDFLAGS=$LDFLAGS" >> $config_host_mak echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak +echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak echo "LIBS+=$LIBS" >> $config_host_mak echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak
rules.mak +1 -1
@@ -93,7 +93,7 @@ module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS) $(if $(findstring /,$@),$(call quiet-command,cp $@ $(subst /,-,$@), " CP $(subst /,-,$@)")) -LD_REL := $(CC) -nostdlib -Wl,-r +LD_REL := $(CC) -nostdlib -Wl,-r $(LD_REL_FLAGS) %.mo: $(call quiet-command,$(LD_REL) -o $@ $^," LD -r $(TARGET_DIR)$@")
Signature · 1 line
2.8.2
Michael Tokarev
AppliedQuoted 3 lines · James Clarke
On Sparc, gcc implicitly passes --relax to the linker, but -r is incompatible with this. Therefore, if --no-relax is supported, it should be passed to the linker.
Applied to -trivial, thanks!
/mjt