diff mbox series

Go patch committed to GCC 7 branch: update to Go 1.8.3 release

Message ID CAOyqgcWQLmaKjAujvymf+Bx497uYc0TcAhRe4KaFnV=HFgzjiQ@mail.gmail.com
State New
Headers show
Series Go patch committed to GCC 7 branch: update to Go 1.8.3 release | expand

Commit Message

Ian Lance Taylor Oct. 2, 2017, 9:05 p.m. UTC
I have committed the appended patch to update the GCC 7 branch to the
Go 1.8.3 release of the Go standard library.  The branch was
previously on the Go 1.8.1 release.  This is a fairly small patch that
fixes various bugs, a subset of the ones listed at:

https://github.com/golang/go/issues?q=is%3Aissue+milestone%3AGo1.8.2+is%3Aclosed
https://github.com/golang/go/issues?q=is%3Aissue+milestone%3AGo1.8.3+is%3Aclosed

Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
GCC 7 branch.

Ian
diff mbox series

Patch

Index: libgo/MERGE
===================================================================
--- libgo/MERGE	(revision 253365)
+++ libgo/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-a4c18f063b6659079ca2848ca217a0587dabc001
+352996a381701cfa0c16e8de29cbde8f3922182f
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
Index: libgo/VERSION
===================================================================
--- libgo/VERSION	(revision 253365)
+++ libgo/VERSION	(working copy)
@@ -1 +1 @@ 
-go1.8.1
+go1.8.3
Index: libgo/go/cmd/go/build.go
===================================================================
--- libgo/go/cmd/go/build.go	(revision 253365)
+++ libgo/go/cmd/go/build.go	(working copy)
@@ -3133,6 +3133,26 @@  func (b *builder) ccompile(p *Package, o
 	desc := p.ImportPath
 	output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", outfile, "-c", file)
 	if len(output) > 0 {
+		// On FreeBSD 11, when we pass -g to clang 3.8 it
+		// invokes its internal assembler with -dwarf-version=2.
+		// When it sees .section .note.GNU-stack, it warns
+		// "DWARF2 only supports one section per compilation unit".
+		// This warning makes no sense, since the section is empty,
+		// but it confuses people.
+		// We work around the problem by detecting the warning
+		// and dropping -g and trying again.
+		if bytes.Contains(output, []byte("DWARF2 only supports one section per compilation unit")) {
+			newFlags := make([]string, 0, len(flags))
+			for _, f := range flags {
+				if !strings.HasPrefix(f, "-g") {
+					newFlags = append(newFlags, f)
+				}
+			}
+			if len(newFlags) < len(flags) {
+				return b.ccompile(p, outfile, newFlags, file, compiler)
+			}
+		}
+
 		b.showOutput(p.Dir, desc, b.processOutput(output))
 		if err != nil {
 			err = errPrintedOutput
Index: libgo/go/crypto/elliptic/elliptic_test.go
===================================================================
--- libgo/go/crypto/elliptic/elliptic_test.go	(revision 253365)
+++ libgo/go/crypto/elliptic/elliptic_test.go	(working copy)
@@ -300,6 +300,29 @@  var p224BaseMultTests = []baseMultTest{
 	},
 }
 
+type scalarMultTest struct {
+	k          string
+	xIn, yIn   string
+	xOut, yOut string
+}
+
+var p256MultTests = []scalarMultTest{
+	{
+		"2a265f8bcbdcaf94d58519141e578124cb40d64a501fba9c11847b28965bc737",
+		"023819813ac969847059028ea88a1f30dfbcde03fc791d3a252c6b41211882ea",
+		"f93e4ae433cc12cf2a43fc0ef26400c0e125508224cdb649380f25479148a4ad",
+		"4d4de80f1534850d261075997e3049321a0864082d24a917863366c0724f5ae3",
+		"a22d2b7f7818a3563e0f7a76c9bf0921ac55e06e2e4d11795b233824b1db8cc0",
+	},
+	{
+		"313f72ff9fe811bf573176231b286a3bdb6f1b14e05c40146590727a71c3bccd",
+		"cc11887b2d66cbae8f4d306627192522932146b42f01d3c6f92bd5c8ba739b06",
+		"a2f08a029cd06b46183085bae9248b0ed15b70280c7ef13a457f5af382426031",
+		"831c3f6b5f762d2f461901577af41354ac5f228c2591f84f8a6e51e2e3f17991",
+		"93f90934cd0ef2c698cc471c60a93524e87ab31ca2412252337f364513e43684",
+	},
+}
+
 func TestBaseMult(t *testing.T) {
 	p224 := P224()
 	for i, e := range p224BaseMultTests {
@@ -379,6 +402,19 @@  func TestP256Mult(t *testing.T) {
 			break
 		}
 	}
+
+	for i, e := range p256MultTests {
+		x, _ := new(big.Int).SetString(e.xIn, 16)
+		y, _ := new(big.Int).SetString(e.yIn, 16)
+		k, _ := new(big.Int).SetString(e.k, 16)
+		expectedX, _ := new(big.Int).SetString(e.xOut, 16)
+		expectedY, _ := new(big.Int).SetString(e.yOut, 16)
+
+		xx, yy := p256.ScalarMult(x, y, k.Bytes())
+		if xx.Cmp(expectedX) != 0 || yy.Cmp(expectedY) != 0 {
+			t.Errorf("#%d: got (%x, %x), want (%x, %x)", i, xx, yy, expectedX, expectedY)
+		}
+	}
 }
 
 func TestInfinity(t *testing.T) {
Index: libgo/go/database/sql/sql.go
===================================================================
--- libgo/go/database/sql/sql.go	(revision 253365)
+++ libgo/go/database/sql/sql.go	(working copy)
@@ -1955,12 +1955,12 @@  func (s *Stmt) QueryContext(ctx context.
 				rowsi: rowsi,
 				// releaseConn set below
 			}
-			rows.initContextClose(ctx)
 			s.db.addDep(s, rows)
 			rows.releaseConn = func(err error) {
 				releaseConn(err)
 				s.db.removeDep(s, rows)
 			}
+			rows.initContextClose(ctx)
 			return rows, nil
 		}
 
Index: libgo/go/database/sql/sql_test.go
===================================================================
--- libgo/go/database/sql/sql_test.go	(revision 253365)
+++ libgo/go/database/sql/sql_test.go	(working copy)
@@ -322,7 +322,7 @@  func TestQueryContext(t *testing.T) {
 	select {
 	case <-ctx.Done():
 		if err := ctx.Err(); err != context.Canceled {
-			t.Fatalf("context err = %v; want context.Canceled")
+			t.Fatalf("context err = %v; want context.Canceled", ctx.Err())
 		}
 	default:
 		t.Fatalf("context err = nil; want context.Canceled")
@@ -413,7 +413,8 @@  func TestTxContextWait(t *testing.T) {
 	db := newTestDB(t, "people")
 	defer closeDB(t, db)
 
-	ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*15)
+	ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*15)
+	defer cancel()
 
 	tx, err := db.BeginTx(ctx, nil)
 	if err != nil {
Index: libgo/go/net/http/h2_bundle.go
===================================================================
--- libgo/go/net/http/h2_bundle.go	(revision 253365)
+++ libgo/go/net/http/h2_bundle.go	(working copy)
@@ -1,4 +1,4 @@ 
-// Code generated by golang.org/x/tools/cmd/bundle.
+// Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT.
 //go:generate bundle -o h2_bundle.go -prefix http2 -underscore golang.org/x/net/http2
 
 // Package http2 implements the HTTP/2 protocol.
@@ -3536,9 +3536,13 @@  func (sc *http2serverConn) serve() {
 		sc.idleTimerCh = sc.idleTimer.C
 	}
 
-	var gracefulShutdownCh <-chan struct{}
+	var gracefulShutdownCh chan struct{}
 	if sc.hs != nil {
-		gracefulShutdownCh = http2h1ServerShutdownChan(sc.hs)
+		ch := http2h1ServerShutdownChan(sc.hs)
+		if ch != nil {
+			gracefulShutdownCh = make(chan struct{})
+			go sc.awaitGracefulShutdown(ch, gracefulShutdownCh)
+		}
 	}
 
 	go sc.readFrames()
@@ -3587,6 +3591,14 @@  func (sc *http2serverConn) serve() {
 	}
 }
 
+func (sc *http2serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) {
+	select {
+	case <-sc.doneServing:
+	case <-sharedCh:
+		close(privateCh)
+	}
+}
+
 // readPreface reads the ClientPreface greeting from the peer
 // or returns an error on timeout or an invalid greeting.
 func (sc *http2serverConn) readPreface() error {
@@ -6003,7 +6015,6 @@  func http2commaSeparatedTrailers(req *Re
 	}
 	if len(keys) > 0 {
 		sort.Strings(keys)
-
 		return strings.Join(keys, ","), nil
 	}
 	return "", nil