Rebase to 1.9.2

execute correctly pie tests
allow to ignore tests via bcond
reduce size of golang package
This commit is contained in:
Jakub Čajka 2017-10-31 16:04:15 +01:00
parent 920ea39083
commit 315b776905
5 changed files with 137 additions and 6 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@
/go1.9beta2.src.tar.gz
/go1.9.src.tar.gz
/go1.9.1.src.tar.gz
/go1.9.2.src.tar.gz

View File

@ -1,4 +1,5 @@
%bcond_with bootstrap
%bcond_with ignore_tests
# build ids are not currently generated:
# https://code.google.com/p/go/issues/detail?id=5238
#
@ -49,10 +50,10 @@
%endif
# Controls what ever we fail on failed tests
%ifarch %{ix86} x86_64 %{arm} aarch64 ppc64le
%global fail_on_tests 1
%else
%if %{with ignore_tests}
%global fail_on_tests 0
%else
%global fail_on_tests 1
%endif
# Build golang shared objects for stdlib
@ -95,10 +96,10 @@
%endif
%global go_api 1.9
%global go_version 1.9.1
%global go_version 1.9.2
Name: golang
Version: 1.9.1
Version: 1.9.2
Release: 1%{?dist}
Summary: The Go Programming Language
# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
@ -141,6 +142,11 @@ Patch219: s390x-expose-IfInfomsg-X__ifi_pad.patch
Patch220: s390x-ignore-L0syms.patch
# https://github.com/golang/go/commit/ca8c361d867d62bd46013c5abbaaad0b2ca6077f
Patch221: use-buildmode-pie-for-pie-testing.patch
# https://github.com/hyangah/go/commit/3502496d03bcd842fd7aac95ec0d7096d581cd26
Patch222: use-no-pie-where-needed.patch
# Having documentation separate was broken
Obsoletes: %{name}-docs < 1.1-4
@ -274,6 +280,9 @@ Requires: %{name} = %{version}-%{release}
%patch220 -p1
%patch221 -p1 -b pie
%patch222 -p1
cp %{SOURCE1} ./src/runtime/
%build
@ -471,6 +480,7 @@ fi
%exclude %{goroot}/src/
%exclude %{goroot}/doc/
%exclude %{goroot}/misc/
%exclude %{goroot}/test/
%{goroot}/*
# ensure directory ownership, so they are cleaned up if empty
@ -508,6 +518,12 @@ fi
%endif
%changelog
* Thu Oct 26 2017 Jakub Čajka <jcajka@redhat.com> - 1.9.2-1
- Rebase to 1.9.2
- execute correctly pie tests
- allow to ignore tests via bcond
- reduce size of golang package
* Fri Oct 06 2017 Jakub Čajka <jcajka@redhat.com> - 1.9.1-1
- fix CVE-2017-15041 and CVE-2017-15042

View File

@ -1 +1 @@
SHA512 (go1.9.1.src.tar.gz) = 3c5d11089a54c61acd1a4fad9618ddb2058cc783a54564407ee50e37c864deaadfd5effeab623080c136a599096f448aae091ef41d0afca1abfcdb98adf4a793
SHA512 (go1.9.2.src.tar.gz) = 1034098575c317eeaf648629690a4dea0c479a69c3b80d9917f6b96c8781ce79c0f29859f667dc4e07d47a44972aa09bd0163a458f897cf45f9d09eb03e4abb5

View File

@ -0,0 +1,51 @@
diff -up go/src/cmd/dist/test.go.pie go/src/cmd/dist/test.go
--- go/src/cmd/dist/test.go.pie 2017-10-25 20:30:21.000000000 +0200
+++ go/src/cmd/dist/test.go 2017-11-03 16:47:55.290829798 +0100
@@ -852,6 +852,16 @@ func (t *tester) supportedBuildmode(mode
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
@@ -953,24 +963,16 @@ func (t *tester) cgoTest(dt *distTest) e
}
}
- if pair != "freebsd-amd64" { // clang -pie fails to link misc/cgo/test
- cmd := t.dirCmd("misc/cgo/test",
- cc, "-xc", "-o", "/dev/null", "-pie", "-")
+ if t.supportedBuildmode("pie") {
+ cmd = t.addCmd(dt, "misc/cgo/test", "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/testtls", "go", "test", "-buildmode=pie")
+ cmd.Env = env
- cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
- cmd.Env = env
+ cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-buildmode=pie")
+ cmd.Env = env
- }
}
}
}

View File

@ -0,0 +1,63 @@
From 3502496d03bcd842fd7aac95ec0d7096d581cd26 Mon Sep 17 00:00:00 2001
From: Lynn Boger <laboger@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@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
---
misc/cgo/testcarchive/carchive_test.go | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go
index b5123154e79..ac637c06007 100644
--- a/misc/cgo/testcarchive/carchive_test.go
+++ b/misc/cgo/testcarchive/carchive_test.go
@@ -6,6 +6,7 @@ package carchive_test
import (
"bufio"
+ "bytes"
"debug/elf"
"fmt"
"io/ioutil"
@@ -609,9 +610,26 @@ func TestCompileWithoutShared(t *testing.T) {
}
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)