[gnome-continuous-yocto/gnomeostree-3.28-rocko: 8212/8267] go: Fix build with PIE on musl



commit fe51ddba0652a4fdac7cf40d9c6a3dcb4ebff83c
Author: Khem Raj <raj khem gmail com>
Date:   Fri Oct 6 11:40:08 2017 -0700

    go: Fix build with PIE on musl
    
    (From OE-Core rev: d6fcf91c06a3d118e8741273fac6903100141db4)
    
    Signed-off-by: Khem Raj <raj khem gmail com>
    Signed-off-by: Ross Burton <ross burton intel com>
    Signed-off-by: Armin Kuster <akuster mvista com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 meta/recipes-devtools/go/go-1.9.inc                |    3 +
 .../go/go-1.9/default-buildmode-pie.patch          |   18 +++
 .../go/go-1.9/set-external-linker.patch            |  111 ++++++++++++++++++++
 3 files changed, 132 insertions(+), 0 deletions(-)
---
diff --git a/meta/recipes-devtools/go/go-1.9.inc b/meta/recipes-devtools/go/go-1.9.inc
index 65adaa8..f52abb5 100644
--- a/meta/recipes-devtools/go/go-1.9.inc
+++ b/meta/recipes-devtools/go/go-1.9.inc
@@ -15,6 +15,9 @@ SRC_URI += "\
         file://0007-ld-add-soname-to-shareable-objects.patch \
         file://0008-make.bash-add-GOHOSTxx-indirection-for-cross-canadia.patch \
         file://0009-cmd-go-buildmode-pie-forces-external-linking-mode-on.patch \
+        file://default-buildmode-pie.patch \
 "
+SRC_URI_append_libc-musl = " file://set-external-linker.patch"
+
 SRC_URI[main.md5sum] = "da2d44ea384076efec43ee1f8b7d45d2"
 SRC_URI[main.sha256sum] = "a4ab229028ed167ba1986825751463605264e44868362ca8e7accc8be057e993"
diff --git a/meta/recipes-devtools/go/go-1.9/default-buildmode-pie.patch 
b/meta/recipes-devtools/go/go-1.9/default-buildmode-pie.patch
new file mode 100644
index 0000000..a7933bd
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.9/default-buildmode-pie.patch
@@ -0,0 +1,18 @@
+Default to PIE on linux platforms
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj khem gmail com>
+
+diff -upr src/go.orig/src/cmd/go/internal/work/build.go src/go/src/cmd/go/internal/work/build.go
+--- go.orig/src/cmd/go/internal/work/build.go  2017-08-27 17:38:26.354750979 +0200
++++ go/src/cmd/go/internal/work/build.go       2017-08-27 17:40:27.555130105 +0200
+@@ -304,7 +304,8 @@ func BuildModeInit() {
+               ldBuildmode = "c-shared"
+       case "default":
+               switch platform {
+-              case "android/arm", "android/arm64", "android/amd64", "android/386":
++              case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",
++                      "android/arm", "android/arm64", "android/amd64", "android/386":
+                       codegenArg = "-shared"
+                       ldBuildmode = "pie"
+               case "darwin/arm", "darwin/arm64":
diff --git a/meta/recipes-devtools/go/go-1.9/set-external-linker.patch 
b/meta/recipes-devtools/go/go-1.9/set-external-linker.patch
new file mode 100644
index 0000000..d6bd7fa
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.9/set-external-linker.patch
@@ -0,0 +1,111 @@
+Change the dynamic linker hardcoding to use musl when not using glibc
+this should be applied conditional to musl being the system C library
+
+Upstream-Status: Inappropriate [Real Fix should be portable across libcs]
+
+Signed-off-by: Khem Raj <raj khem gmail com>
+
+Index: go/src/cmd/link/internal/amd64/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/amd64/obj.go
++++ go/src/cmd/link/internal/amd64/obj.go
+@@ -67,7 +67,7 @@ func Init() {
+       ld.Thearch.Append64 = ld.Append64l
+       ld.Thearch.TLSIEtoLE = tlsIEtoLE
+ 
+-      ld.Thearch.Linuxdynld = "/lib64/ld-linux-x86-64.so.2"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-x86_64.so.1"
+       ld.Thearch.Freebsddynld = "/libexec/ld-elf.so.1"
+       ld.Thearch.Openbsddynld = "/usr/libexec/ld.so"
+       ld.Thearch.Netbsddynld = "/libexec/ld.elf_so"
+Index: go/src/cmd/link/internal/arm/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/arm/obj.go
++++ go/src/cmd/link/internal/arm/obj.go
+@@ -63,7 +63,7 @@ func Init() {
+       ld.Thearch.Append32 = ld.Append32l
+       ld.Thearch.Append64 = ld.Append64l
+ 
+-      ld.Thearch.Linuxdynld = "/lib/ld-linux.so.3" // 2 for OABI, 3 for EABI
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-armhf.so.1"
+       ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1"
+       ld.Thearch.Openbsddynld = "/usr/libexec/ld.so"
+       ld.Thearch.Netbsddynld = "/libexec/ld.elf_so"
+Index: go/src/cmd/link/internal/arm64/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/arm64/obj.go
++++ go/src/cmd/link/internal/arm64/obj.go
+@@ -62,7 +62,7 @@ func Init() {
+       ld.Thearch.Append32 = ld.Append32l
+       ld.Thearch.Append64 = ld.Append64l
+ 
+-      ld.Thearch.Linuxdynld = "/lib/ld-linux-aarch64.so.1"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-aarch64.so.1"
+ 
+       ld.Thearch.Freebsddynld = "XXX"
+       ld.Thearch.Openbsddynld = "XXX"
+Index: go/src/cmd/link/internal/mips/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/mips/obj.go
++++ go/src/cmd/link/internal/mips/obj.go
+@@ -77,7 +77,7 @@ func Init() {
+               ld.Thearch.Append64 = ld.Append64b
+       }
+ 
+-      ld.Thearch.Linuxdynld = "/lib/ld.so.1"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-mipsle.so.1"
+ 
+       ld.Thearch.Freebsddynld = "XXX"
+       ld.Thearch.Openbsddynld = "XXX"
+Index: go/src/cmd/link/internal/mips64/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/mips64/obj.go
++++ go/src/cmd/link/internal/mips64/obj.go
+@@ -75,7 +75,7 @@ func Init() {
+               ld.Thearch.Append64 = ld.Append64b
+       }
+ 
+-      ld.Thearch.Linuxdynld = "/lib64/ld64.so.1"
++      ld.Thearch.Linuxdynld = "/lib64/ld-musl-mips64le.so.1"
+ 
+       ld.Thearch.Freebsddynld = "XXX"
+       ld.Thearch.Openbsddynld = "XXX"
+Index: go/src/cmd/link/internal/ppc64/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/ppc64/obj.go
++++ go/src/cmd/link/internal/ppc64/obj.go
+@@ -77,7 +77,7 @@ func Init() {
+       }
+ 
+       // TODO(austin): ABI v1 uses /usr/lib/ld.so.1
+-      ld.Thearch.Linuxdynld = "/lib64/ld64.so.1"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-powerpc64le.so.1"
+ 
+       ld.Thearch.Freebsddynld = "XXX"
+       ld.Thearch.Openbsddynld = "XXX"
+Index: go/src/cmd/link/internal/s390x/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/s390x/obj.go
++++ go/src/cmd/link/internal/s390x/obj.go
+@@ -62,7 +62,7 @@ func Init() {
+       ld.Thearch.Append32 = ld.Append32b
+       ld.Thearch.Append64 = ld.Append64b
+ 
+-      ld.Thearch.Linuxdynld = "/lib64/ld64.so.1"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-s390x.so.1"
+ 
+       // not relevant for s390x
+       ld.Thearch.Freebsddynld = "XXX"
+Index: go/src/cmd/link/internal/x86/obj.go
+===================================================================
+--- go.orig/src/cmd/link/internal/x86/obj.go
++++ go/src/cmd/link/internal/x86/obj.go
+@@ -63,7 +63,7 @@ func Init() {
+       ld.Thearch.Append32 = ld.Append32l
+       ld.Thearch.Append64 = ld.Append64l
+ 
+-      ld.Thearch.Linuxdynld = "/lib/ld-linux.so.2"
++      ld.Thearch.Linuxdynld = "/lib/ld-musl-i386.so.1"
+       ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1"
+       ld.Thearch.Openbsddynld = "/usr/libexec/ld.so"
+       ld.Thearch.Netbsddynld = "/usr/libexec/ld.elf_so"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]