toolchain/gcc: add GCC 8.1.0
[openwrt/openwrt.git] / toolchain / gcc / patches / 8.1.0 / 960-gotools-fix-compilation-when-making-cross-compiler.patch
1 From dda6b050cd74a352670787a294596a9c56c21327 Mon Sep 17 00:00:00 2001
2 From: Yousong Zhou <yszhou4tech@gmail.com>
3 Date: Fri, 4 May 2018 18:20:53 +0800
4 Subject: [PATCH] gotools: fix compilation when making cross compiler
5
6 libgo is "the runtime support library for the Go programming language.
7 This library is intended for use with the Go frontend."
8
9 gccgo will link target files with libgo.so which depends on libgcc_s.so.1, but
10 the linker will complain that it cannot find it. That's because shared libgcc
11 is not present in the install directory yet. libgo.so was made without problem
12 because gcc will emit -lgcc_s when compiled with -shared option. When gotools
13 were being made, it was supplied with -static-libgcc thus no link option was
14 provided. Check LIBGO in gcc/go/gcc-spec.c for how gccgo make a builtin spec
15 for linking with libgo.so
16
17 - GccgoCrossCompilation, https://github.com/golang/go/wiki/GccgoCrossCompilation
18 - Cross-building instructions, http://www.eglibc.org/archives/patches/msg00078.html
19
20 When 3-pass GCC compilation is used, shared libgcc runtime libraries will be
21 available after gcc pass2 completed and will meet the gotools link requirement
22 at gcc pass3
23 ---
24 gotools/Makefile.am | 4 +++-
25 gotools/Makefile.in | 4 +++-
26 2 files changed, 6 insertions(+), 2 deletions(-)
27
28 --- a/gotools/Makefile.am
29 +++ b/gotools/Makefile.am
30 @@ -26,6 +26,7 @@ PWD_COMMAND = $${PWDCMD-pwd}
31 STAMP = echo timestamp >
32
33 libgodir = ../$(target_noncanonical)/libgo
34 +libgccdir = ../$(target_noncanonical)/libgcc
35 LIBGODEP = $(libgodir)/libgo.la
36
37 LIBGOTOOL = $(libgodir)/libgotool.a
38 @@ -41,7 +42,8 @@ GOCFLAGS = $(CFLAGS_FOR_TARGET)
39 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
40
41 AM_GOCFLAGS = -I $(libgodir)
42 -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
43 +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
44 + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
45 GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
46
47 libgosrcdir = $(srcdir)/../libgo/go
48 --- a/gotools/Makefile.in
49 +++ b/gotools/Makefile.in
50 @@ -263,6 +263,7 @@ mkinstalldirs = $(SHELL) $(toplevel_srcd
51 PWD_COMMAND = $${PWDCMD-pwd}
52 STAMP = echo timestamp >
53 libgodir = ../$(target_noncanonical)/libgo
54 +libgccdir = ../$(target_noncanonical)/libgcc
55 LIBGODEP = $(libgodir)/libgo.la
56 LIBGOTOOL = $(libgodir)/libgotool.a
57 @NATIVE_FALSE@GOCOMPILER = $(GOC)
58 @@ -271,7 +272,8 @@ LIBGOTOOL = $(libgodir)/libgotool.a
59 @NATIVE_TRUE@GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
60 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
61 AM_GOCFLAGS = -I $(libgodir)
62 -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
63 +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
64 + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
65 GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
66 libgosrcdir = $(srcdir)/../libgo/go
67 cmdsrcdir = $(libgosrcdir)/cmd