runtime,cmd/dist,cmd/link: add cgo support on openbsd/arm

Add support for cgo on openbsd/arm.The gcc shipped with base OpenBSD armv7
is old/inadequate, so use clang by default.

Change-Id: I945a26d369378952d357727718e69249411e1127
Reviewed-on: https://go-review.googlesource.com/c/154381
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Joel Sing 2018-12-17 01:18:51 +11:00
parent 99e4ddd053
commit c52beb1087
5 changed files with 85 additions and 4 deletions

View file

@ -535,6 +535,12 @@ func (ctxt *Link) loadlib() {
if *flagLibGCC == "" {
*flagLibGCC = ctxt.findLibPathCmd("--print-libgcc-file-name", "libgcc")
}
if runtime.GOOS == "openbsd" && *flagLibGCC == "libgcc.a" {
// On OpenBSD `clang --print-libgcc-file-name` returns "libgcc.a".
// In this case we fail to load libgcc.a and can encounter link
// errors - see if we can find libcompiler_rt.a instead.
*flagLibGCC = ctxt.findLibPathCmd("--print-file-name=libcompiler_rt.a", "libcompiler_rt")
}
if *flagLibGCC != "none" {
hostArchive(ctxt, *flagLibGCC)
}