Today at work, on a Redhat 5.5 machine, I tried to build Go 1.4.
This happened:
` $ cd go1.4/src $ ./all.bash …snip…
runtime/cgo
/usr/bin/ld: unrecognized option ‘–build-id=none’ /usr/bin/ld: use the –help option for usage information collect2: ld returned 1 exit status `
The solution is to retry without the “–build-id=none” option:
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
index ad03239..ca45217 100644
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -2436,13 +2436,21 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, pcCFLAGS, pcLDFLAGS, cgofi
// --build-id=none. So that is what we do, but only on
// systems likely to support it, which is to say, systems that
// normally use gold or the GNU linker.
+ retryWithoutBuildId := false
switch goos {
case "android", "dragonfly", "linux", "netbsd":
ldflags = append(ldflags, "-Wl,--build-id=none")
+ retryWithoutBuildId = true
}
if err := b.gccld(p, ofile, ldflags, gccObjs); err != nil {
- return nil, nil, err
+ if retryWithoutBuildId {
+ ldflags = ldflags[0:len(ldflags)-1]
+ err = b.gccld(p, ofile, ldflags, gccObjs)
+ }
+ if err != nil {
+ return nil, nil, err
+ }
}
// NOTE(rsc): The importObj is a 5c/6c/8c object and on Windows
Just in case someone else is looking for it… :)
Go does not officially support RHEL before version 6, but it does seem to sort of work. This post explains why it doesn’t really work.