You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

  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. libgo is "the runtime support library for the Go programming language.
  6. This library is intended for use with the Go frontend."
  7. gccgo will link target files with libgo.so which depends on libgcc_s.so.1, but
  8. the linker will complain that it cannot find it. That's because shared libgcc
  9. is not present in the install directory yet. libgo.so was made without problem
  10. because gcc will emit -lgcc_s when compiled with -shared option. When gotools
  11. were being made, it was supplied with -static-libgcc thus no link option was
  12. provided. Check LIBGO in gcc/go/gcc-spec.c for how gccgo make a builtin spec
  13. for linking with libgo.so
  14. - GccgoCrossCompilation, https://github.com/golang/go/wiki/GccgoCrossCompilation
  15. - Cross-building instructions, http://www.eglibc.org/archives/patches/msg00078.html
  16. When 3-pass GCC compilation is used, shared libgcc runtime libraries will be
  17. available after gcc pass2 completed and will meet the gotools link requirement
  18. at gcc pass3
  19. ---
  20. gotools/Makefile.am | 4 +++-
  21. gotools/Makefile.in | 4 +++-
  22. 2 files changed, 6 insertions(+), 2 deletions(-)
  23. diff --git a/gotools/Makefile.am b/gotools/Makefile.am
  24. index 5f3940a278b..9c22f5df103 100644
  25. --- a/gotools/Makefile.am
  26. +++ b/gotools/Makefile.am
  27. @@ -26,6 +26,7 @@ PWD_COMMAND = $${PWDCMD-pwd}
  28. STAMP = echo timestamp >
  29. libgodir = ../$(target_noncanonical)/libgo
  30. +libgccdir = ../$(target_noncanonical)/libgcc
  31. LIBGODEP = $(libgodir)/libgo.la
  32. if NATIVE
  33. @@ -38,7 +39,8 @@ endif
  34. GOCFLAGS = $(CFLAGS_FOR_TARGET)
  35. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  36. -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
  37. +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
  38. + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
  39. GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
  40. cmdsrcdir = $(srcdir)/../libgo/go/cmd
  41. diff --git a/gotools/Makefile.in b/gotools/Makefile.in
  42. index 4386576b011..0bdd9290e01 100644
  43. --- a/gotools/Makefile.in
  44. +++ b/gotools/Makefile.in
  45. @@ -252,13 +252,15 @@ mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
  46. PWD_COMMAND = $${PWDCMD-pwd}
  47. STAMP = echo timestamp >
  48. libgodir = ../$(target_noncanonical)/libgo
  49. +libgccdir = ../$(target_noncanonical)/libgcc
  50. LIBGODEP = $(libgodir)/libgo.la
  51. @NATIVE_FALSE@GOCOMPILER = $(GOC)
  52. # Use the compiler we just built.
  53. @NATIVE_TRUE@GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
  54. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  55. -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
  56. +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
  57. + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
  58. GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
  59. cmdsrcdir = $(srcdir)/../libgo/go/cmd
  60. go_cmd_go_files = \
  61. --
  62. 2.16.3