[Pkg-golang-commits] [golang] 02/03: Backport three patches from upstream to fix ftbfs on ppc64el with new kernel.
Michael Hudson-Doyle
mwhudson-guest at moszumanska.debian.org
Mon Oct 30 23:44:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
mwhudson-guest pushed a commit to branch golang-1.9
in repository golang.
commit f3563394b81e1a833a25e34c10a93d749d3c3534
Author: Michael Hudson-Doyle <michael.hudson at canonical.com>
Date: Tue Oct 31 11:36:17 2017 +1300
Backport three patches from upstream to fix ftbfs on ppc64el with new kernel.
---
...md-dist-use-buildmode-pie-for-pie-testing.patch | 99 ++++++++++++++++++++++
...-buildmode-pie-in-testCgoPprofPIE-instead.patch | 39 +++++++++
...-cgo-testcarchive-use-no-pie-where-needed.patch | 61 +++++++++++++
debian/patches/series | 3 +
4 files changed, 202 insertions(+)
diff --git a/debian/patches/0004-cmd-dist-use-buildmode-pie-for-pie-testing.patch b/debian/patches/0004-cmd-dist-use-buildmode-pie-for-pie-testing.patch
new file mode 100644
index 0000000..4914f4a
--- /dev/null
+++ b/debian/patches/0004-cmd-dist-use-buildmode-pie-for-pie-testing.patch
@@ -0,0 +1,99 @@
+From ca8c361d867d62bd46013c5abbaaad0b2ca6077f Mon Sep 17 00:00:00 2001
+From: Lynn Boger <laboger at linux.vnet.ibm.com>
+Date: Thu, 28 Sep 2017 10:26:39 -0400
+Subject: [PATCH] cmd/dist: use -buildmode=pie for pie testing
+
+Some tests in misc/cgo/test are run with various options including
+'-linkmode=external "-extldflags=-pie"'. On ppc64x passing -pie to
+the external linker with code that was not compiled as position
+independent is incorrect. This works by luck in many cases but is
+not guaranteed to work. I suspect it is an issue on other targets
+as well.
+
+This will now run the tests using -buildmode=pie for the platforms
+that support that buildmode option.
+
+Fixes #21954
+
+Change-Id: I25fc7573f2d3cb5b0d1c691a0ac91aef7715404f
+Reviewed-on: https://go-review.googlesource.com/66870
+Run-TryBot: Lynn Boger <laboger at linux.vnet.ibm.com>
+TryBot-Result: Gobot Gobot <gobot at golang.org>
+Reviewed-by: Ian Lance Taylor <iant at golang.org>
+---
+ src/cmd/dist/test.go | 41 ++++++++++++++---------------------------
+ 1 file changed, 14 insertions(+), 27 deletions(-)
+
+--- a/src/cmd/dist/test.go
++++ b/src/cmd/dist/test.go
+@@ -852,6 +852,16 @@
+ return true
+ }
+ return false
++ case "pie":
++ switch pair {
++ case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x",
++ "android-amd64", "android-arm", "android-arm64", "android-386":
++ return true
++ case "darwin-amd64":
++ return true
++ }
++ return false
++
+ default:
+ log.Fatalf("internal error: unknown buildmode %s", mode)
+ return false
+@@ -928,49 +938,15 @@
+ // static linking on FreeBSD/ARM with clang. (cgo depends on
+ // -fPIC fundamentally.)
+ default:
+- cc := mustEnv("CC")
+- cmd := t.dirCmd("misc/cgo/test",
+- cc, "-xc", "-o", "/dev/null", "-static", "-")
+- cmd.Env = env
+- cmd.Stdin = strings.NewReader("int main() {}")
+- if err := cmd.Run(); err != nil {
+- fmt.Println("No support for static linking found (lacks libc.a?), skip cgo static linking test.")
+- } else {
+- if t.goos != "android" {
+- cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
+- cmd.Env = env
+- }
+-
+- cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test")
++ if t.supportedBuildmode("pie") {
++ cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-buildmode=pie")
+ cmd.Env = env
+
+- cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external`)
++ cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-buildmode=pie")
+ cmd.Env = env
+
+- if t.goos != "android" {
+- cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-static -pthread"`)
+- cmd.Env = env
+- }
+- }
+-
+- if pair != "freebsd-amd64" { // clang -pie fails to link misc/cgo/test
+- cmd := t.dirCmd("misc/cgo/test",
+- cc, "-xc", "-o", "/dev/null", "-pie", "-")
++ cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-buildmode=pie")
+ cmd.Env = env
+- cmd.Stdin = strings.NewReader("int main() {}")
+- if err := cmd.Run(); err != nil {
+- fmt.Println("No support for -pie found, skip cgo PIE test.")
+- } else {
+- cmd = t.addCmd(dt, "misc/cgo/test", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
+- cmd.Env = env
+-
+- cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
+- cmd.Env = env
+-
+- cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
+- cmd.Env = env
+-
+- }
+ }
+ }
+ }
diff --git a/debian/patches/0005-runtime-use-buildmode-pie-in-testCgoPprofPIE-instead.patch b/debian/patches/0005-runtime-use-buildmode-pie-in-testCgoPprofPIE-instead.patch
new file mode 100644
index 0000000..7b1d941
--- /dev/null
+++ b/debian/patches/0005-runtime-use-buildmode-pie-in-testCgoPprofPIE-instead.patch
@@ -0,0 +1,39 @@
+From 58de9f358375e87f07605852530383fee0a4b671 Mon Sep 17 00:00:00 2001
+From: Lynn Boger <laboger at linux.vnet.ibm.com>
+Date: Fri, 27 Oct 2017 10:06:40 -0400
+Subject: [PATCH] runtime: use -buildmode=pie in testCgoPprofPIE instead of
+ -extldflags=-pie
+
+Errors occur in runtime test testCgoPprofPIE when the test
+is built by passing -pie to the external linker with code
+that was not built as PIC. This occurs on ppc64le because
+non-PIC is the default, and fails only on newer distros
+where the address range used for programs is high enough
+to cause relocation overflow. This test should be built
+with -buildmode=pie since that correctly generates PIC
+with -pie.
+
+Related issues are #21954 and #22126.
+
+Updates #22459
+
+Change-Id: Ib641440bc9f94ad2b97efcda14a4b482647be8f7
+Reviewed-on: https://go-review.googlesource.com/73970
+Run-TryBot: Lynn Boger <laboger at linux.vnet.ibm.com>
+TryBot-Result: Gobot Gobot <gobot at golang.org>
+Reviewed-by: Ian Lance Taylor <iant at golang.org>
+---
+ src/runtime/crash_cgo_test.go | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/src/runtime/crash_cgo_test.go
++++ b/src/runtime/crash_cgo_test.go
+@@ -330,7 +330,7 @@
+ }
+
+ func TestCgoPprofPIE(t *testing.T) {
+- testCgoPprof(t, "-ldflags=-extldflags=-pie", "CgoPprof")
++ testCgoPprof(t, "-buildmode=pie", "CgoPprof")
+ }
+
+ func TestCgoPprofThread(t *testing.T) {
diff --git a/debian/patches/0006-misc-cgo-testcarchive-use-no-pie-where-needed.patch b/debian/patches/0006-misc-cgo-testcarchive-use-no-pie-where-needed.patch
new file mode 100644
index 0000000..3abd4b4
--- /dev/null
+++ b/debian/patches/0006-misc-cgo-testcarchive-use-no-pie-where-needed.patch
@@ -0,0 +1,61 @@
+From c15c44ec48fa278330b5d205cf7b4508250496fe Mon Sep 17 00:00:00 2001
+From: Lynn Boger <laboger at linux.vnet.ibm.com>
+Date: Wed, 11 Oct 2017 16:02:59 -0400
+Subject: [PATCH] misc/cgo/testcarchive: use -no-pie where needed
+
+Starting in gcc 6, -pie is passed to the linker by default
+on some platforms, including ppc64le. If the objects
+being linked are not built for -pie then in some cases the
+executable could be in error. To avoid that problem, -no-pie
+should be used with gcc to override the default -pie option
+and generate a correct executable that can be run without error.
+
+Fixes #22126
+
+Change-Id: I4a052bba8b9b3bd6706f5d27ca9a7cebcb504c95
+Reviewed-on: https://go-review.googlesource.com/70072
+Run-TryBot: Lynn Boger <laboger at linux.vnet.ibm.com>
+TryBot-Result: Gobot Gobot <gobot at golang.org>
+Reviewed-by: Ian Lance Taylor <iant at golang.org>
+---
+ misc/cgo/testcarchive/carchive_test.go | 20 +++++++++++++++++++-
+ 1 file changed, 19 insertions(+), 1 deletion(-)
+
+--- a/misc/cgo/testcarchive/carchive_test.go
++++ b/misc/cgo/testcarchive/carchive_test.go
+@@ -6,6 +6,7 @@
+
+ import (
+ "bufio"
++ "bytes"
+ "debug/elf"
+ "fmt"
+ "io/ioutil"
+@@ -605,9 +606,26 @@
+ }
+
+ exe := "./testnoshared" + exeSuffix
+- ccArgs := append(cc, "-o", exe, "main5.c", "libgo2.a")
++
++ // In some cases, -no-pie is needed here, but not accepted everywhere. First try
++ // if -no-pie is accepted. See #22126.
++ ccArgs := append(cc, "-o", exe, "-no-pie", "main5.c", "libgo2.a")
+ t.Log(ccArgs)
+ out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
++
++ // If -no-pie unrecognized, try -nopie if this is possibly clang
++ if err != nil && bytes.Contains(out, []byte("unknown")) && !strings.Contains(cc[0], "gcc") {
++ ccArgs = append(cc, "-o", exe, "-nopie", "main5.c", "libgo2.a")
++ t.Log(ccArgs)
++ out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
++ }
++
++ // Don't use either -no-pie or -nopie
++ if err != nil && bytes.Contains(out, []byte("unrecognized")) {
++ ccArgs := append(cc, "-o", exe, "main5.c", "libgo2.a")
++ t.Log(ccArgs)
++ out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
++ }
+ t.Logf("%s", out)
+ if err != nil {
+ t.Fatal(err)
diff --git a/debian/patches/series b/debian/patches/series
index 2362f90..47c2abc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,5 @@
0002-reproducible-BUILD_PATH_PREFIX_MAP.patch
0003-Do-not-use-SP-as-index-reg.patch
+0004-cmd-dist-use-buildmode-pie-for-pie-testing.patch
+0005-runtime-use-buildmode-pie-in-testCgoPprofPIE-instead.patch
+0006-misc-cgo-testcarchive-use-no-pie-where-needed.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-golang/golang.git
More information about the pkg-golang-commits
mailing list