Gentoo Archives: gentoo-alt

From: Fabian Groffen <grobian@g.o>
To: gentoo-alt@l.g.o
Subject: [gentoo-alt] [PREFIX] Solaris && GNU ld 2.22
Date: Fri, 17 Feb 2012 23:04:12
Message-Id: 20120217220653.GM944@gentoo.org
1 All,
2
3 I just ran into this problem myself on all of my Solaris Prefixes.
4
5 Problem: after upgrading GNU binutils to 2.22, compiling starts to fail
6
7 On x86-based Solaris, any compilation fails with an ld error like this:
8 ld: target elf32-i386 not found
9 sparc-based systems fail when linking against libraries that GNU linker
10 scripts exist for (e.g. libpcre, or libz) with a similar error.
11
12 Cause: starting from GNU ld 2.21 a targets for Solaris were introduced,
13 *_sol2, that strictly match the Solaris 2 ABI. In GNU ld 2.22 these
14 targets are the only ones that work. GCC 4.5 knows about this, and
15 targets the *_sol2 targets at configure time.
16
17 If you upgrade GNU binutils to 2.22, your system hence breaks when your
18 GCC wasn't compiled when GNU binutils 2.21 was around on your system.
19
20 On sparc-based systems, the problem can be remedied quite easily,
21 fortunately, by just fixing the GNU ld-scripts to reference the right
22 target, like so for a 32-bits environment:
23 sed -i -e 's/^OUTPUT_FORMAT ( elf32-sparc )$/OUTPUT_FORMAT ( elf32-sparc-sol2 )/' $EPREFIX/usr/lib/lib*.so
24 or likewise for a 64-bits environment:
25 sed -i -e 's/^OUTPUT_FORMAT ( elf64-sparc )$/OUTPUT_FORMAT ( elf64-sparc-sol2 )/' $EPREFIX/usr/lib/lib*.so
26
27 Because of a different setup in the GCC spec-file for x86-based systems,
28 the fix there is much more complicated. If possible, recompile gcc
29 before upgrading binutils. GCC now has a patch that makes it behave
30 on x86 like sparc, such that the damage is reduced.
31
32 Like on sparc, we need to fix the GNU ld-scripts, for 32-bits
33 environment:
34 sed -i -e 's/^OUTPUT_FORMAT ( elf32-i386 )$/OUTPUT_FORMAT ( elf32-i386-sol2 )/' $EPREFIX/usr/lib/lib*.so
35 or for a 64-bits environment:
36 sed -i -e 's/^OUTPUT_FORMAT ( elf64-x86-64 )$/OUTPUT_FORMAT ( elf64-x86-64-sol2 )/' $EPREFIX/usr/lib/lib*.so
37
38 With the broken interaction of the compiler with the linker, we have to
39 hack around it by using a GCC spec-file that won't omit a (wrong) target
40 when calling the linker.
41
42 gcc -dumpspecs | sed 's/!m64:/m32/' > /var/tmp/specs
43 env CC="gcc -specs=/var/tmp/specs" emerge -1 gcc
44
45 After this you should have a working compiler again.
46
47
48 --
49 Fabian Groffen
50 Gentoo on a different level

Attachments

File name MIME type
signature.asc application/pgp-signature