golang: Fix clang compatibility with pie
authorFredrik Fornwall <fredrik@fornwall.net>
Thu, 18 Aug 2016 22:24:44 +0000 (18:24 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Thu, 18 Aug 2016 22:24:44 +0000 (18:24 -0400)
packages/golang/src-cmd-go-build.go.patch [new file with mode: 0644]

diff --git a/packages/golang/src-cmd-go-build.go.patch b/packages/golang/src-cmd-go-build.go.patch
new file mode 100644 (file)
index 0000000..eb8eb40
--- /dev/null
@@ -0,0 +1,39 @@
+diff -u -r ../go/src/cmd/go/build.go ./src/cmd/go/build.go
+--- ../go/src/cmd/go/build.go  2016-08-15 18:47:58.000000000 -0400
++++ ./src/cmd/go/build.go      2016-08-18 18:05:18.471655968 -0400
+@@ -2846,7 +2846,7 @@
+               ldflags = append(ldflags, "-Wl,-r", "-nostdlib", "-Wl,--whole-archive", "-lgolibbegin", "-Wl,--no-whole-archive")
+               if b.gccSupportsNoPie() {
+-                      ldflags = append(ldflags, "-no-pie")
++                      ldflags = append(ldflags, "-nopie")
+               }
+               // We are creating an object file, so we don't want a build ID.
+@@ -3029,7 +3029,7 @@
+               }
+       }
+-      if strings.Contains(a[0], "clang") {
++      if runtime.GOOS == "android" {
+               // disable ASCII art in clang errors, if possible
+               a = append(a, "-fno-caret-diagnostics")
+               // clang is too smart about command-line arguments
+@@ -3064,7 +3064,7 @@
+ // -no-pie must be passed when doing a partial link with -Wl,-r. But -no-pie is
+ // not supported by all compilers.
+ func (b *builder) gccSupportsNoPie() bool {
+-      return b.gccSupportsFlag("-no-pie")
++      return b.gccSupportsFlag("-nopie")
+ }
+ // gccSupportsFlag checks to see if the compiler supports a flag.
+@@ -3383,7 +3383,7 @@
+       ldflags := stringList(bareLDFLAGS, "-Wl,-r", "-nostdlib", staticLibs)
+       if b.gccSupportsNoPie() {
+-              ldflags = append(ldflags, "-no-pie")
++              ldflags = append(ldflags, "-nopie")
+       }
+       // We are creating an object file, so we don't want a build ID.