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.

67 lines
2.7 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. --- a/gotools/Makefile.am
  24. +++ b/gotools/Makefile.am
  25. @@ -26,6 +26,7 @@ PWD_COMMAND = $${PWDCMD-pwd}
  26. STAMP = echo timestamp >
  27. libgodir = ../$(target_noncanonical)/libgo
  28. +libgccdir = ../$(target_noncanonical)/libgcc
  29. LIBGODEP = $(libgodir)/libgo.la
  30. LIBGOTOOL = $(libgodir)/libgotool.a
  31. @@ -41,7 +42,8 @@ GOCFLAGS = $(CFLAGS_FOR_TARGET)
  32. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  33. AM_GOCFLAGS = -I $(libgodir)
  34. -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
  35. +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
  36. + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
  37. GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
  38. libgosrcdir = $(srcdir)/../libgo/go
  39. --- a/gotools/Makefile.in
  40. +++ b/gotools/Makefile.in
  41. @@ -337,6 +337,7 @@ mkinstalldirs = $(SHELL) $(toplevel_srcd
  42. PWD_COMMAND = $${PWDCMD-pwd}
  43. STAMP = echo timestamp >
  44. libgodir = ../$(target_noncanonical)/libgo
  45. +libgccdir = ../$(target_noncanonical)/libgcc
  46. LIBGODEP = $(libgodir)/libgo.la
  47. LIBGOTOOL = $(libgodir)/libgotool.a
  48. @NATIVE_FALSE@GOCOMPILER = $(GOC)
  49. @@ -346,7 +347,8 @@ LIBGOTOOL = $(libgodir)/libgotool.a
  50. GOCFLAGS = $(CFLAGS_FOR_TARGET)
  51. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  52. AM_GOCFLAGS = -I $(libgodir)
  53. -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
  54. +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
  55. + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
  56. GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
  57. libgosrcdir = $(srcdir)/../libgo/go
  58. cmdsrcdir = $(libgosrcdir)/cmd