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.

66 lines
2.6 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. if NATIVE
  31. @@ -38,7 +39,8 @@ endif
  32. GOCFLAGS = $(CFLAGS_FOR_TARGET)
  33. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  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. cmdsrcdir = $(srcdir)/../libgo/go/cmd
  39. --- a/gotools/Makefile.in
  40. +++ b/gotools/Makefile.in
  41. @@ -252,13 +252,15 @@ 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. @NATIVE_FALSE@GOCOMPILER = $(GOC)
  48. # Use the compiler we just built.
  49. @NATIVE_TRUE@GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
  50. GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
  51. -AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
  52. +AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \
  53. + -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s
  54. GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
  55. cmdsrcdir = $(srcdir)/../libgo/go/cmd
  56. go_cmd_go_files = \