aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/build.go
AgeCommit message (Collapse)Author
2023-01-24all: fix some commentscui fliter
Change-Id: I3e9f05d221990b1ae464545d6d8b2e22c35bca21 Reviewed-on: https://go-review.googlesource.com/c/go/+/463077 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20cmd/dist: mark linux/sparc64 as a broken port, remove incomplete mapDmitri Shuralyov
The linux/sparc64 port is incomplete—it doesn't work, and it doesn't have a builder. Now that dist supports broken ports, mark it as such. The incomplete map was created to hide ports that aren't functional from dist list output. Now that we have the broken port concept, it seems largely redundant, so remove it for now. For #56679. Updates #28944. Change-Id: I34bd23e913ed6d786a4d0aa8d2852f2b926fe4b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/458516 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-01-20cmd/dist: add map of broken ports and -force flagDmitri Shuralyov
It's empty so far. The next CL adds linux/sparc64. Also add -force flag to the bootstrap.bash script so that it's possible to use it with broken ports. For #56679. Change-Id: I09c733d0df0a68df34fb808eae29be010a6da461 Reviewed-on: https://go-review.googlesource.com/c/go/+/458515 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17cmd/dist: make toolchain build reproducibleRuss Cox
- Build cmd with CGO_ENABLED=0. Doing so removes the C compiler toolchain from the reproducibility perimeter and also results in cmd/go and cmd/pprof binaries that are statically linked, so that they will run on a wider variety of systems. In particular the Linux versions will run on Alpine and NixOS without needing a simulation of libc.so.6. The potential downside of disabling cgo is that cmd/go and cmd/pprof use the pure Go network resolver instead of the host resolver on Unix systems. This means they will not be able to use non-DNS resolver mechanisms that may be specified in /etc/resolv.conf, such as mDNS. Neither program seems likely to need non-DNS names like those, however. macOS and Windows systems still use the host resolver, which they access without cgo. - Build cmd with -trimpath when building a release. Doing so removes $GOPATH from the file name prefixes stored in the binary, so that the build directory does not leak into the final artifacts. - When CC and CXX are empty, do not pick values to hard-code into the source tree and binaries. Instead, emit code that makes the right decision at runtime. In addition to reproducibility, this makes cross-compiled toolchains work better. A macOS toolchain cross-compiled on Linux will now correctly look for clang, instead of looking for gcc because it was built on Linux. - Convert \ to / in file names stored in .a files. These are converted to / in the final binaries, but the hashes of the .a files affect the final build ID of the binaries. Without this change, builds of a Windows toolchain on Windows and non-Windows machines produce identical binaries except for the input hash part of the build ID. - Due to the conversion of \ to / in .a files, convert back when reading inline bodies on Windows to preserve output file names in error messages. Combined, these four changes (along with Go 1.20's removal of installed pkg/**.a files and conversion of macOS net away from cgo) make the output of make.bash fully reproducible, even when cross-compiling: a released macOS toolchain built on Linux or Windows will contain exactly the same bits as a released macOS toolchain built on macOS. The word "released" in the previous sentence is important. For the build IDs in the binaries to work out the same on both systems, a VERSION file must exist to provide a consistent compiler build ID (instead of using a content hash of the binary). For #24904. Fixes #57007. Change-Id: I665e1ef4ff207d6ff469452347dca5bfc81050e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/454836 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-17time/tzdata: generate zip constant during cmd/distRuss Cox
We have a make.bash-time generation capability, so use it to generate the embedded zip file for time/tzdata. This is one less file to try to review in CLs like CL 455356. For #22487. Fixes #43350. Change-Id: I2fcd0665fa0b1c830baec5fb4cd714483fea25a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/455357 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-12-01cmd/dist: remove pkg/$GOOS_$GOARCH and pkg/obj at exitMichael Matloob
pkg/obj will be empty, so just remove it. pkg/$GOOS_$GOARCH will be empty unless the user has specified GODEBUG=installgoroot=all, so check if it's empty, and if so, delete it. Also remove xreaddirfiles, which is unused. Also remove the copy of pkg/$GOOS_$GOARCH in the cmd/go test TestNewReleaseRebuildsStalePackagesInGOPATH. The directory is empty so copying it has no effect. For #47257 Change-Id: Ief90b882d157bd16078cd5d2b83a915bfc831f9a Reviewed-on: https://go-review.googlesource.com/c/go/+/453496 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-21cmd/dist: stop trying to access runtime/internal/sys.a in debug modeCherry Mui
Now that we don't install the .a files, the installed runtime/internal/sys.a no longer exists. Stop trying to access it. Change-Id: Ic437e7ad95be6109d0b2fcfb81e840f5cb476be8 Reviewed-on: https://go-review.googlesource.com/c/go/+/451360 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-11-21cmd/dist: update to assume Go 1.17.13 as minimal Go bootstrap versionMartin Möhrmann
Replace explicit Go version names where possible with generic reference to Go bootstrap version. Updates #44505 Change-Id: I4a6439576efd40e72acd26fcc1472a1a8b0b06e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/344330 Auto-Submit: Martin Möhrmann <martin@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Martin Möhrmann <moehrmann@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-10cmd/dist: define GOPPC64_{cpu} for PPC64 targetsPaul E. Murphy
This can be used to provide better instruction selection for assembly implementations without having to implement two variants and dynamic runtime selections when a newer GOPPC64 value is used. Change-Id: I4331037d57b128137280aa7904d08d362391f81e Reviewed-on: https://go-review.googlesource.com/c/go/+/449115 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-11-01cmd/dist: fix a variable scope bug:Michael Matloob
We reused p so we were deleting the same directory twice instead of two different directories. Fix that. For #47257 Change-Id: I315ad87d0a9182e00ae4c11b82986227e2b02e17 Reviewed-on: https://go-review.googlesource.com/c/go/+/447115 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-10-27cmd/dist: produce intermedate .a files in a temporary locationMichael Matloob
Before this change, the .a files for the intermediate go toolchains were produced in the same location as the install target. This change has them produced in a temporary location instead. This change, combined with go install not producing .a files for most stdlib packages by default results in a build of the distribution only producing .a's for the five packages in std that require cgo. (Before this change, the .a's for the final build were not being produced, but stale ones from the intermediate builds were left behind.) For #47257 Change-Id: I91b826cd1ce9aad9c492fb865e36d34dc8bb188e Reviewed-on: https://go-review.googlesource.com/c/go/+/436135 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
2022-10-01cmd/go: remove the -i build flagDaniel Martí
The flag is now removed from `go build` and `go test`. It has been deprecated since Go 1.16, printing a warning message. The idea was to fully delete it in Go 1.17, but that didn't happen. First, delete the BuildI variable and its flag declarations, as well as all the bits of docs that mentioned the flag. Second, delete or simplify the code paths that used BuildI. Third, adapt the tests to the removed flag. Some of them are removed, like test_relative_import_dash_i.txt and TestGoTestDashIDashOWritesBinary, as they centered around the flag. The rest are modified to not cover or use the flag. Finally, change cmd/dist to no longer use `go install -i`. The purpose of the flag was that, when bootstrapping the toolchain, all of its dependencies would also be installed as object files. When removing the use of the -i flags, the checkNotStale call right after building toolchain3 would fail as expected, because runtime/internal/sys is now only up to date in the build cache. Luckily, that's not a problem: we run `go install std cmd` right after, so all standard library packages will be installed as object files. Move the checkNotStale call after that install command. Fixes #41696. Change-Id: I5d8139f18aaee07da886d483e663f3f2f00d5f3a Reviewed-on: https://go-review.googlesource.com/c/go/+/416094 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-01cmd/dist: add support for freebsd/riscv64Mikael Urankar
Updates #53466 Change-Id: I6643b4254dc707351d397018cee485bb508dde94 Reviewed-on: https://go-review.googlesource.com/c/go/+/431659 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-28cmd/dist: test cmd module on js/wasmTobias Klauser
Most tests will be skipped anyway because 'go build' is not available, but this ensures cmd will be build tested by TryBots for js/wasm. For #25911 For #35220 For #54219 Change-Id: I09c75905c36311810eb1ae75eeee2fa6102c1c0d Reviewed-on: https://go-review.googlesource.com/c/go/+/435237 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-20all: replace package ioutil with os and io in srcAndy Pan
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-30cmd/go/internal/imports: recognize "unix" build tagZeke Lu
For #20322 For #51572 Fixes #54712 Change-Id: I22fcfa820e83323bfdf1a40deee7286240f02b3e GitHub-Last-Rev: cd2c6536b0298baf3c54e5bdbc456a814545cff4 GitHub-Pull-Request: golang/go#54716 Reviewed-on: https://go-review.googlesource.com/c/go/+/426296 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-17all: use "noopt" build tag for checking optimization disabledCuong Manh Le
Fixes #49390 Change-Id: Ie5a5e097635c9fdcf4509455007283009a7d3021 Reviewed-on: https://go-review.googlesource.com/c/go/+/423256 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-26cmd/dist: support spaces and quotes in CCMotiejus Jakštys
As of CL 334732 `go build` can accept `$CC` with spaces and quotes, which lets us easily use `zig cc` as the C compiler, or easily pass extra compiler parameters: ``` CC="zig cc" go build <...> CC="clang-13 -v" go build <...> CC="zig cc -Wl,--print-gc-sections" go build <...> ``` However, the same does not apply for building go itself: ``` $ CC="zig cc" ./make.bash Building Go cmd/dist using /usr/local/go. (go1.18.2 linux/amd64) go tool dist: cannot invoke C compiler "zig cc": exec: "zig cc": executable file not found in $PATH Go needs a system C compiler for use with cgo. To set a C compiler, set CC=the-compiler. To disable cgo, set CGO_ENABLED=0. ``` With this change Go can be built directly with `zig cc` (the linker arg will disappear with CL 405414): ``` $ CC="zig cc -Wl,--no-gc-sections" ./make.bash Building Go cmd/dist using /usr/local/go. (go1.18.2 linux/amd64) Building Go toolchain1 using /usr/local/go. Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1. Building Go toolchain2 using go_bootstrap and Go toolchain1. Building Go toolchain3 using go_bootstrap and Go toolchain2. Building packages and commands for linux/amd64. --- Installed Go for linux/amd64 in /home/motiejus/code/go Installed commands in /home/motiejus/code/go/bin $ ../bin/go version go version devel go1.19-811f1913a8 Thu May 19 09:44:49 2022 +0300 linux/amd64 ``` Fixes #52990 Change-Id: I66b3525d47db488d3c583c1aee3af78060fd5a38 GitHub-Last-Rev: ecc70d722406f0c7d0c1930c872db392e80e7cf5 GitHub-Pull-Request: golang/go#52991 Reviewed-on: https://go-review.googlesource.com/c/go/+/407216 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20cmd/dist: port to linux/loong64 completedXiaodong Liu
For #46229 Change-Id: I5c207482d0a2cfb3a66f7e293cf413a5b54daa26 Reviewed-on: https://go-review.googlesource.com/c/go/+/397074 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-02os/exec: return error when PATH lookup would use current directoryRuss Cox
CL 381374 was reverted because x/sys/execabs broke. This CL reapplies CL 381374, but adding a lookPathErr error field back, for execabs to manipulate with reflect. That field will just be a bit of scar tissue in this package forever, to keep old code working with new toolchains. CL 403256 fixes x/sys/execabs's test to be ready for the change. Older versions of x/sys/execabs will keep working (that is, will keep rejecting what they should reject), but they will return a slightly different error from LookPath without that CL, and the test fails because of the different error text. For #43724. This reverts commit f2b674756b3b684118e4245627d4ed8c07e518e7. Change-Id: Iee55f8cd9939e1bd31e5cbdada50681cdc505117 Reviewed-on: https://go-review.googlesource.com/c/go/+/403274 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-01cmd/dist: support dist tool for loong64Xiaodong Liu
Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I61dca43680d8e5bd3198a38577450a53f405a987 Reviewed-on: https://go-review.googlesource.com/c/go/+/342307 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-29Revert "os/exec: return error when PATH lookup would use current directory"Bryan Mills
This reverts CL 381374. Reason for revert: broke tests for x/sys/execabs. Updates #43724. Updates #43947. Change-Id: I9eb3adb5728dead66dbd20f6afe1e7a77e2a26f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/403058 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-04-29os/exec: return error when PATH lookup would use current directoryRuss Cox
Following discussion on #43724, change os/exec to take the approach of golang.org/x/sys/execabs, refusing to respect path entries mentioning relative paths by default. Code that insists on being able to find executables in relative directories in the path will need to add a couple lines to override the error. See the updated package docs in exec.go for more details. Fixes #43724. Fixes #43947. Change-Id: I73c1214f322b60b4167a23e956e933d50470fe13 Reviewed-on: https://go-review.googlesource.com/c/go/+/381374 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05cmd/dist: move more environment logic into cmd/dist from make and run scriptsBryan C. Mills
'go tool dist env' outputs different (and fewer) environment variables than 'go env'. The 'go tool dist env' variables should be authoritative, whereas many printed by 'go env' are merely informational (and not intended to be overridden in the actual environment). Fixes #52009 Change-Id: Ic0590153875183135cebf7ca55ead7c2b4038569 Reviewed-on: https://go-review.googlesource.com/c/go/+/398061 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-31runtime: remove AVX2less code in memclrNoHeapPointers for GOAMD64 >= 3vpachkov
Optimize memclr by removing simple case loop along with the runtime check since AVX2 is guaranteed to be available when compiling with GOAMD64 >= 3 name old speed new speed delta Memclr/5-12 2.70GB/s ± 1% 2.73GB/s ± 1% ~ (p=0.056 n=5+5) Memclr/16-12 7.00GB/s ± 2% 7.03GB/s ± 1% ~ (p=1.000 n=5+5) Memclr/64-12 25.5GB/s ± 1% 25.5GB/s ± 1% ~ (p=0.548 n=5+5) Memclr/256-12 53.4GB/s ± 1% 52.7GB/s ± 2% ~ (p=0.222 n=5+5) Memclr/4096-12 109GB/s ± 1% 129GB/s ± 0% +18.57% (p=0.008 n=5+5) Memclr/65536-12 75.2GB/s ± 2% 78.3GB/s ± 3% +4.14% (p=0.008 n=5+5) Memclr/1M-12 53.5GB/s ± 2% 54.1GB/s ± 2% ~ (p=0.310 n=5+5) Memclr/4M-12 53.1GB/s ± 3% 52.9GB/s ± 2% ~ (p=1.000 n=5+5) Memclr/8M-12 44.6GB/s ± 3% 45.1GB/s ± 3% ~ (p=0.310 n=5+5) Memclr/16M-12 24.8GB/s ± 2% 24.2GB/s ± 2% ~ (p=0.056 n=5+5) Memclr/64M-12 38.3GB/s ± 1% 37.8GB/s ± 1% ~ (p=0.056 n=5+5) [Geo mean] 31.0GB/s 31.5GB/s +1.78% Change-Id: I6f3014f6338cb3b5a1b94503faa205f043fe2de8 Reviewed-on: https://go-review.googlesource.com/c/go/+/367494 Trust: Cherry Mui <cherryyz@google.com> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2022-03-30cmd/dist: delete special case for release branches without VERSIONDmitri Shuralyov
findgoversion has some logic from before the go1 release that only has effect when on a release branch without a VERSION file. Starting with release-branch.go1 and the go1 tag a decade ago, release branch have always had a VERSION file checked in. (The commit that adds/updates the VERSION file is what is tagged.) Since we have no need to support old branches like release-branch.r60, and such scenarios don't come up in modern Go, delete it to simplify this code a bit. Should the VERSION file situation change, we'd need to rework this code anyway. Fixes #42345. Change-Id: I13f27babd37aaa5cec30fefde1b8e6ccce816461 Reviewed-on: https://go-review.googlesource.com/c/go/+/393954 Trust: Daniel Martí <mvdan@mvdan.cc> Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-28go/build: recognize "unix" build tagIan Lance Taylor
The new "unix" build tag matches any Unix or Unix-like system. This is only recognized on go:build lines, not in file names. For #20322 Fixes #51572 Change-Id: I3a991f9e69353b25e259bc6462709cdcd83640fb Reviewed-on: https://go-review.googlesource.com/c/go/+/389934 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-18cmd/go: stamp build settings for binaries in cmdBryan C. Mills
Also update cmd/dist to avoid setting gcflags and ldflags explicitly when the set of flags to be set is empty (a verbose way of specifying the default behavior). Stamping was disabled for the Go standard library in CL 356014 due to the cmd/dist flags causing cmd/go to (correctly) report the resulting binaries as stale. With cmd/dist fixed, we can also remove the special case in cmd/go, which will allow tests of binaries in 'cmd' to read the build info embedded in the test binary. That build info may be useful to determine (say) whether runtime.GOROOT ought to work without GOROOT set in the environment. For #51483 Updates #37475 Change-Id: I64d04f5990190094eb6c0522db829d3bdfa50ef3 Reviewed-on: https://go-review.googlesource.com/c/go/+/391809 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-10-28cmd/dist: implement //go:build parsingRuss Cox
The bootstrap directories are built with the Go 1.4 go command, and they will retain the // +build lines until we bump the bootstrap toolchain to Go 1.17 or later. cmd/dist builds cmd/go and all its dependencies, using the assembler, compiler, and linker that were built using Go 1.4. We don't want to have to keep // +build lines in cmd/go and all its dependencies, so this CL changes cmd/dist to understand the //go:build lines. cmd/dist is a standalone Go program that must itself build with very old Go releases, so we cannot assume go/build/constraint is available. Instead, implement a trivial parser/evaluator. For #41184. Change-Id: I84e259dec3bd3daec3f82024eb3500120f53096d Reviewed-on: https://go-review.googlesource.com/c/go/+/359314 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-05Revert "cmd/dist: omit cmd/cgo from toolchain1"Matthew Dempsky
This reverts commit 81b7ec1ad5b50b8e73a63b44d8c2538154def535. Reason for revert: broke ios builder Change-Id: I7f469161c3c632ae48b7d938d355c9929eaaad92 Reviewed-on: https://go-review.googlesource.com/c/go/+/354135 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-05cmd/dist: omit cmd/cgo from toolchain1Matthew Dempsky
We don't need cmd/cgo for building go_bootstrap or toolchain2, so skip building it as part of toolchain1. This allows cmd/cgo to assume a current go/ast; e.g., that ast.IndexListExpr exists (needed for next CL). Change-Id: I642bba780bf273e6ea9c6e7c5d5d7ccfe86bf462 Reviewed-on: https://go-review.googlesource.com/c/go/+/353884 Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-16cmd/go: add GOAMD64 environment variablenimelehin
The variable represents the microarchitecture level for which to compile. Valid values are v1 (default), v2, v3, v4. Updates #45453 Change-Id: I095197fc9239d79f98896d7e745e2341354daca4 GitHub-Last-Rev: f83ed17204606264073be5b9831f9d24f2f9dbc4 GitHub-Pull-Request: golang/go#48359 Reviewed-on: https://go-review.googlesource.com/c/go/+/349595 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Bryan C. Mills <bcmills@google.com>
2021-08-19cmd/dist: remove unused variablesManlio Perillo
Remove the unused defaultcflags and defaultldflags variables. Reported by staticcheck. Change-Id: Icc42f2e670496dbe2ffb26abe25128d8e53e2a6d Reviewed-on: https://go-review.googlesource.com/c/go/+/321931 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-08-11src/make.*: make --no-clean flag a no-op that prints a warningMatthew Dempsky
This flag is undocumented and is no longer useful. Users who want to install additional toolchains without cleaning the installed packages should just use `go install`. This CL changes cmd/dist to print a warning that --no-clean is deprecated and to advise users to use `go install std cmd` instead, and then otherwise ignores it: ``` $ ./make.bash --no-clean Building Go cmd/dist using $GOROOT_BOOTSTRAP. (devel +b7a85e0003 linux/amd64) warning: --no-clean is deprecated and has no effect; use 'go install std cmd' instead Building Go toolchain1 using $GOROOT_BOOTSTRAP. ``` Fixes #47204. Change-Id: I275031832098401a49e491e324e8de3427973630 Reviewed-on: https://go-review.googlesource.com/c/go/+/341392 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-21cmd/dist: display first class port status in json outputConstantin Konstantinidis
Fixes #38874 Change-Id: I819dd008fd6869d335888b4aa03dcf739da9a9a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/320069 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc>
2021-04-28cmd/dist,runtime: support cgo on openbsd/mips64Joel Sing
Add support for cgo on openbsd/mips64. Fixes #43005 Change-Id: I2386204f53fa984a01a9d89f0b6c96455768f326 Reviewed-on: https://go-review.googlesource.com/c/go/+/275896 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-26syscall, etc.: use abi.FuncPCABI0 for libc syscall wrappersCherry Zhang
In CL 288092 we made Darwin syscall wrappers as ABIInternal, so their addresses taken from Go using funcPC are the actual function entries, not the wrappers. As we introduced internal/abi.FuncPCABIxxx intrinsics, use that. And change the assembly functions back to ABI0. Do it on OpenBSD as well, as OpenBSD and Darwin share code generator. Change-Id: I408120795f7fc826637c867394248f8f373906bd Reviewed-on: https://go-review.googlesource.com/c/go/+/313230 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-23cmd/dist: enable cgo on windows/arm64Russ Cox
Change-Id: I4d470e2af1bfb4fba004a6f3e00a163a575593da Reviewed-on: https://go-review.googlesource.com/c/go/+/312047 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-15internal/bytealg: port more performance-critical functions to ABIInternalAustin Clements
CL 308931 ported several runtime assembly functions to ABIInternal so that compiler-generated ABIInternal calls don't go through ABI wrappers, but it missed the runtime assembly functions that are actually defined in internal/bytealg. This eliminates the cost of wrappers for the BleveQuery and GopherLuaKNucleotide benchmarks, but there's still more to do for Tile38. 0-base 1-wrappers sec/op sec/op vs base BleveQuery 6.507 ± 0% 6.477 ± 0% -0.46% (p=0.004 n=20) GopherLuaKNucleotide 30.39 ± 1% 30.34 ± 0% ~ (p=0.301 n=20) Tile38IntersectsCircle100kmRequest 1.038m ± 1% 1.080m ± 2% +4.03% (p=0.000 n=20) For #40724. Change-Id: I0b722443f684fcb997b1d70802c5ed4b8d8f9829 Reviewed-on: https://go-review.googlesource.com/c/go/+/310184 Trust: Austin Clements <austin@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-08cmd/go: strip GOEXPERIMENT from hash saltAustin Clements
The go command salts cache hashes using runtime.Version() (the Go version the go command was built with) in order to separate objects built with different versions of Go. CL 307820 added the active GOEXPERIMENTs to the result of runtime.Version, which affected cmd/go's hash salt. Since dist builds go_bootstrap with all GOEXPERIMENTs disabled, but then go_bootstrap builds the final go binary with the GOEXPERIMENTs passed to make.bash, if any GOEXPERIMENTs were passed, go_bootstrap and the final go binary produce different cache hashes. At the very end of dist, it uses the final go binary to check the hashes of all packages, but these hashes were produced by go_bootstrap, so it concludes everything is stale. This should fix the builders that enable GOEXPERIMENTs, including the regabi and staticlockranking builders. Change-Id: Ie389929dff6f7b6eff2b19a2f43507e72be5f32e Reviewed-on: https://go-review.googlesource.com/c/go/+/308591 Trust: Austin Clements <austin@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-04-03cmd/dist: include "go1.x-" in devel go version stringsDaniel Martí
This way, "go version" will report the "base version" or major version that the tool corresponds to. This is the same version number that is matched against build tags such as "go1.14" or "!go1.16". Obtaining this version being built is non-trivial, since we can't just import a package or query git. The added comments document the chosen mechanism, based on a regular expression. It was chosen over AST parsing as it would add a significant amount of code without much gain, given how simple the goversion.go file is. For #41116. Change-Id: I653ae935e27c13267f23898f89c84020dcd6e194 Reviewed-on: https://go-review.googlesource.com/c/go/+/264938 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc> Trust: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-03-18cmd/dist: build bootstrap without GOEXPERIMENTAustin Clements
Currently, dist attempts to build the bootstrap with the GOEXPERIMENT set in the environment. However, the logic is incomplete and notably requires a hack to enable the appropriate build tags for GOEXPERIMENT=regabi. Without this hack, the build becomes skewed between a compiler that uses regabi and a runtime that doesn't when building toolchain2. We could try to improve the GOEXPERIMENT processing in cmd/dist, but it will always chase cmd/internal/objabi and it's quite difficult to share the logic with objabi because of the constraints on building cmd/dist. Instead, we switch to building go_bootstrap without any GOEXPERIMENT and only start using GOEXPERIMENT once we have a working, modern cmd/go (which has all the GOEXPERIMENT logic in it). We also build toolchain1 without any GOEXPERIMENT set, in case the bootstrap toolchain is recent enough to understand build-time GOEXPERIMENT settings. As part of this, we make GOEXPERIMENT=none mean "no experiments". This is necessary since, now that we support setting GOEXPERIMENT at build time, we need an explicit way to say "ignore all baked-in experiments". For #40724. Change-Id: I115399579b766a7a8b2f352f7e5efea5305666cd Reviewed-on: https://go-review.googlesource.com/c/go/+/302050 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-11cmd: move GOEXPERIMENT knob from make.bash to cmd/goMatthew Dempsky
This CL changes GOEXPERIMENT to act like other GO[CONFIG] environment variables. Namely, that it can be set at make.bash time to provide a default value used by the toolchain, but then can be manually set when running either cmd/go or the individual tools (compiler, assembler, linker). For example, it's now possible to test rsc.io/tmp/fieldtrack by simply running: GOEXPERIMENT=fieldtrack go test -gcflags=-l rsc.io/tmp/fieldtrack \ -ldflags=-k=rsc.io/tmp/fieldtrack.tracked without needing to re-run make.bash. (-gcflags=-l is needed because the compiler's inlining abilities have improved, so calling a function with a for loop is no longer sufficient to suppress inlining.) Fixes #42681. Change-Id: I2cf8995d5d0d05f6785a2ee1d3b54b2cfb3331ca Reviewed-on: https://go-review.googlesource.com/c/go/+/300991 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-03-02dist: generate stub go.mod in workdirTamir Duberstein
...and run commands from there. This removes the requirement that bootstrap must not run inside a module by ensuring that enclosing modules do not interfere with bootstrap. Fixes #44209. Change-Id: I700a81829226770b8160c8ff04127b855b6e26bf Reviewed-on: https://go-review.googlesource.com/c/go/+/296610 Trust: Jay Conrod <jayconrod@google.com> Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-23cmd/dist: match goexperiment.regabi tag when GOEXPERIMENT is onCherry Zhang
Change-Id: I5e4347dde6dcb49cd96608e4f67e54c7b3050bc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/293851 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-02-19cmd/dist: add windows/arm64 supportRuss Cox
- Add Windows SystemInfo constant for arm64 - Add windows/arm64 to GOOS/GOARCH list This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. Change-Id: I6109bd87512b5cb1d227d7a85fd0ac20eb2259e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/288819 Trust: Russ Cox <rsc@golang.org> Trust: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-03[dev.regabi] runtime, syscall, etc.: mark Darwin syscall wrappers as ABIInternalCherry Zhang
Mark the syscall wrappers as ABIInternal, as they have addresses taken from Go code, and it is important to call to them without wrappers. Previously, the wrapper is just a single JMP instruction, which makes it not matter. In the next CL we'll make the wrapper actually have a frame. The real wrappers will mess up things such as stack alignment for C ABI. This doesn't look really nice, but I don't know how we can do better... TODO: other OSes. Change-Id: Ifb3920494990a7775e3e6902fbcaf137df3cc653 Reviewed-on: https://go-review.googlesource.com/c/go/+/288092 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-11-06cmd/dist: remove openbsd/mips64 from incomplete portsJoel Sing
Remove openbsd/mips64 from incomplete ports lists - all of the necessary code has landed and we want to run tests so we can see/deal with remaining failures. Update #40995 Change-Id: I5d4f89af82ff3abe57570a9a8abf889498093d32 Reviewed-on: https://go-review.googlesource.com/c/go/+/267606 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-11-03cmd/dist,cmd/go,runtime: add support for cgo on linux/riscv64Joel Sing
Fixes #36641 Change-Id: I51868d83ce341d78d33b221d184c5a5110c60d14 Reviewed-on: https://go-review.googlesource.com/c/go/+/263598 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>