package/golang: new package
PATCH v2 1/1 package/golang: new package
This patch adds golang, the Go compiler-and-interpreter.
We're adding a host package to get the golang cross-compiler, and a target package to get the golang interpreter on the target.
It is to be noted that golang's buildsystem is going at great length to not do anything like any other buildsystem, and is full of little tricks.
First-off, even though it generates code for the target, the host-variant does not need the toolchain; it has its own built-in code generator. Yet, building the target variant, the toolchain is indeed required.
Second, it misdetects cross-compilation: it considers that if the target CPU and the build CPU are the same, then this is not cross-compilation. Of course, this is completely stupid and wrong. So, we need to patch it to override its insane heuristic.
Third, even so, when the target CPU is the same as the build CPU, the resulting binaries will be dynamically linked, otherwise, they are statically linked. We can't even force it one way or the other... Instead, we mark it as requiring dynamic libraries, and let the golang ill buildsystem decide whether to do static or dynamic link; we can do so because any sane toolchain will always have the static variants of the libc and libpthread, which is all that golang requires anyway.
[yann.morin.1998 at free.fr:
- add architecture-specific options
- needs dynamic linking
- fix tab-space indentation in patch 0003
- fix licensing info
]
---
V1: Sent from Yann
V2: Sent from Christian
- fixed indentation in makefile
- removed unnecessary variable initialization
--- package/Config.in | 1 + package/golang/0001-add-no-march-option-gccp.patch | 19 +++++ .../0002-remove-unnecessary-march-ld-flag.patch | 29 ++++++++ package/golang/0003-fix-make-bash-script.patch | 46 ++++++++++++ package/golang/Config.in | 22 ++++++ package/golang/golang.hash | 1 + package/golang/golang.mk | 86 ++++++++++++++++++++++ 7 files changed, 204 insertions(+) create mode 100644 package/golang/0001-add-no-march-option-gccp.patch create mode 100644 package/golang/0002-remove-unnecessary-march-ld-flag.patch create mode 100644 package/golang/0003-fix-make-bash-script.patch create mode 100644 package/golang/Config.in create mode 100644 package/golang/golang.hash create mode 100644 package/golang/golang.mk
package/Config.in +1 -0
@@ -460,6 +460,7 @@ menu "Erlang libraries/modules" source "package/erlang-p1-zlib/Config.in" endmenu endif + source "package/golang/Config.in" source "package/guile/Config.in" source "package/haserl/Config.in" source "package/jamvm/Config.in"
package/golang/0001-add-no-march-option-gccp.patch new file +19 -0
@@ -0,0 +1,19 @@ +Adds an option to not add the problematic -m parameter to GCC. + +Signed-off-by: Christian Stewart <[email protected]> + +diff -Nau golang.orig/src/cmd/cgo/gcc.go golang/src/cmd/cgo/gcc.go +--- golang.orig/src/cmd/cgo/gcc.go.orig 2015-07-09 15:53:55.720794139 -0700 ++++ golang/src/cmd/cgo/gcc.go 2015-07-09 17:46:43.664496374 -0700 +@@ -736,6 +736,11 @@ + + // gccMachine returns the gcc -m flag to use, either "-m32", "-m64" or "-marm". + func (p *Package) gccMachine() []string { ++ ++ if os.Getenv("CGO_NO_EMULATION") == "1" { ++ return nil ++ } ++ + switch goarch { + case "amd64": + return []string{"-m64"}
package/golang/0002-remove-unnecessary-march-ld-flag.patch new file +29 -0
@@ -0,0 +1,29 @@ +Removes defining -m parameter to LD, which is unnecessary in buildroot. + +Signed-off-by: Christian Stewart <[email protected]> + +diff -Nau golang.orig/src/cmd/ld/lib.c golang/src/cmd/ld/lib.c +--- golang.orig/src/cmd/ld/lib.c.orig 2015-07-09 18:38:44.192359082 -0700 ++++ golang/src/cmd/ld/lib.c 2015-07-09 18:39:02.108358294 -0700 +@@ -589,20 +589,7 @@ + if(extld == nil) + extld = "gcc"; + argv[argc++] = extld; +- switch(thechar){ +- case '8': +- argv[argc++] = "-m32"; +- break; +- case '6': +- argv[argc++] = "-m64"; +- break; +- case '5': +- argv[argc++] = "-marm"; +- break; +- } +- if(!debug['s'] && !debug_s) { +- argv[argc++] = "-gdwarf-2"; +- } else { ++ if(debug['s'] || debug_s) { + argv[argc++] = "-s"; + } + if(HEADTYPE == Hdarwin)
package/golang/0003-fix-make-bash-script.patch new file +46 -0
46 lines not on this page · raw message
package/golang/Config.in new file +22 -0
@@ -0,0 +1,22 @@ +comment "golang needs a toolchain w/ threads, dynamic library" + depends on BR2_PACKAGE_GOLANG_ARCH_SUPPORTS + depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS + +# golang only supports x86, x86_64 and ARM (LE) targets. +# For ARM, armv5 or above is required. +config BR2_PACKAGE_GOLANG_ARCH_SUPPORTS + bool + default y + depends on BR2_USE_MMU + depends on BR2_i386 || BR2_x86_64 || BR2_arm + depends on !BR2_ARM_CPU_ARMV4 + +config BR2_PACKAGE_GOLANG + bool "golang" + depends on BR2_PACKAGE_GOLANG_ARCH_SUPPORTS + depends on !BR2_STATIC_LIBS + depends on BR2_TOOLCHAIN_HAS_THREADS + help + Go compiler and cli tool. + + http://golang.org/
package/golang/golang.hash new file +1 -0
@@ -0,0 +1 @@ +sha1 460caac03379f746c473814a65223397e9c9a2f6 go1.4.2.src.tar.gz
package/golang/golang.mk new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 1/1 package/golang: new package
Christian, All,
On 2015-07-29 15:37 -0700, Christian Stewart spake thusly:
Quoted 1 line
This patch adds golang, the Go compiler-and-interpreter.
Please, do not resend so fast.
After a review, it is usually good to wait a bit, to give others a chance to review, too.
Re-sending too fast means others would review the previous iteration (bad) but that you would also have a lot of re-spin to do. Also, potential reviewr (and committer) may get wary of this many respins.
I know you are probably eager to see that merged soon, but re-sending too fast is not the best way to make that happen.
Unless the committer asks for a simple fixup and a prompt respin, of course. Otherwise, let it settle for a day...
Beside, in that case, your respin is not correct, because it does not address the rm-rf that Thomas pointed out, so I'll have to repin my version...
Don't get me wrong: I too am eager to see it merged, and we all do appreciate your work on this! :-)
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'