Bug 17219 - ld/mips: can no longer build libstdc++ (gcc 4.8/4.9)
Summary: ld/mips: can no longer build libstdc++ (gcc 4.8/4.9)
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Matthew Fortune
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-01 11:36 UTC by Manuel Lauss
Modified: 2016-06-18 06:43 UTC (History)
2 users (show)

See Also:
Host:
Target: mipsel-softfloat-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Lauss 2014-08-01 11:36:26 UTC
For the last few days, current git-head of binutils is unable to build libstdc++ during cross-build of gcc:

libtool: link:  /tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/./gcc/xgcc -shared-libgcc -B/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/./gcc -nostdinc++ -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/src -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/src/.libs -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/mipsel-softfloat-linux-gnu/bin/ -B/usr/mipsel-softfloat-linux-gnu/lib/ -isystem /usr/mipsel-softfloat-linux-gnu/include -isystem /usr/mipsel-softfloat-linux-gnu/sys-include    -shared -nostdlib /usr/mipsel-softfloat-linux-gnu/usr/lib/crti.o /tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/./gcc/crtbeginS.o  .libs/compatibility.o .libs/compatibility-debug_list.o .libs/compatibility-debug_list-2.o .libs/compatibility-c++0x.o .libs/compatibility-atomic-c++0x.o .libs/compatibility-thread-c++0x.o .libs/compatibility-chrono.o .libs/compatibility-condvar.o  -Wl,--whole-archive ../libsupc++/.libs/libsupc++convenience.a ../src/c++98/.libs/libc++98convenience.a ../src/c++11/.libs/libc++11convenience.a -Wl,--no-whole-archive  -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/libsupc++/.libs -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/src -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/mipsel-softfloat-linux-gnu/libstdc++-v3/src/.libs -lm -L/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/./gcc -L/usr/mipsel-softfloat-linux-gnu/lib -L/usr/mipsel-softfloat-linux-gnu/usr/lib -lc -lgcc_s /tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/work/build/./gcc/crtendS.o /usr/mipsel-softfloat-linux-gnu/usr/lib/crtn.o  -Wl,-O1 -Wl,-z -Wl,relro -Wl,--gc-sections -Wl,--version-script=libstdc++-symbols.ver   -Wl,-soname -Wl,libstdc++.so.6 -o .libs/libstdc++.so.6.0.20
/usr/libexec/gcc/mipsel-softfloat-linux-gnu/ld: .libs/compatibility.o: relocation R_MIPS_26 against `memmove' can not be used when making a shared object; recompile with -fPIC
.libs/compatibility.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Also, builds are full of these messages:
/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/temp/ccGy6M7d.s: Assembler messages:
/tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.9.0/temp/ccGy6M7d.s: Warning: .gnu_attribute 4,3 requires `softfloat'
Comment 1 Manuel Lauss 2014-08-01 15:51:59 UTC
started with commit 351cdf24d223290b15fa991e5052ec9e9bd1e284 (
[MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions)

Reverting this one lets me cross-build gcc again AND also build a mips32 kernel!
Comment 2 Manuel Lauss 2014-08-20 20:07:09 UTC
native builds are also affected: for example gcc-4.9.1 built natively fails with
libtool: link: mipsel-softfloat-linux-gnu-gcc -shared  .libs/lto-plugin.o    -Wl,--as-needed  -static-libgcc -Wl,-O1 ../libiberty/pic/libiberty.a   -Wl,-soname -Wl,liblto_plugin.so.0 -o .libs/liblto_plugin.so.0.0.0
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: .libs/lto-plugin.o: relocation 4 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: .libs/lto-plugin.o: relocation 5 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: .libs/lto-plugin.o: relocation 5 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: .libs/lto-plugin.o: relocation 4 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: .libs/lto-plugin.o: relocation 5 against `stderr' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.9.1/../../../../mipsel-softfloat-linux-gnu/bin/ld: error: non-dynamic relocations refer to dynamic symbol stderr

and so on.  Again, reverting the above mentioned commit fixes everything.
Comment 3 Aaro Koskinen 2015-01-10 16:02:10 UTC
I get similar errors with release 2.25 binutils. Trying to cross-build MIPS GCC configured with --with-float=soft fails miserably. With hard float there is no issues (or binutils 2.24 with soft float). Apparently 2.25 binutils require some additional flags which GCC 4.9 fails to pass?

Is there any simple workaround for this?
Comment 4 Matthew Fortune 2015-01-11 22:05:11 UTC
(In reply to Aaro Koskinen from comment #3)
> I get similar errors with release 2.25 binutils. Trying to cross-build MIPS
> GCC configured with --with-float=soft fails miserably. With hard float there
> is no issues (or binutils 2.24 with soft float). Apparently 2.25 binutils
> require some additional flags which GCC 4.9 fails to pass?
> 
> Is there any simple workaround for this?

This is a compiler driver issue. The LD failures relating to relocations are somewhat strange but I believe they are not the important part here. The ABI problems from the assembler warnings are the root cause.

I've put together a backport of minimal GCC driver changes for the GCC 4.9 branch and that is pretty much the only way to resolve this. The new floating-point ABI checks in the assembler unfortunately couldn't be seamless for everything and soft-float is the case that takes most of the pain.

With the GCC patch in place I managed to build a GCC 4.9 (branch) + binutils 2.25 (branch) soft-float toolchain. I'll post the patch to GCC at some point tomorrow and try to remember and update this ticket with a link. The patch should apply cleanly to any GCC 4.9 release so will have to be ported by a distribution maintainer if anyone wants any of the already released GCC 4.9.x compilers alongside binutils 2.25 onwards.

I will look at a similar patch for GCC 4.8 if there is sufficient call for that alongside binutils 2.25.

Sorry for not getting to the GCC 4.9 patch sooner, I knew about it and never quite got to doing it.
Comment 5 Aaro Koskinen 2015-02-06 22:47:25 UTC
GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64569
Comment 6 Aaro Koskinen 2015-02-06 22:56:36 UTC
(In reply to Matthew Fortune from comment #4)
> With the GCC patch in place I managed to build a GCC 4.9 (branch) + binutils
> 2.25 (branch) soft-float toolchain. I'll post the patch to GCC at some point
> tomorrow and try to remember and update this ticket with a link. The patch
> should apply cleanly to any GCC 4.9 release so will have to be ported by a
> distribution maintainer if anyone wants any of the already released GCC
> 4.9.x compilers alongside binutils 2.25 onwards.

I don't see any patch related to this in GCC 4.9 branch...

> I will look at a similar patch for GCC 4.8 if there is sufficient call for
> that alongside binutils 2.25.

Also this would be nice...
Comment 7 Manuel Lauss 2016-06-18 06:43:57 UTC
I'm marking this a s "fixed" since gcc-4.9 and gcc-5 branch and their libstdc++ build just fine and have been for over 8 months now.