Skip to content

Commit c5cf662

Browse files
author
Bryan C. Mills
committed
all: move internal/x to vendor/golang.org/x and revendor using 'go mod vendor'
This also updates the vendored-in versions of several packages: 'go mod vendor' selects a consistent version of each module, but we had previously vendored an ad-hoc selection of packages. Notably, x/crypto/hkdf was previously vendored in at a much newer commit than the rest of x/crypto. Bringing the rest of x/crypto up to that commit introduced an import of golang.org/x/sys/cpu, which broke the js/wasm build, requiring an upgrade of x/sys to pick up CL 165749. Updates golang#30228 Updates golang#30241 Updates golang#25822 Change-Id: I5b3dbc232b7e6a048a158cbd8d36137af1efb711 Reviewed-on: https://go-review.googlesource.com/c/go/+/164623 Reviewed-by: Filippo Valsorda <filippo@golang.org>
1 parent 0fc89a7 commit c5cf662

File tree

240 files changed

+3250
-11361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+3250
-11361
lines changed

src/cmd/dist/build.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,21 @@ func xinit() {
192192

193193
gogcflags = os.Getenv("BOOT_GO_GCFLAGS")
194194

195+
// Add -mod=vendor to GOFLAGS so that commands won't try to resolve go.mod
196+
// files for vendored external modules.
197+
// TODO(golang.org/issue/30240): If the vendor directory contains the go.mod
198+
// files, this probably won't be necessary.
199+
// TODO(golang.org/issue/26849): Escape spaces in GOFLAGS if needed.
200+
goflags := strings.Fields(os.Getenv("GOFLAGS"))
201+
for i, flag := range goflags {
202+
if strings.HasPrefix(flag, "-mod=") {
203+
goflags = append(goflags[0:i], goflags[i+1:]...)
204+
break
205+
}
206+
}
207+
goflags = append(goflags, "-mod=vendor")
208+
os.Setenv("GOFLAGS", strings.Join(goflags, " "))
209+
195210
cc, cxx := "gcc", "g++"
196211
if defaultclang {
197212
cc, cxx = "clang", "clang++"

src/cmd/dist/test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,10 @@ func (t *tester) registerTests() {
419419
if !t.race {
420420
cmd.Args = append(cmd.Args, "cmd")
421421
}
422+
cmd.Stderr = new(bytes.Buffer)
422423
all, err := cmd.Output()
423424
if err != nil {
424-
log.Fatalf("Error running go list std cmd: %v, %s", err, all)
425+
log.Fatalf("Error running go list std cmd: %v:\n%s", err, cmd.Stderr)
425426
}
426427
pkgs := strings.Fields(string(all))
427428
for _, pkg := range pkgs {

src/cmd/go/testdata/script/gopath_std_vendor.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ stdout $GOPATH[/\\]src[/\\]vendor
99
# to the package 'vendor/golang.org/x/net/http2/hpack' within GOROOT.
1010
cd importnethttp
1111
go list -deps -f '{{.ImportPath}} {{.Dir}}'
12-
stdout ^internal/x/net/http2/hpack
13-
stdout $GOROOT[/\\]src[/\\]internal[/\\]x[/\\]net[/\\]http2[/\\]hpack
12+
stdout ^vendor/golang.org/x/net/http2/hpack
13+
stdout $GOROOT[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack
1414
! stdout $GOPATH[/\\]src[/\\]vendor
1515

1616
# In the presence of $GOPATH/src/vendor/golang.org/x/net/http2/hpack,

src/cmd/go/testdata/script/list_std.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stdout cmd/compile
1616

1717
# In GOPATH mode, packages vendored into GOROOT should be reported as standard.
1818
go list -f '{{if .Standard}}{{.ImportPath}}{{end}}' std cmd
19-
stdout internal/x/net/http2/hpack
19+
stdout golang.org/x/net/http2/hpack
2020
stdout cmd/vendor/golang\.org/x/arch/x86/x86asm
2121

2222
# However, vendored packages should not match wildcard patterns beginning with cmd.

src/cmd/go/testdata/script/mod_list_std.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env GOPROXY=off
55

66
# Outside of GOROOT, our vendored packages should be reported as part of the standard library.
77
go list -f '{{if .Standard}}{{.ImportPath}}{{end}}' std cmd
8-
stdout ^internal/x/net/http2/hpack
8+
stdout ^vendor/golang.org/x/net/http2/hpack
99
stdout ^cmd/vendor/golang\.org/x/arch/x86/x86asm
1010

1111
# cmd/... should match the same packages it used to match in GOPATH mode.
@@ -20,15 +20,15 @@ stdout ^cmd/compile
2020
# Today, they are listed in 'std' but not './...'.
2121
cd $GOROOT/src
2222
go list ./...
23-
stdout ^internal/x
23+
! stdout ^vendor/golang.org/x # TODO: should be included, or should be omitted from 'std'.
2424

2525
cp stdout $WORK/listdot.txt
2626
go list std
27-
stdout ^internal/x
27+
stdout ^vendor/golang.org/x # TODO: remove vendor/ prefix
2828
# TODO: cmp stdout $WORK/listdot.txt
2929

3030
go list all
31-
stdout ^internal/x
31+
stdout ^vendor/golang.org/x # TODO: remove vendor/ prefix.
3232
! stdout ^std/
3333

3434

@@ -37,11 +37,11 @@ stdout ^internal/x
3737
# TODO(golang.org/issue/30241): Make that work.
3838
# Today, they still have the vendor/ prefix.
3939
go list std
40-
stdout ^internal/x/net/http2/hpack # TODO
40+
stdout ^vendor/golang.org/x/net/http2/hpack # TODO
4141
! stdout ^golang.org/x/net/http2/hpack # TODO
4242

4343
go list -deps -f '{{if not .Standard}}{{.ImportPath}}{{end}}' std
44-
# ! stdout ^internal/x/net/http2/hpack # TODO
44+
# ! stdout ^vendor/golang.org/x/net/http2/hpack # TODO
4545
! stdout ^golang.org/x/net/http2/hpack # TODO
4646

4747

src/cmd/go/testdata/script/mod_std_vendor.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
env GO111MODULE=on
22
env GOPROXY=off
33

4+
[!gc] skip
5+
6+
# 'go list' should report imports from _test.go in the TestImports field.
47
go list -f '{{.TestImports}}'
58
stdout net/http # from .TestImports
69

710
# 'go list' should find standard-vendored packages.
8-
go list -f '{{.Dir}}' internal/x/net/http2/hpack
9-
stdout $GOROOT[/\\]src[/\\]internal
11+
go list -f '{{.Dir}}' vendor/golang.org/x/net/http2/hpack
12+
stdout $GOROOT[/\\]src[/\\]vendor
1013

1114
# 'go list -test' should report vendored transitive dependencies of _test.go
1215
# imports in the Deps field.
1316
go list -test -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}'
14-
stdout internal/x/crypto # dep of .TestImports
17+
stdout ^vendor/golang.org/x/crypto # dep of .TestImports
1518

1619

1720
# Modules outside the standard library should not use the packages vendored there...
@@ -29,7 +32,7 @@ stderr 'use of vendored package'
2932

3033
cd ../importstd
3134
! go build .
32-
stderr 'use of internal package'
35+
stderr 'use of vendored package'
3336

3437

3538
# When run within the 'std' module, 'go list -test' should report vendored
@@ -38,8 +41,8 @@ stderr 'use of internal package'
3841
# Today, they're standard packages as long as they exist.
3942
cd $GOROOT/src
4043
go list -test -f '{{range .Deps}}{{.}}{{"\n"}}{{end}}' net/http
41-
! stdout ^vendor/golang.org/x/net/http2/hpack # TODO: this will exist later
42-
stdout ^internal/x/net/http2/hpack
44+
stdout ^vendor/golang.org/x/net/http2/hpack # TODO: remove vendor/ prefix
45+
! stdout ^golang.org/x/net/http2/hpack
4346

4447
-- go.mod --
4548
module m
@@ -74,4 +77,4 @@ module importvendor
7477
-- importstd/x.go --
7578
package importstd
7679

77-
import _ "internal/x/net/http2/hpack"
80+
import _ "vendor/golang.org/x/net/http2/hpack"

src/cmd/go/testdata/script/std_vendor.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ go list -f '{{.TestImports}}'
77
stdout net/http # from .TestImports
88

99
# 'go list' should report standard-vendored packages by path.
10-
go list -f '{{.Dir}}' internal/x/net/http2/hpack
11-
stdout $GOROOT[/\\]src[/\\]internal
10+
go list -f '{{.Dir}}' vendor/golang.org/x/net/http2/hpack
11+
stdout $GOROOT[/\\]src[/\\]vendor
1212

1313
# 'go list -test' should report vendored transitive dependencies of _test.go
1414
# imports in the Deps field, with a 'vendor' prefix on their import paths.
1515
go list -test -f '{{.Deps}}'
16-
stdout internal/x/crypto # dep of .TestImports
16+
stdout golang.org/x/crypto # dep of .TestImports
1717

1818
# Packages outside the standard library should not use its copy of vendored packages.
1919
cd broken

src/cmd/vet/all/whitelist/s390x.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ internal/cpu/cpu_s390x.s: [s390x] kmctrQuery: invalid MOVD of ret+0(FP); interna
1010
internal/cpu/cpu_s390x.s: [s390x] kmaQuery: invalid MOVD of ret+0(FP); internal/cpu.queryResult is 16-byte value
1111
internal/cpu/cpu_s390x.s: [s390x] kimdQuery: invalid MOVD of ret+0(FP); internal/cpu.queryResult is 16-byte value
1212
internal/cpu/cpu_s390x.s: [s390x] klmdQuery: invalid MOVD of ret+0(FP); internal/cpu.queryResult is 16-byte value
13+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] stfle: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.facilityList is 32-byte value
14+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] kmQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value
15+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] kmcQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value
16+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] kmctrQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value
17+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] kmaQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value
18+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] kimdQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value
19+
vendor/golang.org/x/sys/cpu/cpu_s390x.s: [s390x] klmdQuery: invalid MOVD of ret+0(FP); vendor/golang.org/x/sys/cpu.queryResult is 16-byte value

src/crypto/tls/cipher_suites.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"crypto/sha1"
1515
"crypto/sha256"
1616
"crypto/x509"
17+
"golang.org/x/crypto/chacha20poly1305"
1718
"hash"
18-
"internal/x/crypto/chacha20poly1305"
1919
)
2020

2121
// a keyAgreement implements the client and server side of a TLS key agreement

src/crypto/tls/handshake_messages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package tls
66

77
import (
88
"fmt"
9-
"internal/x/crypto/cryptobyte"
9+
"golang.org/x/crypto/cryptobyte"
1010
"strings"
1111
)
1212

0 commit comments

Comments
 (0)