Bug 47230 - [4.6 Regression] gcc fails to bootstrap on alpha in stage2 with "relocation truncated to fit: GPREL16 against ..."
Summary: [4.6 Regression] gcc fails to bootstrap on alpha in stage2 with "relocation t...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P4 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: link-failure
Depends on:
Blocks:
 
Reported: 2011-01-09 13:09 UTC by Uroš Bizjak
Modified: 2015-03-27 17:09 UTC (History)
6 users (show)

See Also:
Host: alphaev68-unknown-linux-gnu
Target: alphaev68-unknown-linux-gnu
Build: alphaev68-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2011-03-07 19:05:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uroš Bizjak 2011-01-09 13:09:15 UTC
GCC fails to bootstrap on alphaev68-unknown-linux-gnu in stage2 with:

/home/uros/gcc-build/./prev-gcc/xgcc -B/home/uros/gcc-build/./prev-gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -B/usr/local/alphaev68-unknown-linux-gnu/lib/ -isystem /usr/local/alphaev68-unknown-linux-gnu/include -isystem /usr/local/alphaev68-unknown-linux-gnu/sys-include      -g -O2 -gtoggle -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o lto1 \
	lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o main.o tree-browser.o libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a -lcloog -lppl_c -lppl -lgmpxx -lmpc -lmpfr -lgmp -rdynamic -ldl  -L../zlib -lz ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a 
libbackend.a(cfgbuild.o): In function `find_many_sub_basic_blocks':
(.text+0x450): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(cfgbuild.o): In function `find_many_sub_basic_blocks':
(.text+0xdc4): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(cfgcleanup.o): In function `mark_effect':
(.text+0x3e4): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(cfgcleanup.o): In function `try_crossjump_to_edge.isra.24':
(.text+0x1f98): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(cfgcleanup.o): In function `cleanup_cfg':
(.text+0x4870): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(cfgcleanup.o): In function `cleanup_cfg':
(.text+0x4f94): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(combine.o): In function `can_combine_p.isra.17':
(.text+0xae28): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(combine.o): In function `combine_simplify_rtx':
(.text+0x10204): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(combine.o): In function `combine_simplify_rtx':
(.text+0x12640): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(combine.o): In function `simplify_if_then_else':
(.text+0x138f8): relocation truncated to fit: GPREL16 against symbol `default_target_rtl' defined in .bss section in libbackend.a(emit-rtl.o)
libbackend.a(combine.o): In function `simplify_if_then_else':
(.text+0x13d08): additional relocation overflows omitted from the output
collect2: ld returned 1 exit status
gmake[3]: *** [lto1] Error 1
gmake[3]: Leaving directory `/space/uros/gcc-build/gcc'
gmake[2]: *** [all-stage2-gcc] Error 2
gmake[2]: Leaving directory `/space/uros/gcc-build'
gmake[1]: *** [stage2-bubble] Error 2
gmake[1]: Leaving directory `/space/uros/gcc-build'
gmake: *** [all] Error 2

It looks that "default_target_rtl" symbol can not be reached with GP relative relocation anymore.
Comment 1 Uroš Bizjak 2011-01-09 13:11:00 UTC
4.6 regression.
Comment 2 Uroš Bizjak 2011-02-21 19:47:01 UTC
Apparently fixed [1].

[1] http://gcc.gnu.org/ml/gcc-testresults/2011-02/msg02323.html
Comment 3 Serge Belyshev 2011-03-07 19:07:36 UTC
Bootstrap issue disappeared, but now linux kernel build fails with the same error:

  ld  -static -N  --build-id -o .tmp_vmlinux1 -T arch/alpha/kernel/vmlinux.lds arch/alpha/kernel/head.o  init/built-in.o --start-group  usr/built-in.o  arch/alpha/kernel/built-in.o  arch/alpha/mm/built-in.o  arch/alpha/math-emu/built-in.o  kernel/built-in.o  mm/built-in.o  fs/built-in.o  ipc/built-in.o  security/built-in.o  crypto/built-in.o  block/built-in.o  lib/lib.a  arch/alpha/lib/lib.a  lib/built-in.o  arch/alpha/lib/built-in.o  drivers/built-in.o  sound/built-in.o  firmware/built-in.o  net/built-in.o --end-group 
init/built-in.o: In function `do_one_initcall':
/home/ssb/src/linux/init/main.c:736: relocation truncated to fit: GPREL16 against symbol `initcall_debug' defined in .sbss section in init/built-in.o
/home/ssb/src/linux/init/main.c:746: relocation truncated to fit: GPREL16 against symbol `initcall_debug' defined in .sbss section in init/built-in.o
/home/ssb/src/linux/init/main.c:758: relocation truncated to fit: GPREL16 against symbol `initcall_debug' defined in .sbss section in init/built-in.o
init/built-in.o: In function `set_reset_devices':
/home/ssb/src/linux/init/main.c:197: relocation truncated to fit: GPREL16 against symbol `reset_devices' defined in .sbss section in init/built-in.o
init/built-in.o: In function `init_setup':
/home/ssb/src/linux/init/main.c:333: relocation truncated to fit: GPREL16 against `.sbss'
init/built-in.o: In function `rdinit_setup':
/home/ssb/src/linux/init/main.c:350: relocation truncated to fit: GPREL16 against `.sbss'
init/built-in.o: In function `unknown_bootoption':
/home/ssb/src/linux/init/main.c:296: relocation truncated to fit: GPREL16 against `.sbss'
/home/ssb/src/linux/init/main.c:299: relocation truncated to fit: GPREL16 against `.sbss'
/home/ssb/src/linux/init/main.c:304: relocation truncated to fit: GPREL16 against `.sbss'
/home/ssb/src/linux/init/main.c:305: relocation truncated to fit: GPREL16 against `.sbss'
/home/ssb/src/linux/init/main.c:314: additional relocation overflows omitted from the output
make: *** [.tmp_vmlinux1] Error 1
Comment 4 Jakub Jelinek 2011-03-25 19:51:38 UTC
GCC 4.6.0 is being released, adjusting target milestone.
Comment 5 Uroš Bizjak 2011-04-29 08:35:29 UTC
Unfortunately, the bootstrap on alphaev6-linux again fails with this message.
Comment 6 Mikael Pettersson 2011-04-29 09:37:37 UTC
FWIW, I've never gotten that linkage failure on my alphaev6-linux machine, and last week's snapshots (4.7-20110423, 4.6-20110422, and 4.5-20110421) all bootstrapped fine on it.

I do have quite an old binutils (2.18.50.0.9-8.fc10 20080822).  I tried binutils-2.21 once, but it regressed some gcc tls test so I ditched it.  Haven't tried any other binutils versions yet.
Comment 7 Uroš Bizjak 2011-04-29 14:01:55 UTC
(In reply to comment #6)
> FWIW, I've never gotten that linkage failure on my alphaev6-linux machine, and
> last week's snapshots (4.7-20110423, 4.6-20110422, and 4.5-20110421) all
> bootstrapped fine on it.

Can you please post your configure command?

> I do have quite an old binutils (2.18.50.0.9-8.fc10 20080822).  I tried
> binutils-2.21 once, but it regressed some gcc tls test so I ditched it. 
> Haven't tried any other binutils versions yet.

I have reported this problem to binutils and it was fixed by rth in post-2.21 SVN.
Comment 8 Mikael Pettersson 2011-04-29 17:17:48 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > FWIW, I've never gotten that linkage failure on my alphaev6-linux machine, and
> > last week's snapshots (4.7-20110423, 4.6-20110422, and 4.5-20110421) all
> > bootstrapped fine on it.
> 
> Can you please post your configure command?

Sure:

/home/mikpe/gcc-4.7-20110423/configure --prefix=/home/mikpe/install47 --with-gmp=/home/mikpe/pkgs/linux-alpha/gmp-4.3.2 --with-mpfr=/home/mikpe/pkgs/linux-alpha/mpfr-2.4.2 --with-mpc=/home/mikpe/pkgs/linux-alpha/mpc-0.8.2 --disable-plugin --disable-lto --disable-nls --enable-threads=posix --enable-checking=release --disable-libmudflap --enable-languages=c,c++ --with-long-double-128 --with-cpu=ev6

> > I do have quite an old binutils (2.18.50.0.9-8.fc10 20080822).  I tried
> > binutils-2.21 once, but it regressed some gcc tls test so I ditched it. 
> > Haven't tried any other binutils versions yet.
> 
> I have reported this problem to binutils and it was fixed by rth in post-2.21
> SVN.

Do you have a reference, like a PR number or an approximate commit date?  I'd like to backport this fix to my binutils 2.21 based branch.
Comment 9 Uroš Bizjak 2011-04-29 17:52:24 UTC
(In reply to comment #8)

> > > I do have quite an old binutils (2.18.50.0.9-8.fc10 20080822).  I tried
> > > binutils-2.21 once, but it regressed some gcc tls test so I ditched it. 
> > > Haven't tried any other binutils versions yet.
> > 
> > I have reported this problem to binutils and it was fixed by rth in post-2.21
> > SVN.
> 
> Do you have a reference, like a PR number or an approximate commit date?  I'd
> like to backport this fix to my binutils 2.21 based branch.

http://sourceware.org/bugzilla/show_bug.cgi?id=11891

Maybe you should also backport an unrelated alpha fix:

http://sourceware.org/bugzilla/show_bug.cgi?id=12610
Comment 10 Jakub Jelinek 2011-06-27 12:32:35 UTC
GCC 4.6.1 is being released.
Comment 11 Matt Turner 2011-07-08 20:42:37 UTC
gcc-4.6.1 fails to boostrap gcc-4.6.1 even with binutils-2.21.1 + fixes for 12608 and 12610 for me.
Comment 12 Uroš Bizjak 2011-07-09 08:22:18 UTC
I am using patch from URL [1] in my builds.  While not perfect, it works OK.

Since this is linker bug, I have added rth to CC in the hope that he has better solution.

[1] http://gcc.gnu.org/ml/gcc-patches/2011-05/msg00022.html
Comment 13 Matt Turner 2011-07-09 20:55:23 UTC
(In reply to comment #12)
> Since this is linker bug, I have added rth to CC in the hope that he has better
> solution.

Bug link is http://sources.redhat.com/bugzilla/show_bug.cgi?id=5276
Comment 14 Jakub Jelinek 2011-10-26 17:13:16 UTC
GCC 4.6.2 is being released.
Comment 15 Jakub Jelinek 2012-03-01 14:37:58 UTC
GCC 4.6.3 is being released.
Comment 16 Uroš Bizjak 2012-03-15 14:17:23 UTC
gcc again bootstraps OK on 4.7 branch and 4.8 mainline.
Comment 17 Mikael Pettersson 2012-04-11 20:48:54 UTC
With binutils-2.22 (vanilla) I'm unable to bootstrap gcc-4.6.3 on alphaev6-unknown-linux, due to a bunch of 'relocation truncated to fit' errors.  Applying the patch from #c12 allows gcc-4.6.3 to bootstrap, but that compiler is unable to build a linux-3.3.0 kernel, the final vmlinux link step fails with a bunch of 'relocation truncated to fit: GPREL16' errors .

gcc-4.4.7 + binutils-2.22 works.
Comment 18 Mikael Pettersson 2012-04-12 10:09:32 UTC
It seems to be triggered(*) by Uros' PR46533 patch in r166999:
http://gcc.gnu.org/viewcvs?view=revision&revision=166999

Repeat-by:
1. have cross tools to alpha-linux hosted on e.g. x86, mine has binutils-2.20.1
2. build gcc-4.6 r166998 as cross to alpha-linux
3. used the above to cross-build a linux-3.3.0 kernel, this works for me
4. repeat steps 2 and 3 with gcc-4.6 r166999, gcc builds ok but the kernel build fails with the usual 'relocation truncated to fit: GPREL16 against ...' errors

In my cross environment gcc 4.7 and 4.8 also fail to build a linux kernel, but 4.5.3 and 4.4.7 work.

(*) Presumably gcc triggers a bug in ld.
Comment 19 Uroš Bizjak 2012-04-12 10:24:36 UTC
(In reply to comment #18)
> It seems to be triggered(*) by Uros' PR46533 patch in r166999:
> http://gcc.gnu.org/viewcvs?view=revision&revision=166999

I don't think that this patch has anything to do with GPREL16. The patch fixes relocation on functions, where you have problems with symbol relocations.
 
> Repeat-by:
> 1. have cross tools to alpha-linux hosted on e.g. x86, mine has binutils-2.20.1
> 2. build gcc-4.6 r166998 as cross to alpha-linux
> 3. used the above to cross-build a linux-3.3.0 kernel, this works for me
> 4. repeat steps 2 and 3 with gcc-4.6 r166999, gcc builds ok but the kernel
> build fails with the usual 'relocation truncated to fit: GPREL16 against ...'
> errors

Just stick -Wl,--no-relax somewhere. This is standard practice to build a kernel.
Comment 20 Jakub Jelinek 2013-04-12 16:17:20 UTC
The 4.6 branch has been closed, fixed in GCC 4.7.0.
Comment 21 uros 2014-07-26 15:11:46 UTC
Author: uros
Date: Sat Jul 26 15:11:14 2014
New Revision: 213081

URL: https://gcc.gnu.org/viewcvs?rev=213081&root=gcc&view=rev
Log:
	PR target/47230
	* configure.ac (alpha*-*-linux*): Use mh-alpha-linux.
	* configure: Regenerate.

config/ChangeLog:

	PR target/47230
	* mh-alpha-linux: New file.


Added:
    trunk/config/mh-alpha-linux
Modified:
    trunk/ChangeLog
    trunk/config/ChangeLog
    trunk/configure
    trunk/configure.ac
Comment 22 uros 2014-07-26 15:18:36 UTC
Author: uros
Date: Sat Jul 26 15:18:04 2014
New Revision: 213082

URL: https://gcc.gnu.org/viewcvs?rev=213082&root=gcc&view=rev
Log:
	PR target/47230
	* configure.ac (alpha*-*-linux*): Use mh-alpha-linux.
	* configure: Regenerate.

config/ChangeLog:

	PR target/47230
	* mh-alpha-linux: New file.


Added:
    branches/gcc-4_9-branch/config/mh-alpha-linux
Modified:
    branches/gcc-4_9-branch/ChangeLog
    branches/gcc-4_9-branch/config/ChangeLog
    branches/gcc-4_9-branch/configure
    branches/gcc-4_9-branch/configure.ac
Comment 23 uros 2014-07-26 15:24:05 UTC
Author: uros
Date: Sat Jul 26 15:23:33 2014
New Revision: 213083

URL: https://gcc.gnu.org/viewcvs?rev=213083&root=gcc&view=rev
Log:
	PR target/47230
	* configure.ac (alpha*-*-linux*): Use mh-alpha-linux.
	* configure: Regenerate.

config/ChangeLog:

	PR target/47230
	* mh-alpha-linux: New file.


Added:
    branches/gcc-4_8-branch/config/mh-alpha-linux
Modified:
    branches/gcc-4_8-branch/ChangeLog
    branches/gcc-4_8-branch/config/ChangeLog
    branches/gcc-4_8-branch/configure
    branches/gcc-4_8-branch/configure.ac
Comment 24 Uroš Bizjak 2014-07-26 15:39:04 UTC
Fixed (worked around) for real for 4.8.4, 4.9.2 and 4.10.
Comment 25 uros 2015-02-25 20:00:03 UTC
Author: uros
Date: Wed Feb 25 19:59:31 2015
New Revision: 220990

URL: https://gcc.gnu.org/viewcvs?rev=220990&root=gcc&view=rev
Log:
	Revert:
	2014-07-26  Uros Bizjak  <ubizjak@gmail.com>

	PR target/47230
	* configure.ac (alpha*-*-linux*): Use mh-alpha-linux.
	* configure: Regenerate.

/config

	Revert:
	2014-07-26  Uros Bizjak  <ubizjak@gmail.com>

	PR target/47230
	* mh-alpha-linux: New file.

/gcc

	PR target/47230
	* doc/install.texi (Specific, alpha*-*-*): Document that binutils 2.25
	or newer are required.


Removed:
    trunk/config/mh-alpha-linux
Modified:
    trunk/ChangeLog
    trunk/config/ChangeLog
    trunk/configure
    trunk/configure.ac
    trunk/gcc/ChangeLog
    trunk/gcc/doc/install.texi
Comment 26 Uroš Bizjak 2015-02-25 20:03:44 UTC
(In reply to uros from comment #25)

The linker bug [1] was fixed in binutils 2.25 and GCC workaround was removed for gcc 5.0.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=5276
Comment 27 uros 2015-03-27 17:09:16 UTC
Author: uros
Date: Fri Mar 27 17:08:44 2015
New Revision: 221739

URL: https://gcc.gnu.org/viewcvs?rev=221739&root=gcc&view=rev
Log:
	Install back PR target/47230 fix (Revert the revert).

Added:
    trunk/config/mh-alpha-linux
Modified:
    trunk/ChangeLog
    trunk/config/ChangeLog
    trunk/configure
    trunk/configure.ac
    trunk/gcc/ChangeLog
    trunk/gcc/doc/install.texi