aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/build.go
AgeCommit message (Collapse)Author
23 hoursall: prealloc slice with possible minimum capabilitiesShulhan
2026-03-27all: remove openbsd/mips64 portTobias Klauser
The openbsd/mips64 port is dead, remove the remaining code specific to that port and clean up build tags. Fixes #61546 Change-Id: I0328b7b76ce1ddacd3a526b3f4ae29eaa1254c3f Reviewed-on: https://go-review.googlesource.com/c/go/+/746480 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2026-03-25cmd/dist: try to use jj commit info for devel versionmatloob
Fixes #78369 Change-Id: Icb8bb9822eac78934efc313f50221de56a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/759320 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-11-26doc/next: document broken freebsd/riscv64 portDmitri Shuralyov
Also update comment in cmd/dist's broken map to point to the top-level umbrella issue. For #76475. For #75005. Change-Id: I43b8384af4264dc5d72ceea8d05730b9db81123a Reviewed-on: https://go-review.googlesource.com/c/go/+/724860 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2025-10-27cmd/link: internal linking support for windows/arm64qmuntal
The internal linker was missing some pieces to support windows/arm64. Closes #75485 Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64 Change-Id: I5c18a47e63e09b8ae22c9b24832249b54f544b7e Reviewed-on: https://go-review.googlesource.com/c/go/+/704295 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-10-10cmd/go: unify "go fix" and "go vet"Alan Donovan
This change unifies the fix and vet subcommands; they use the same run function, action graph, and external tool (-vettool for go vet and -fixtool for go fix). go fix runs the tool with the -fix flag, whereas although go vet also supports -fix, it is not the default. The two tools have different (overlapping) suites of analyzers. The high-level parts are fully parameterized over the vet/fix distinction; the lower-level parts (the action graph) continue to use only the "vet" terminology. The cmd/{vet,fix} executable is referred to as the "tool". The tool is generally invoked in -json mode, regardless of whether -json was requested, so that the tool produces a cacheable JSON blob on stdout. When the go user did not request -json, this blob is parsed and printed to stderr by logic in the go vet command. (Formerly the tool would print diagnostics to stderr, but this interacts poorly with the build cache.) go fix's legacy -fix=fixer,... flag is now a no-op that prints a warning that the flag is obsolete. The unitchecker's -c=n flag (to display n lines of context around each diagnostic) is reimplemented in go vet based on the JSON information, to avoid reliance on the stderr output of the tool. cmd/fix is added to dist's prebuilt set of tools since go fix cannot build it dynamically (though ideally it would). Updates #71859 For #75432 Change-Id: I0a84746720b59d05d662ed57826747c5598dca44 Reviewed-on: https://go-review.googlesource.com/c/go/+/700795 Reviewed-by: Michael Matloob <matloob@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Bypass: Alan Donovan <adonovan@google.com>
2025-09-15all: replace strings.Split with strings.SplitSeq1911860538
In Go 1.25+, strings.SplitSeq offers better performance. Here are the benchmark results comparing strings.Split and strings.SplitSeq in a for-loop, with the benchmark code located in src/strings/iter_test.go: goos: darwin goarch: amd64 pkg: cmd/go/internal/auth cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ParseGitAuth/standard-8 281.4n ± 1% 218.0n ± 11% -22.54% (p=0.000 n=10) ParseGitAuth/with_url-8 549.1n ± 1% 480.5n ± 13% -12.48% (p=0.002 n=10) ParseGitAuth/minimal-8 235.4n ± 1% 197.3n ± 7% -16.20% (p=0.000 n=10) ParseGitAuth/complex-8 797.6n ± 2% 805.2n ± 4% ~ (p=0.481 n=10) ParseGitAuth/empty-8 87.48n ± 3% 63.25n ± 6% -27.71% (p=0.000 n=10) ParseGitAuth/malformed-8 228.8n ± 1% 171.2n ± 3% -25.17% (p=0.000 n=10) geomean 288.9n 237.7n -17.72% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ ParseGitAuth/standard-8 192.00 ± 0% 96.00 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/with_url-8 400.0 ± 0% 288.0 ± 0% -28.00% (p=0.000 n=10) ParseGitAuth/minimal-8 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.000 n=10) ParseGitAuth/complex-8 528.0 ± 0% 400.0 ± 0% -24.24% (p=0.000 n=10) ParseGitAuth/empty-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/malformed-8 176.00 ± 0% 80.00 ± 0% -54.55% (p=0.000 n=10) geomean 179.0 102.1 -42.96% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ ParseGitAuth/standard-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) ParseGitAuth/with_url-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10) ParseGitAuth/minimal-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) ParseGitAuth/complex-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10) ParseGitAuth/empty-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/malformed-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) geomean 3.086 2.040 -33.91% Updates #69315. Change-Id: Id0219edea45d9658d527b863162ebe917e7821d9 GitHub-Last-Rev: 392b315e122f2c9ef8703ca2dbce8f82ec198556 GitHub-Pull-Request: golang/go#75259 Reviewed-on: https://go-review.googlesource.com/c/go/+/701015 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2025-08-06all: remove support for windows/armqiulaidongfeng
Also CL 690655 for golang.org/x/sys. For #71671 Change-Id: Iceb369dec5affb944a39d07cdabfd7add6f1f319 Reviewed-on: https://go-review.googlesource.com/c/go/+/648795 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-08-05cmd/dist, internal/platform: mark freebsd/riscv64 brokenMark Freeman
It seems we have a builder, but it is not running correctly. Until then, we should mark this port broken. For #74734 For #74735 Change-Id: I536d037a43499cbd033fb6ebdf004a3df76332ab Reviewed-on: https://go-review.googlesource.com/c/go/+/691835 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-10cmd/dist: only install necessary tools when doing local testMichael Matloob
Instead of installing all of cmd, install only the tools that cmd/dist would normally install. Also, remove the addition of the buildid tool to the list of commands in the toolchain in debug mode. The uses of buildid were removed in CL 451360. For #71867 Change-Id: I062909d23c18294aa23ea43b9f7eeb69bfa80c8c Reviewed-on: https://go-review.googlesource.com/c/go/+/680475 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Matloob <matloob@google.com>
2025-06-03cmd/dist: don't install tools that won't be shipped in distributionMichael Matloob
We shouldn't be installing these tools because we will remove them in distpack. Installing the tools will also prevent us from testing what happens when the tools are missing. The changes below this on the stack, CL 677775 (cmd/doc: build cmd/doc directly into the go command) and CL 677636 (cmd/go/internal/cfg: fix GOROOT setting when forcing host config) are needed for this change to pass tests. The doc change is being done so we preserve the properties in the tests that doc can be invoked without doing a build. It's not strictly necessary (we could just remove the tests) but it's nice to have. The GOROOT setting is a significant bug in switching the configuration to host mode: the value of GOROOT wasn't being reset, which caused issues for go commands built with trimpath, because runtime.GOROOT wouldn't have the correct goroot value. For #71867 Change-Id: I4181711ba117066b7d62d7d013ad4b186871cfb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/677558 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2025-05-20cmd/dist, internal/platform: enable internal linking feature and test on loong64limeidan
Change-Id: Ifea676e9eb44281465832fc4050f6286e50f4543 Reviewed-on: https://go-review.googlesource.com/c/go/+/533717 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
2025-05-08cmd/go: fix incorrect determining default value of CGO_ENABLEDqiulaidongfeng
The default value is the value obtained when no environment variables are set and go env -w is not used. In the past, we used the current value (may be modified by an environment variable to a non-default value), error was used as the default value. For #69994 Change-Id: Iead3a6cacd04dc51a094ffb9f7bb7553320fcd78 Reviewed-on: https://go-review.googlesource.com/c/go/+/621995 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-04-30cmd/dist: move "devel" substring in git-inferred development versionDmitri Shuralyov
Keep the property that the "devel" substring is always present in these development versions of Go, but also gain the property that it's viable to use functions in the go/version package such as Lang, Compare, and get the expected results without needing to trim the "devel " prefix. For #73369. For #41116. Fixes #73372. Change-Id: Ieea4692e8c6cf0135e010f49f85300f6b038d6b1 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/668015 Reviewed-by: Funda Secgin <fundasecgin30@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-25cmd/dist: add "devel" substring check to isRelease computationDmitri Shuralyov
Non-release versions that are built from source without a VERSION file specifying any particular version end up with a development version like "devel go1.25-67e0681aef Thu Apr 24 12:17:27 2025 -0700". Right now those versions are correctly determined to be non-release because they don't have a "go" prefix, instead they have a "devel " prefix. In preparation of being able to move the "devel" substring, add a check that said substring isn't present anywhere, since it is certain not to be included in any released Go version we publish at https://go.dev/dl/. For #73372. Change-Id: Ia3e0d03b5723d4034d6270c3a2224f8dfae380e9 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/667955 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-16all: use strings.ReplaceAll where applicableMarcel Meyer
``` find . \ -not -path './.git/*' \ -not -path './test/*' \ -not -path './src/cmd/vendor/*' \ -not -wholename './src/strings/example_test.go' \ -type f \ -exec \ sed -i -E 's/strings\.Replace\((.+), -1\)/strings\.ReplaceAll\(\1\)/g' {} \; ``` Change-Id: I59e2e91b3654c41a32f17dd91ec56f250198f0d6 GitHub-Last-Rev: 0868b1eccc945ca62a5ed0e56a4054994d4bd659 GitHub-Pull-Request: golang/go#73370 Reviewed-on: https://go-review.googlesource.com/c/go/+/665395 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
2025-02-14cmd/dist: use slices.Indexqiulaidongfeng
Change-Id: Ifcab176faa2ac55e60576cf6acd96a18d0e860ab Reviewed-on: https://go-review.googlesource.com/c/go/+/648859 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-19cmd/dist: add GOFIPS140 settingRuss Cox
GOFIPS140 will be used to control whether to build binaries that run in FIPS-140 mode by default, as well as which version of crypto/internal/fips is used during a given build. It is a target configuration variable analogous to GOOS, GOARCH, CGO_ENABLED, and the like, so the default value is recorded in the toolchain during make.bash. This CL adds the GOFIPS140 setting to the build process and records the default for use by cmd/go. For #70200. Change-Id: Iafcb5a4207f00fae8bcd93e0184a63c72526abea Reviewed-on: https://go-review.googlesource.com/c/go/+/629196 Reviewed-by: Michael Matloob <matloob@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-02cmd/dist, internal/syslist: update UnixOS commentsIan Lance Taylor
Update the comments about the list of Unix systems after CL 601357, which moved one copy and eliminated another. Change-Id: I12f5b14a53ce6f8b3a41c9a10f947465c291e2b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/623035 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-09-11runtime: add asm_riscv64.hMark D Ryan
asm_riscv64.h will be used to define macros for each riscv64 extension that is not part of the rva20u64 base profile but that the _riscv64.s assembly files are allowed to use because the user has specified a more capable profile in the GORISCV64 variable. This will allow us, for example, to test for the hasZba macro in those assembly files instead of the GORISCV64_rva22u64 macro before using a Zba instruction. This is important as it means that in the future when we add support for new profiles that support Zba, e.g., rva23u64, we only need to update asm_riscv64.h to indicate rva23u64 supports Zba. We will not need to update every assembly language file that already uses Zba instructions. Updates #61476 Change-Id: I83abfeb20d08a87ac8ea88f4d8a93437f0631353 Reviewed-on: https://go-review.googlesource.com/c/go/+/608255 Auto-Submit: Tim King <taking@google.com> Reviewed-by: Tim King <taking@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-22cmd/dist: set go version in bootstrap go.mod fileMichael Matloob
The commands to build the bootstrap toolchains and go commands are run from modules created by two bootstrap go.mod files: one is used when building toolchain1 and go_bootstrap, and the other is used for toolchain2 and toolchain3, and the final build. Currently the first has a go directive specifying go 1.20, and the second one does not have a go directive at all. This affects the default GODEBUG setting when building the final toolchain: the default GODEBUG value is based on the go version of the go.mod file, and when the go.mod file does not have a version it defaults to go1.16. We should set the go directive on the bootstrap used for the second half of the builds to use the current go verison from the std's go.mod file (which is the same as the version on cmd's go.mod file). The go.mod file used for the initial bootstrap should have a go directive with the minimum version of the toolchain required for bootstrapping. That version is the current version - 2 rounded down to an even number. For #64751 Fixes #68797 Change-Id: Ibdddf4bc36dc963291979d603c4f3fc55264f65b Reviewed-on: https://go-review.googlesource.com/c/go/+/604799 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-08-14cmd/dist, internal/platform: mark windows/arm (32-bit ARM) brokenDmitri Shuralyov
The port is reportedly broken, and there isn't a builder testing it. For #68552. For #67308. Change-Id: Iababa17cdf855b675aaf85642a667e8081ef5dfe Reviewed-on: https://go-review.googlesource.com/c/go/+/601777 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-07-23runtime,internal: move runtime/internal/sys to internal/runtime/sysDavid Chase
Cleanup and friction reduction For #65355. Change-Id: Ia14c9dc584a529a35b97801dd3e95b9acc99a511 Reviewed-on: https://go-review.googlesource.com/c/go/+/600436 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-05-20cmd/dist: set GOPROXY=off when GOPATH is set to be in GOROOTMichael Matloob
Avoid downloading modules into a modcache in the GOROOT directory. That creates read only files in GOROOT, which is undesirable. Fixes #67463 Change-Id: I6d10c605be5eba967648d823ee8fc915716b4b5b Reviewed-on: https://go-review.googlesource.com/c/go/+/586078 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-18cmd/go: preprocess PGO profilesMichael Pratt
Following the previous CL, now actually run the preprofile tool to create the preprocessed output. There is still no build cache integration, so the tool will run on every build even if nothing has changed. For #58102. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Change-Id: I0414377a956889f457e50898737fcaa8a698658d Reviewed-on: https://go-review.googlesource.com/c/go/+/569424 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-03-06cmd/dist,internal: add GOARM64 environment variableAndrey Bokhanko
Adds GOARM64 environment variable with accepted range of values "v8.{0-9}", "v9.{0-5}" and optional ",lse" and ",crypto" suffixes. Right now it doesn't affect anything, but can be used in the future to selectively target specific versions of different ARM64 hardware. For #60905 Change-Id: I6d530041b6931aa884e34f719f8ec41b1cb03ece Reviewed-on: https://go-review.googlesource.com/c/go/+/559555 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Shu-Chun Weng <scw@google.com> Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
2024-02-21cmd: remove support for GOROOT_FINALConstantin Konstantinidis
Fixes #62047 Change-Id: If7811c1eb9073fb09b7006076998f8b2e1810bfb Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/539975 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-02-16cmd/dist,cmd/go: define assembly macros, handle GOARM value with soft/hardfloatCherry Mui
CL 525637 added GOARM_x assembly macros based on GOARM value. But it did not define the macro in cmd/dist, so the macro is not set during bootstrapping. This CL defines them. With CL 514907, cfg.GOARM can also take a soft/hardfloat suffix, like "7,hardfloat". Handle that case. For #65601. Change-Id: I60ffe7e8b623ae693d91d6e8595067a6f76565b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/562995 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2024-01-25cmd/dist,internal/platform,runtime: add cgo support for openbsd/riscv64 portJoel Sing
Updates #55999 Change-Id: Ie9a030130713f3eaf789b91d9033be3335eb9d75 Reviewed-on: https://go-review.googlesource.com/c/go/+/518630 Reviewed-by: Carlos Amedee <carlos@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-01-25cmd/dist,internal/platform: enable openbsd/riscv64 portJoel Sing
Fixes #55999 Change-Id: If76b61b660db3fefe5f9ca97500782f2a650db25 Reviewed-on: https://go-review.googlesource.com/c/go/+/518629 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-01-24cmd/go: add GORISCV64 environment variableMark Ryan
The variable represents the RISC-V user-mode application profile for which to compile. Valid values are rva20u64 (the default) and rva22u64. Setting GORISCV64=rva20u64 defines the riscv64.rva20u64 build tag, sets the internal variable buildcfg.GORISCV64 to 20 and defines the macro GORISCV64_rva20u64 for use in assembly language code. Setting GORISCV64=rva22u64 defines the riscv64.rva20u64 and riscv64.rva22u64 build tags, sets the internal variable buildcfg.GORISCV64 to 22 and defines the macro GORISCV64_rva22u64 for use in assembly language code. This patch only provides a mechanism for the compiler and hand-coded assembly language functions to take advantage of the RISC-V extensions mandated by the application profiles. Further patches will be required to get the compiler/assembler and assembly language functions to actually generate and use these extensions. Fixes #61476 Change-Id: I9195ae6ee71703cd2112160e89157ab63b8391af Reviewed-on: https://go-review.googlesource.com/c/go/+/541135 Reviewed-by: M Zhuo <mengzhuo1203@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Wang Yaduo <wangyaduo@linux.alibaba.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: M Zhuo <mengzhuo1203@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-31cmd/dist,internal/platform: enable openbsd/ppc64 portJoel Sing
Updates #56001 Change-Id: I16440114ecf661e9fc17d304ab3b16bc97ef82f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/517935 Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2023-10-02cmd/dist,internal/platform: add openbsd/riscv64 portJoel Sing
Updates #55999 Change-Id: I3c07f776919e36e4c1fdc5346f7622e5901a2902 Reviewed-on: https://go-review.googlesource.com/c/go/+/518624 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Aaron Bieber <deftly@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Joel Sing <joel@sing.id.au>
2023-08-23cmd/internal/obj/riscv,cmd/link: add support for internal cgo linking on riscv64Joel Sing
Make it possible to internally link cgo on riscv64, which also adds support for SDYNIMPORT calls without external linking being required. This reduces the time of an ./all.bash run on a Sifive Hifive Unleashed by approximately 20% (~140 minutes down to ~110 minutes). Change-Id: I43f1348de31672718ae8676cc82f6fdc1dfee054 Reviewed-on: https://go-review.googlesource.com/c/go/+/431104 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Than McIntosh <thanm@google.com>
2023-08-23cmd/link: add support for openbsd/ppc64Joel Sing
Add linker support for the openbsd/ppc64 port. Updates #56001 Change-Id: I18bc19b4086599996aebfbe68f2e85e1200589ca Reviewed-on: https://go-review.googlesource.com/c/go/+/475619 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Eric Grosse <grosse@gmail.com>
2023-08-22cmd/compile,cmd/dist,cmd/go: compute -+ flag from package pathAustin Clements
As we did for the asm -compiling-runtime flag, this CL modifies the compiler to compute the -+ (compiling runtime) flag from the package path. Unlike for asm, some tests use -+ explicitly to opt in to runtime restrictions, so we leave the flag, but it's no longer passed by any build tools. This lets us eliminate cmd/go's list of "runtime packages" in favor of the unified objabi.LookupPkgSpecial. It also fixes an inconsistency with dist, which only passed -+ when compiling "runtime" itself. One consequence of this is that the compiler now ignores the -N flag when compiling runtime packages. Previously, cmd/go would strip -N when passing -+ and the compiler would fatal if it got both -N and -+, so the overall effect was that the compiler never saw -N when compiling a runtime package. Now we simply move that logic to disable -N down into the compiler. Change-Id: I4876047a1563210ed122a31b72d62798762cbcf5 Reviewed-on: https://go-review.googlesource.com/c/go/+/521699 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-08-22cmd/asm,cmd/dist,cmd/go: remove asm -compiling-runtime flagAustin Clements
Currently, dist and go pass a -compiling-runtime flag to asm if they're compiling a runtime package. However, now that we always pass the package path to asm, it can make that determination just as well as its callers can. This CL moves that check into asm and drops the flag. This in turn makes dist's copy of IsRuntimePackagePath unnecessary, so we delete it. Change-Id: I6ecf2d50b5b83965012af34dbe5f9a973ba0778b Reviewed-on: https://go-review.googlesource.com/c/go/+/521697 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-01cmd/dist: tolerate macOS writing .DS_Store to GOROOT/binDmitri Shuralyov
I was trying out gorebuild (a program that runs make.bash many times) on a macOS system. Unfortunately there were a few failed invocations on my first try, but not with a very good or interesting reason: go tool dist: unexpected new file in $GOROOT/bin: .DS_Store Tolerate it since it's not unexpected, and will not affect the build. Change-Id: I656536b896098c2ba934667196d4ce82e706c8da Reviewed-on: https://go-review.googlesource.com/c/go/+/513763 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-06-22internal/platform,cmd/dist: export the list of supported platformsBryan C. Mills
Also switch internal/platform to commit the generated code instead of regenerating it in cmd/dist. Nothing in the generated code depends on the target configuration, and committing the source file makes it more amenable to searching and indexing (particularly on https://cs.opensource.google/go/go). For #60939. Change-Id: I9133dfd5129b3c4d7457267589dfac5e7ecbef65 Reviewed-on: https://go-review.googlesource.com/c/go/+/505175 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2023-06-13cmd/dist: more robust cleanupRuss Cox
Identify generated files by name prefix (z*) and content (^// Code generated by go tool dist) instead of having a fixed list. This will be more robust against doing make.bash and then rewinding git and then doing make.bash again. Change-Id: If9b4d02f5ad65345623866176d96e9894a957dc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/501036 Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2023-06-12cmd/dist: do not use user build cache in versioned treesRuss Cox
There is no guarantee that the user build cache will have correct data if we are using a versioned build (with a VERSION file), because that overrides the use of tool build IDs for staleness. An earlier build might have run with a buggy compiler, and we don't want those files lying around. Change-Id: I831956911162ccbd0b4d943c305b3537918fe119 Reviewed-on: https://go-review.googlesource.com/c/go/+/502699 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2023-06-07cmd/dist: disable PGO for toolchain2 buildCherry Mui
Toolchain2 is only used for building toolchain3. We don't need to build it with PGO. And building with PGO causes packages to be built twice (one with PGO for the compiler, one without for other programs). Disable PGO for toolchain2. Also, I thought cmd/dist requires toolchain2 and toolchain3 compilers are identical binaries, so they need to be built in the same way. But it doesn't. Change-Id: Iaf49816da3dd06db79b48482c0e2435e09b512d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/501335 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-06-06cmd/dist: remove deptab and cleanlist in favor of gentabAustin Clements
dist's deptab is a list of changes to the automatically derived set of package dependencies. It's as old as dist itself, and the first version of deptab in CL 5620045 was quite complex. From the beginning, some of the entries in deptab have been for generated files that need to be added to the dependency set because they can't be discovered if they don't exist. gentab is also as old as dist itself, and lists the generated dependency files. The interaction between deptab and gentab is rather odd. gentab contains only base file names, not whole paths. To figure out what files to generate, dist takes a Cartesian product of deptab and gentab and calls the generator wherever the basename of a path in deptab matches an entry in gentab. This perhaps made sense at the time because some of the generated files appeared in more than one package in deptab. These days, deptab consists exclusively of generated files because dist can correctly derive all other dependencies, and all of the generated files have unique paths. This makes the Cartesian product approach needlessly complex (and so confusing!), and means that the only purpose served by deptab is to provide full paths for generated files. Furthermore, in the dist clean command, it also needed to expand the file names in gentab to complete paths, but it did so using a different list, cleanlist, and the same Cartesian product algorithm. This CL drops all of this complexity by putting full paths into gentab, which lets us delete deptab and cleanlist. Change-Id: Ie3993983734f6da3be453bb4c17a64e22dcf3e8f Reviewed-on: https://go-review.googlesource.com/c/go/+/501137 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2023-06-06cmd/dist: remove stale cleanup codeAustin Clements
dist clean has logic to delete command binaries from the cmd directories in cleanlist. However, these days the only binary it could possibly remove is "$GOROOT/src/cmd/cgo/cgo". This is clearly no longer necessary, so remove this stale code. When this logic was originally introduced in CL 5622058, it was driven by cleantab (not cleanlist), which contained all of the cmd directories, which were legion at the time because this was the era of the [568][acgl] toolchain. CL 9154 deleted cleantab, and did the same clean walk over the "cmd/" directories listed in buildorder. However, buildorder was a list of packages necessary to build cmd/go, so the only "cmd/" directory in buildorder at the time was "cmd/go". Hence, at that CL, dist started deleting only a "$GOROOT/src/cmd/go/go" binary. The modern cleanlist was introduced in CL 76021, as a list of packages containing "generated files and commands". The only "cmd/" directory in cleanlist the whole time has been "cmd/cgo" (and I'm honestly not sure why cmd/cgo is in there), so since that CL dist has only deleted "$GOROOT/src/cmd/cgo/cgo". Change-Id: I1915eb938d1a0e22ae6a64e7648a21894d3e6502 Reviewed-on: https://go-review.googlesource.com/c/go/+/501136 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2023-06-06cmd/dist: remove stale files from gentabAustin Clements
There are several files in gentab that have a nil generator, which means they used to be generated, but aren't any more, so dist should delete them if it encounters them. However, cleaning only look for these file names in the small number of directories listed in cleanlist, and none of these files were originally generated into any of the directories in cleanlist. Specifically, enam.c was generated into $GOROOT/src/cmd/[568]l starting with CL 5620045 until CL 35740044 and the anames[5689].c files were generated into $GOROOT/src/liblink starting with CL 35740044 and CL 120690043 until CL 6110. None of these directories even exist any more, and if these files did somehow exist, dist wouldn't delete them anyway. Hence, we can safely remove these files from gentab. Change-Id: Ifed322d64a7a81a76537fcd9fc7020c7aca48050 Reviewed-on: https://go-review.googlesource.com/c/go/+/501135 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
2023-05-01misc/android: rename to misc/go_android_exec, make go build workAustin Clements
This makes it reasonable to "go build" from this directory by changing the name of the directory to a more reasonable name for the binary and dropping the unnecessary "ignore" build tag. The resulting binary doesn't *quite* have the necessary name for a Go exec wrapper because that needs to have the form, go_android_$GOARCH_exec, but it's close. Change-Id: I036cb1af9c034462a952b176a794526fa3ffd1ab Reviewed-on: https://go-review.googlesource.com/c/go/+/490495 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-20cmd/dist: refactor generated cgo-support logicBryan C. Mills
During bootstrapping, cmd/dist writes a file indicating which GOOS/GOARCH combinations are valid, and which support cgo-enabled builds. That information previously went into the go/build package, but today it fits in more naturally in the internal/platform package (which already has a number of functions indicating feature support for GOOS/GOARCH combinations). Moreover, as of CL 450739 the cmd/go logic for determining whether to use cgo is somewhat more nuanced than the go/build logic: cmd/go checks for the presence of a C compiler, whereas go/build does not (mostly because it determines its configuration at package-init time, and checking $PATH for a C compiler is somewhat expensive). To simplify this situation, this change: - consolidates the “cgo supported” check in internal/platform (alongside many other platform-support checks) instead of making it a one-off in go/build, - and updates a couple of tests to use testenv.HasCGO instead of build.Default.CgoEnabled to decide whether to test a cgo-specific behavior. For #58884. For #59500. Change-Id: I0bb2502dba4545a3d98c9e915727382ce536a0f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/483695 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
2023-04-19make.{bash,bat}: check unmodified $PATH for $GOROOT/bin presenceDmitri Shuralyov
Previously, all.bash and all.bat restored the original $PATH before calling 'dist banner', so that it would do its job of checking whether the user still needs to add $GOROOT/bin to their $PATH. That worked for those scripts, but had no effect on make.bash nor make.bat. Instead of trying to extend that logic to more scripts, change the approach to provide dist an unmodified copy of $PATH via an internal to dist environment variable $DIST_UNMODIFIED_PATH. The make.bash and make.bat scripts happen to use dist env -p to modify $PATH, making it viable to add the internal variable there instead of in each script. It currently works by adding semicolon terminators to dist env output so that make.bash's 'eval $(dist env -p)' works as before but is able to export DIST_UNMODIFIED_PATH for following dist invocations to observe. Nothing needs to be done for Windows since its 'set ENV=val' format already has that effect. Plan 9 doesn't use the -p flag of dist env, and checks that GOROOT/bin is bound before /bin rather than looking at the $PATH env var like other OSes, so it may not have this bug. I don't have easy access to Plan 9 and haven't tried to confirm. Fixes #42563. Change-Id: I74691931167e974a930f7589d22a48bb6b931163 Reviewed-on: https://go-review.googlesource.com/c/go/+/485896 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-04-12cmd/dist: check for errors from filepath.Globwangjianwen
Change-Id: Ib5bcd3d1e9618d65b4d4b0895d0e40dbd76646c6 GitHub-Last-Rev: 174084ca6c67ff99a4b3628d213b2de198f74dd0 GitHub-Pull-Request: golang/go#59516 Reviewed-on: https://go-review.googlesource.com/c/go/+/483435 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-11cmd/dist: add -distpack flag to build distribution archivesRuss Cox
We want to enable others to reproduce the exact distribution archives we are serving on go.dev/dl. Today the code for building those archives lives in golang.org/x/build, which is fundamentally tied to running on the Go team build infrastructure and not easy for others to run. This CL adds a new flag -distpack to cmd/dist, usually invoked as make.bash -distpack, to build the distribution archives using code in the main repository that anyone can run. Starting in Go 1.21, the Go team build infrastructure will run this instead of its current custom code to build those archives. The current builds are not reproducible even given identical infrastructure, because the archives are stamped with the current time. It is helpful to have a timestamp in the archives indicating when the code is from, but that time needs to be reproducible. To ensure this, the new -distpack flag extends the VERSION file to include a time stamp, which it uses as the modification time for all files in the archive. The new -distpack flag is implemented by a separate program, cmd/distpack, instead of being in cmd/dist, so that it can be compiled by the toolchain being distributed and not the bootstrap toolchain. Otherwise details like the exact compression algorithms might vary from one bootstrap toolchain to another and produce non-reproducible builds. So there is a new 'go tool distpack', but it's omitted from the distributions themselves, just as 'go tool dist' is. make.bash already accepts any flags for cmd/dist, including -distpack. make.bat is less sophisticated and looks for each known flag, so this CL adds an update to look for -distpack. The CL also changes make.bat to accept the idiomatic Go -flagname in addition to the non-idiomatic (for Go) --flagname. Previously it insisted on the --flag form. I have confirmed that using make.bash -distpack produces the identical distribution archives for windows/amd64, linux/amd64, darwin/amd64, and darwin/arm64 whether it is run on windows/amd64, linux/amd64, or darwin/amd64 hosts. For #24904. Change-Id: Ie6d69365ee3d7294d05b4f96ffb9159b41918074 Reviewed-on: https://go-review.googlesource.com/c/go/+/470676 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Carlos Amedee <amedee@google.com>