aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/dwarf_test.go
AgeCommit message (Collapse)Author
2026-03-02all: test: remove unneeded loop variablesAriel Otilibili
This CL follows from the abandoned CL 722961. Alan Donovan asked if modernize would catch these changes; it does in part. Here is how modernize was used: 1. Build the Go compiler from latest master 2. Clone x/tools and build modernize with the newest compiler 3. Then, do: PATH=PATH_TO_BIN:$PATH go list ./... | xargs env PATH=PATH_TO_BIN:$PATH GOMOD=off MODERNIZE -forvar -fix -test -debug fpstv 4. For assurance, move into a package directory (i.e, cmd), and redo Step 3. From the obtained result, it seems modernize did not remove the loop variable when: - the range notation was not used - the loop variable was not directly under the for directive. Which does happens here: # git ls-files | xargs -I {} perl -nE 'print "$ARGV:$.:$_" if /\s+(\w+) := \1$/' {} | grep _test [...] cmd/compile/internal/types2/api_test.go:2423: i := i md/go/internal/modload/query_test.go:182: tt := tt md/go/internal/web/url_test.go:17: tc := tc cmd/go/internal/web/url_test.go:49: tc := tc cmd/internal/par/queue_test.go:54: i := i runtime/syscall_windows_test.go:781: arglen := arglen Link: https://go-review.googlesource.com/c/go/+/722961/comments/e8d47866_fc399fa1 Co-authored-by: Plamerdi Makela <plamerdi447@gmail.com> Fixes #76411 Change-Id: I0c191cdca70dbea6efaf6796dca9c60e2afcd9ea GitHub-Last-Rev: 77c3e11fc21a4ede70b733b567a1690edb944dc1 GitHub-Pull-Request: golang/go#77694 Reviewed-on: https://go-review.googlesource.com/c/go/+/746502 Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2026-02-25Revert "cmd/compile: add loclist for removed DCL nodes"Cherry Mui
This reverts CL 696575. Reason for revert: break many builders. E.g. https://ci.chromium.org/b/8688888321314872289 Change-Id: I453b50fd0b731a6b3d1870f43fd7ed5937965bc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/749020 Auto-Submit: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2026-02-24cmd/compile: add loclist for removed DCL nodesDerek Parker
Certain return parameters which live in registers and end up pruned by earlier SSA passes will end up with a DWARF entry but no location list. This patch fixes this by ensuring those params have proper location lists generated for them. Change-Id: I4fff074e62c3010abdee85934fb286510b21c707 Reviewed-on: https://go-review.googlesource.com/c/go/+/696575 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Derek Parker <parkerderek86@gmail.com>
2026-02-18cmd/link: don't pass -Wl,-S on illumosPeter Tribble
The change in CL 707096 to exclude GOOS=solaris needs to also be applied for GOOS=illumos, which shares the same linker lineage. Fixes #77530 Change-Id: Ifc2047595af2db52870f9fb0a9faf646666d9e61 Reviewed-on: https://go-review.googlesource.com/c/go/+/746560 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-12-08cmd/link: generate DWARF for moduledataIan Lance Taylor
Fixes #76731 Change-Id: I5c686c91af8543b57880a89d30393912ef1958ad Reviewed-on: https://go-review.googlesource.com/c/go/+/727760 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-26cmd/link: always run current linker in testsIan Lance Taylor
This ensures that the tests are testing the current linker sources, not the installed linker. Change-Id: I14a2ca9d413e1af57c7b5a00657c72023626a651 Reviewed-on: https://go-review.googlesource.com/c/go/+/721220 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-29cmd/link: don't pass -Wl,-S on SolarisCherry Mui
Solaris linker's -S has a different meaning. Fixes #75637. Change-Id: I51e641d5bc6d7f64ab5aa280090c70ec787a1fbf Reviewed-on: https://go-review.googlesource.com/c/go/+/707096 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-09-29cmd/link: skip TestFlagW on platforms without DWARF symbol tableRichard Miller
As with other DWARF tests, don't run TestFlagW on platforms where executables don't have a DWARF symbol table. Fixes #75585 Change-Id: I81014bf59b15e30ac1b2a7d24a52f9647db46c26 Reviewed-on: https://go-review.googlesource.com/c/go/+/706418 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-09-26cmd/link: skip TestFlagW on AIXCherry Mui
The internal/xcoff can only parse XCOFF with symbol table. This test creates executables without symbol table. Skip the test. (It might be possible to make internal/xcoff work with binaries without symbol table? Leave it for the future.) Fixes #75618. Change-Id: I273ffefee5376d987accd5aa48c9473d2b3df055 Reviewed-on: https://go-review.googlesource.com/c/go/+/707095 Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2025-09-25cmd/link: handle -w flag in external linking modeCherry Mui
Currently, when the -w flag is set, it doesn't actually disable the debug info generation with in external linking mode. (It does make the Go object have no debug info, but C objects may still have.) Pass "-Wl,-S" to let the external linker disable debug info generation. Change-Id: I0fce56b9f23a45546b69b9e6dd027c5527b1bc87 Reviewed-on: https://go-review.googlesource.com/c/go/+/705857 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2025-09-23cmd/link: make -w behavior consistent on WindowsCherry Mui
On UNIX-like platforms, the -w flag disables DWARF, and the -s flag implies -w (so it disables both the symbol table and DWARF). The implied -w can be negated with -w=0, i.e. -s -w=0 disables the symbol table but keeps the DWARF. Currently, this negation doesn't work on Windows. This CL makes it so, so it is consistent on all platforms (that support DWARF). Change-Id: I19764a15768433afe333b37061cea16f06cb901b Reviewed-on: https://go-review.googlesource.com/c/go/+/703998 Reviewed-by: Than McIntosh <thanm@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-07-23cmd/link: scope test to linux & net.sendFileDerek Parker
Limits the scope of new test added in 71c2bf551303930faa32886446910fa5bd0a701a. Discussion: https://go-review.googlesource.com/c/go/+/684377. Change-Id: I0e8f513eb564aae277ba8a80ebdad469eb1e6e6a GitHub-Last-Rev: add2b2e2096e5221ac3d54376c1afa1bec10482c GitHub-Pull-Request: golang/go#74720 Reviewed-on: https://go-review.googlesource.com/c/go/+/689916 Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: 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: Keith Randall <khr@google.com>
2025-07-22cmd/compile: fix loclist for heap return vars without optimizationsDerek Parker
When compiling without optimizations certain variables such as return params end up missing location lists. Fixes #65405 Change-Id: Id4ec6b1ab6681fd77b8fefb47a4ec05060c128ef GitHub-Last-Rev: 5ab6a5398162119dd0cd5325f4239b4559b030bd GitHub-Pull-Request: golang/go#74398 Reviewed-on: https://go-review.googlesource.com/c/go/+/684377 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2024-10-28cmd/link, go/internal/gccgoimporter: get ar from env by default in testschangwang ma
Change-Id: Ib64b1f641fcf795a51aaf31639d37927dab519e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/622237 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-29cmd/link: add script testing facility for linker useThan McIntosh
Add support for running script tests as part of the linker's suite of tests, hooking in the script test engine packages recently moved from cmd/go to cmd/internal. Linker script tests will use the test binary itself as the linker for Go builds, and can also run the C compiler if needed. New script test cases (*.txt files) should be added to the directory cmd/link/testdata/script. For demo purposes, this patch also adds a new "randlayout_option.txt" script test that replicates the existing linker's TestRandLayout testpoint in script form. Updates #68606. Change-Id: Icf26bf657850e39548d6ea819f2542fc68a3899b Reviewed-on: https://go-review.googlesource.com/c/go/+/601360 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2023-05-03cmd/compile,cmd/link: skip tests that require DWARF symbols on iosBryan C. Mills
The linker does not combine DWARF information into the binary on ios. This generalizes test skips that were already present for a similar reason on plan9. Fixes #59939. Change-Id: Ideda07c9f9a69fd102a7d9a83ea8e7b7c29d0da2 Reviewed-on: https://go-review.googlesource.com/c/go/+/491835 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2023-01-31cmd/link: skip c-archive tests if c-archive mode is not supportedIan Lance Taylor
Change-Id: If0e034d9ebf2baeb89cb52b22aedbe923cc703ff Reviewed-on: https://go-review.googlesource.com/c/go/+/463983 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-15cmd/link: use testenv.Command instead of exec.Command in testsBryan C. Mills
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: I25a67aa5793c6fa977ff6d4dc59ca1533bf58d41 Reviewed-on: https://go-review.googlesource.com/c/go/+/450702 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2021-10-27cmd: move internal/str back to cmd/goRuss Cox
cmd/go is not subject to all the same restrictions as most of cmd. In particular it need not be buildable with the bootstrap toolchain. So it is better to keep as little code shared between cmd/go and cmd/compile, cmd/link, cmd/cgo as possible. cmd/internal/str started as cmd/go/internal/str but was moved to cmd/internal in order to make use of the quoted string code. Move that code to cmd/internal/quoted and then move the rest of cmd/internal/str back to cmd/go/internal/str. Change-Id: I3a98f754d545cc3af7e9a32c2b77a5a035ea7b9a Reviewed-on: https://go-review.googlesource.com/c/go/+/355010 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-08-16cmd: support space and quotes in CC and CXXJay Conrod
The CC and CXX environment variables now support spaces and quotes (both double and single). This fixes two issues: first, if CC is a single path that contains spaces (like 'c:\Program Files\gcc\bin\gcc.exe'), that should now work if the space is quoted or escaped (#41400). Second, if CC or CXX has multiple arguments (like 'gcc -O2'), they are now split correctly, and the arguments are passed before other arguments when invoking the C compiler. Previously, strings.Fields was used to split arguments, and the arguments were placed later in the command line. (#43078). Fixes golang/go#41400 Fixes golang/go#43078 NOTE: This change also includes a fix (CL 341929) for a test that was broken by the original CL. Commit message for the fix is below. [dev.cmdgo] cmd/link: fix TestBuildForTvOS This test was broken in CL 334732 on darwin. The test invokes 'go build' with a CC containing the arguments -framework CoreFoundation. Previously, the go command split CC on whitespace, and inserted the arguments after the command line when running CC directly. Those arguments weren't passed to cgo though, so cgo ran CC without -framework CoreFoundation (or any of the other flags). In CL 334732, we pass CC through to cgo, and cgo splits arguments using str.SplitQuotedFields. So -framework CoreFoundation actually gets passed to the C compiler. It appears that -framework flags are only meant to be used in linking operations, so when cgo invokes clang with -E (run preprocessor only), clang emits an error that -framework is unused. This change fixes the test by moving -framework CoreFoundation out of CC and into CGO_LDFLAGS. Change-Id: I2d5d89ddb19c94adef65982a8137b01f037d5c11 Reviewed-on: https://go-review.googlesource.com/c/go/+/334732 Trust: Jay Conrod <jayconrod@google.com> Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/341936 Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-05-27cmd/go,cmd/link: do not check for staleness in most testsBryan C. Mills
Instead, check that stale packages in the standard library are not rebuilt when already present in the build cache, and are not installed implicitly when rebuilt. We retain the staleness checks for the runtime package in tests involving '-i', because those are guaranteed to fail anyway if the package is stale and the "stale" failure message is arguably clearer. They can be removed if/when we remove the '-i' flag, but the runtime package is less likely to become stale because it does not have cgo dependencies. Fixes #46347 Updates #33598 Updates #35459 Updates #41696 Change-Id: I7b0a808addd930f9f4911ff53ded62272af75a40 Reviewed-on: https://go-review.googlesource.com/c/go/+/322629 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-08cmd/link: use testing.T.TempDir in testsBrad Fitzpatrick
Change-Id: I6fc8c9ee6d2246bfd874eb58b411e34ddbeaf723 Reviewed-on: https://go-review.googlesource.com/c/go/+/299670 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-03-03cmd/link: disable flaky Darwin "symbols" testDavid Chase
About one run out of 3 it fails on my laptop, and I am tired of having to be a nanny for my tests just because of this one flaky test. This has been a problem for months. Updates #32218. Change-Id: I2871d4c6f47e9432d189ed7bdcda8f9c0871cfc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/297469 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-19cmd/link: fix TestDWARFiOSCherry Zhang
Use GOOS=ios. Run "xcodebuild -showsdks" correctly. Wrap testDWARF in subtests, as it calls t.Parallel, otherwise the two calls of testDWARF will cause t.Parallel being called twice, which panics. Updates #38485. Change-Id: I614c8daa99c83cbfd05a4cfa041968d49279f16a Reviewed-on: https://go-review.googlesource.com/c/go/+/263639 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-07-07[dev.link] cmd/link: run more tests in parallelCherry Zhang
Change-Id: I4062fd89f234b4ca5386b74584e1363c05e82e84 Reviewed-on: https://go-review.googlesource.com/c/go/+/241177 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-06-11[dev.link] all: merge branch 'master' into dev.linkCherry Zhang
Change-Id: I446db56b20ef2189e23e225a91a17736c1d11e4c
2020-06-09cmd/dist: do not unset GOROOT_FINAL prior to running testsBryan C. Mills
Also do not unset it by default in the tests for cmd/go. GOROOT_FINAL affects the GOROOT value embedded in binaries, such as 'cmd/cgo'. If its value changes and a build command is performed that depends on one of those binaries, the binary would be spuriously rebuilt. Instead, only unset it in the specific tests that make assumptions about the GOROOT paths embedded in specific compiled binaries. That may cause those tests to do a little extra rebuilding when GOROOT_FINAL is set, but that little bit of extra rebuilding seems preferable to spuriously-stale binaries. Fixes #39385 Change-Id: I7c87b1519bb5bcff64babf1505fd1033ffa4f4fb Reviewed-on: https://go-review.googlesource.com/c/go/+/236819 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-05-19[dev.link] cmd/link: skip TestDWARFiOS if the iOS tools aren't installedJeremy Faller
Change-Id: I5bccb5935cdeb3a0ccf398a57eb4776f0e6aedca Reviewed-on: https://go-review.googlesource.com/c/go/+/234578 Run-TryBot: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-06cmd/link: remove darwin/arm testCherry Zhang
The darwin/arm port is removed in Go 1.15. Setting GOOS=darwin GOARCH=arm will fail, therefore "go test cmd/link" on macOS will fail (in non -short mode). Remove this test point. Updates #37611. Change-Id: Ia9531c4b4a6692a0c49153517af9fdddd1f3e0bf Reviewed-on: https://go-review.googlesource.com/c/go/+/227341 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-06cmd/link: fix data race in testDWARFCherry Zhang
Multiple instances of testDWARF run in parallel, with a shared backing store of the env input slice. Do modification of the environment locally, instead of on the shared slice. Fixes #38265. Change-Id: I22a7194c8cd55ba22c9d6c47ac47bf7e710a7027 Reviewed-on: https://go-review.googlesource.com/c/go/+/227342 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-01-24cmd/link: ensure cgo cflags do not leak into dwarf testsCarlos Amedee
Running the dwarf tests with CGO_CFLAGS set with certain values would cause the test to fail. all.bash would fail when CGO_CFLAGS was set to '-mmacosx-version-min=10.10' because the --macosx-version-min flag is incompatible with some dwarf tests. The change guards against using an unintended flag in the unit test. Updates #35459 Change-Id: Idc9b354aba44fdab424cb0081a4b3ea7a6d0f8e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/216177 Run-TryBot: Carlos Amedee <carlos@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-11-13cmd/link: don't run TestDWARF in c-archive mode on WindowsThan McIntosh
Test fix: in dwarf_test.go don't try to run the TestDWARF testpoint on windows with c-archive build mode (linker + debug/pe support for that build mode on Windows is not fully baked it seems). Fixes #35512. Change-Id: I1c87ff3d62e5b98e75062b184d762fb5ed937745 Reviewed-on: https://go-review.googlesource.com/c/go/+/206899 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-11-11cmd/link: disable a DWARF testpoint on Windows pending investigationThan McIntosh
Disable a portion of the TestDWARF testpoint for Windows using c-archive buildmode, pending investigation of the issue at hand, so as to get the longtest builder unblocked. Updates #35512. Change-Id: Ib72d82ceaa674b9a51da220fb8e225231d5c3433 Reviewed-on: https://go-review.googlesource.com/c/go/+/206557 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-09-17debug/elf: apply more relocations when reading DWARF data sectionsThan McIntosh
The elf reader's method for reading in DWARF section data has support for applying selected relocations when the debug/dwarf readers are being used on relocatable objects. This patch extends the set of relocations applied slightly. In particlar, prior to this for some architectures we were only applying relocations whose target symbol was a section symbol; now we also include some relocations that target other symbols. This is needed to get meaningful values for compilation unit DIE low_pc attributes, which typically target a specific function symbol in text. Fixes #31363. Change-Id: I34b02e7904cd7f2dea74197f73fa648141d15212 Reviewed-on: https://go-review.googlesource.com/c/go/+/195679 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-30cmd/link/internal/ld: ensure mach-o debug symbols are visible to App StoreAman Gupta
Passing test that shows Apple's symbols utility can now read DWARF data in go.o, after the fix in CL174538 Updates #31022 #22716 #31459 Change-Id: I56c3517ad6d0a9f39537182f63cef56bb198aa83 Reviewed-on: https://go-review.googlesource.com/c/go/+/170451 Reviewed-by: Than McIntosh <thanm@google.com>
2019-05-30cmd/link/internal/ld: improve messages for testDWARF failuresAman Gupta
Change-Id: I60af7a6477d1b25c43b311246ae4a79bf691460e Reviewed-on: https://go-review.googlesource.com/c/go/+/171819 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-22all: shorten some testsRuss Cox
Shorten some of the longest tests that run during all.bash. Removes 7r 50u 21s from all.bash. After this change, all.bash is under 5 minutes again on my laptop. For #26473. Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79 Reviewed-on: https://go-review.googlesource.com/c/go/+/177559 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-11cmd/link/internal/ld: fix c-archive mach-o compatibilityAman Gupta
These workarounds predate proper DWARF support and are no longer necessary. Before this patch, running `/usr/bin/symbols go.o` using the object in the c-archive would fail, causing App Store rejections. Fixes #31022 #28997 Change-Id: I6a210b6369c13038777c6e21e874e81afcb50c2f Reviewed-on: https://go-review.googlesource.com/c/go/+/170377 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-21cmd/link: skip TestBuildFortvOS if the SDK is missingElias Naur
While we're here, move the test from dwarf_test.go to link_test.go; it doesn't have anything to do with DWARF. Should fix the macOS builders with only the Xcode command line tools installed. Change-Id: Iaaba1b589f4d778705f7b627f78c2b12388e2b3b Reviewed-on: https://go-review.googlesource.com/c/go/+/168462 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-03-21cmd/link/internal/ld: copy Mach-O platform version commands to go.oElias Naur
To build for watchOS and tvOS the Apple toolchain requires a Mach-O load command that matches the platform for all object files in a build. The go.o object file produced by the Go linker contains no such command. The loader commands are mutually exclusive so we need to pick the right one. Fortunately, cgo must be enabled for watchOS and tvOS to be useful, so we can copy the first loader command we find in the object files produced by the host compiler. Add a test that builds a small program for tvOS to test both this CL and the previous CL that added bitcode support. Updates #22395 Change-Id: I7a47d19be9d80f0459dc358c600cddd9f236c444 Reviewed-on: https://go-review.googlesource.com/c/go/+/168321 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-13cmd: disable DWARF with old ld on aix/ppc64Clément Chigot
DWARF relocations isn't working with some older ld, because of -Wl,-bnoobjreorder which is needed on Go. This commit checks ld's version and disable DWARF generation in cmd/link if it's too old. Some tests must therefore be skipped. Change-Id: I2e794c263eb0dfe0b42e7062fb80c26f086b44d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/164007 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-02cmd/link: reliably remove temporary directory in testDwarfIan Lance Taylor
We were using t.Parallel in a subtest, which meant that the main test would not wait for the subtest, so the main test would delete the temporary directory before the subtest used it. The subtest worked because "go build -o /tmp/x/y/p.exe p" creates /tmp/x/y as needed. Updates #30500 Change-Id: I5904ecac748d15ded4cb609f049fa548b8916a0e Reviewed-on: https://go-review.googlesource.com/c/164857 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-27cmd/link: do not close over the loop variable in testDWARFBryan C. Mills
Fixes #30429 Updates #16520 Updates #20733 Change-Id: Iae41f06c09aaaed500936f5496d90cefbe8293e4 Reviewed-on: https://go-review.googlesource.com/c/164119 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-02-26cmd/link: use SeekPC in testDWARFIan Lance Taylor
This makes the tests slightly faster, though the bulk of the time is still spent building the test programs. Also run some tests in parallel. Updates #26470 Change-Id: Ia5ec2b99831d69c426b43dbab80613aa03e705f5 Reviewed-on: https://go-review.googlesource.com/c/153258 Reviewed-by: Austin Clements <austin@google.com>
2018-09-27cmd/link: move DIE of global variables to their compile unitAlessandro Arzilli
The DIEs for global variables were all assigned to the first emitted compile unit in debug_info, regardless of what it was. Move them instead to their respective compile units. Change-Id: If794fa0ba4702f5b959c6e8c16119b16e7ecf6d8 Reviewed-on: https://go-review.googlesource.com/137235 Reviewed-by: Than McIntosh <thanm@google.com>
2018-05-04cmd/link/internal/ld: skip DWARF combining for iOS binariesElias Naur
The macOS and iOS external linker strips DWARF information from binaries because it assumes the information will go into separate DWARF information .dSYM files. To preserve the embedded debugging information, the Go linker re-combines the separate DWARF information into the unmapped __DWARF segment of the final executable. However, the iOS dyld linker does not allow unmapped segments, so use the presence of the LC_VERSION_MIN_IPHONEOS linker command to skip DWARF combining. Note that we can't use GOARCH for detection since the iOS emulator runs on GOARCH=386 and GOARCH=amd64 and we will run into https://golang.org/issues/25148. Updates #25148. Change-Id: I29a1bc468fdee74ab3b27c46931501a0a8120c66 Reviewed-on: https://go-review.googlesource.com/111275 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-04-26cmd/link, cmd/go: enable DWARF on darwin/arm and darwin/arm64Cherry Zhang
Fixes #24883. Change-Id: Iff992ec3f2f31f4d82923d7cc806df4ee58e70b0 Reviewed-on: https://go-review.googlesource.com/108295 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-01-09cmd/link: set runtime.GOROOT default during linkRuss Cox
Suppose you build the Go toolchain in directory A, move the whole thing to directory B, and then use it from B to build a new program hello.exe, and then run hello.exe, and hello.exe crashes with a stack trace into the standard library. Long ago, you'd have seen hello.exe print file names in the A directory tree, even though the files had moved to the B directory tree. About two years ago we changed the compiler to write down these files with the name "$GOROOT" (that literal string) instead of A, so that the final link from B could replace "$GOROOT" with B, so that hello.exe's crash would show the correct source file paths in the stack trace. (golang.org/cl/18200) Now suppose that you do the same thing but hello.exe doesn't crash: it prints fmt.Println(runtime.GOROOT()). And you run hello.exe after clearing $GOROOT from the environment. Long ago, you'd have seen hello.exe print A instead of B. Before this CL, you'd still see hello.exe print A instead of B. This case is the one instance where a moved toolchain still divulges its origin. Not anymore. After this CL, hello.exe will print B, because the linker sets runtime/internal/sys.DefaultGoroot with the effective GOROOT from link time. This makes the default result of runtime.GOROOT once again match the file names recorded in the binary, after two years of divergence. With that cleared up, we can reintroduce GOROOT into the link action ID and also reenable TestExecutableGOROOT/RelocatedExe. When $GOROOT_FINAL is set during link, it is used in preference to $GOROOT, as always, but it was easier to explain the behavior above without introducing that complication. Fixes #22155. Fixes #20284. Fixes #22475. Change-Id: Ifdaeb77fd4678fdb337cf59ee25b2cd873ec1016 Reviewed-on: https://go-review.googlesource.com/86835 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-03-30cmd/link: skip TestDWARF when cgo is disabledJosh Bleecher Snyder
While we're here, fix a Skip/Skipf error I noticed. Fixes #19796. Change-Id: I59b1f5b5ea727fc314acfee8445b3de0b5af1e46 Reviewed-on: https://go-review.googlesource.com/38992 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-30cmd/link: skip TestDWARF on Plan 9David du Colombier
TestDWARF has been added in CL 38855. This test is failing on Plan 9 because executables don't have a DWARF symbol table. Fixes #19793. Change-Id: I7fc547a7c877b58cc4ff6b4eb5b14852e8b4668b Reviewed-on: https://go-review.googlesource.com/38931 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>