0822790d6b222f3d3854947bd6475e24ab333278
[feed/packages.git] / devel / gcc / patches / 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 if NATIVE
38 @@ -38,7 +39,8 @@ endif
39 GOCFLAGS = $(CFLAGS_FOR_TARGET)
40 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
41
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 cmdsrcdir = $(srcdir)/../libgo/go/cmd
48 --- a/gotools/Makefile.in
49 +++ b/gotools/Makefile.in
50 @@ -252,13 +252,15 @@ 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 @NATIVE_FALSE@GOCOMPILER = $(GOC)
57
58 # Use the compiler we just built.
59 @NATIVE_TRUE@GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
60 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
61 -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
62 +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
63 + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
64 GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
65 cmdsrcdir = $(srcdir)/../libgo/go/cmd
66 go_cmd_go_files = \