aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/dwarf
AgeCommit message (Collapse)Author
2025-11-11std,cmd: go fix -any std cmdAlan Donovan
This change mechanically replaces all occurrences of interface{} by 'any' (where deemed safe by the 'any' modernizer) throughout std and cmd, minus their vendor trees. Since this fix is relatively numerous, it gets its own CL. Also, 'go generate go/types'. Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/719702 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com>
2025-03-13cmd/internal/dwarf: always use AT_ranges for scopes with DWARF 5Than McIntosh
This patch extends the change in CL 657175 to apply the same abbrev selection strategy to single-range lexical scopes that we're now using for inlined routine bodies, when DWARF 5 is in effect. Ranges are more compact and use fewer relocation than explicit hi/lo PC values, so we might as well always use them. Updates #26379. Change-Id: Ieeaddf50e82acc4866010e29af32bcd1fb3b4f02 Reviewed-on: https://go-review.googlesource.com/c/go/+/657177 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-12cmd/internal/dwarf: fix bug in inlined func DIE range DWARF 5 infoThan McIntosh
This patch changes the strategy we use in the compiler for handling range information for inlined subroutine bodies, fixing a bug in how this was handled for DWARF 5. The high and lo PC values being emitted for DW_TAG_inlined_subroutine DIEs were incorrect, pointing to the start of functions instead of the proper location. The fix in this patch is to move to unconditionally using DW_AT_ranges for inlined subroutines, even those with only a single range. Background: prior to this point, if a given inlined function body had a single contiguous range, we'd pick an abbrev entry for it with explicit DW_AT_low_pc and DW_AT_high_pc attributes. If the extent of the code for the inlined body was not contiguous (which can happen), we'd select an abbrev that used a DW_AT_ranges attribute instead. This strategy (preferring explicit hi/lo PC attrs for a single-range func) made sense for DWARF 4, since in DWARF 4 the representation used in the .debug_ranges section was especially heavyweight (lots of space, lots of relocations), so having explicit hi/lo PC attrs was less expensive. With DWARF 5 range info is written to the .debug_rnglists section, and the representation here is much more compact. Specifically, a single hi/lo range can be represented using a base address in addrx format (max of 4 bytes, but more likely 2 or 3) followed by start and endpoints of the range in ULEB128 format. This combination is more compact spacewise than the explicit hi/lo values, and has fewer relocations (0 as opposed to 2). Note: we should at some point consider applying this same strategy to lexical scopes, since we can probably reap some of the same benefits there as well. Updates #26379. Fixes #72821. Change-Id: Ifb65ecc6221601bad2ca3939f9b69964c1fafc7c Reviewed-on: https://go-review.googlesource.com/c/go/+/657175 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2025-03-04cmd/compile,cmd/link: move to DWARF5-style location listsThan McIntosh
This patch updates the compiler to generate DWARF5-style location lists (e.g. entries that feed into .debug_loclists) as opposed to DWARF4-style location lists (which wind up in .debug_loc). The DWARF5 format is much more compact, and can make indirect references to text addresses via the .debug_addr section for further space savings. Updates #26379. Change-Id: If2e6fce1136d9cba5125ea51a71419596d1d1691 Reviewed-on: https://go-review.googlesource.com/c/go/+/635836 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-04cmd/compile,cmd/link: move to DWARF5-style range listsThan McIntosh
This patch updates the compiler to generate DWARF5-style range lists (e.g. entries that feed into .debug_rnglists) as opposed to DWARF4-style range lists (which wind up in .debug_ranges). The DWARF5 format is much more compact, and can make indirect references to text address via the .debug_addr section for further space savings. Updates #26379. Change-Id: I273a6283484b7fe33d79d5412e31c5155b22a7c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/635345 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>
2025-02-22cmd: initial compiler+linker support for DWARF5 .debug_addrThan McIntosh
This patch rolls the main .debug_info DWARF section from version 4 to version 5, and also introduces machinery in the Go compiler and linker for taking advantage of the DWARF5 ".debug_addr" section for subprogram DIE "high" and "low" PC attributes. All functionality is gated by GOEXPERIMENT=dwarf5. For the compiler portion of this patch, we add a new DIE attribute form "DW_FORM_addrx", which accepts as an argument a function (text) symbol. The dwarf "putattr" function is enhanced to handle this format by invoking a new dwarf context method "AddIndirectTextRef". Under the hood, this method invokes the Lsym method WriteDwTxtAddrx, which emits a new objabi.R_DWTXTADDR_* relocation. The size of the relocation is dependent on the number of functions in the package; we pick a size that is just big enough for the largest func index. In the linker portion of this patch, we now switch over to writing out a version number of 5 (instead of 4) in the compile unit header (this is required if we want to use addrx attributes). In the parallel portion of DWARF gen, within each compilation unit we scan subprogram DIEs to look for R_DWTXTADDR_* relocations, and when we find such a reloc, we assign a slot in the .debug_addr section for the func targeted. After the parallel portion is complete, we then walk through all of the compilation units to assign a value to their DW_AT_addr_base attribute, which points to the portion of the single .debug_addr section containing the text addrs for that compilation unit. Note that once this patch is in, programs built with GOEXPERIMENT=dwarf5 will have broken/damaged DWARF info; in particular, since we've changed only the CU and subprogram DIEs and haven't incorported the other changes mandated by DWARF5 (ex: .debug_ranges => .debug_rnglists) a lot of the variable location info will be missing/incorrect. This will obviously change in subsequent patches. Note also that R_DWTXTADDR_* can't be used effectively for lexical scope DIE hi/lo PC attrs, since there isn't a viable way to encode "addrx + constant" in the attribute value (you would need a new entry for each attr endpoint in .debug_addr, which would defeat the point). Updates #26379. Change-Id: I2dfc45c9a8333e7b2a58f8e3b88fc8701fefd006 Reviewed-on: https://go-review.googlesource.com/c/go/+/635337 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-22cmd/link, cmd/internal/dwarf: add DWARF5 line table supportThan McIntosh
This patch rolls out the necessary changes to migrate the DWARF line table support in the compiler and linker to DWARF version 5, gated by the "dwarf5" GOEXPERIMENT. DWARF version 5 includes a number of changes to the line table, notably a revamped prolog section and a change in the indexing system used to refer to files and directories within the line table program. Specifically, prior to DWARF 4 a compilation's directory table was considered to have an implicit zero entry containing the compilation directory of the translation unit (package), and the file table was considered to have an implicit zero entry storing the "primary source file" (stored in the compilation unit DIE name). DWARF 5 does away with these implicity entries meaning that files and dirs are now effectively a 0-based index. Updates #26379. Change-Id: I9b4f1be5415aacec1ba57366d60bd48819c56ea5 Reviewed-on: https://go-review.googlesource.com/c/go/+/633879 Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> 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-02-22cmd/internal/dwarf: add DW_LNCT and DW_UT constant definitionsThan McIntosh
Add a set of constants for the DWARF version 5 line table content description values found in the V5 line table prolog, and for the new DWARF unit type encodings. Updates #26379. Change-Id: I8f4989ea6b6cbb303deda1a6a20ad243d73b46b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/633878 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2024-09-09all: remove unnecessary symbols and add missing symbolscuishuang
Change-Id: I535a7aaaf3f9e8a9c0e0c04f8f745ad7445a32f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/611678 Run-TryBot: shuang cui <imcusg@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> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-09-03cmd: replace many sort.Interface with slices.Sort and SortFuncZxilly
with slices there's no need to implement sort.Interface Change-Id: I59167e78881cb1df89a71e33d738d6aeca7adb71 GitHub-Last-Rev: 507ba84453f7305b6b2bf6317292111c00c93ffe GitHub-Pull-Request: golang/go#68724 Reviewed-on: https://go-review.googlesource.com/c/go/+/602895 Reviewed-by: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2024-07-30cmd/link: add variable_parameter attr to functype outparamsThan McIntosh
When generating DW_TAG_subroutine_type DIEs during linker DWARF type synthesis, ensure that in the list of children of the subroutine type DIE (correspondings to input/output params) the output params are marked with the DW_AT_variable_parameter attribute. In addition, fix up the generated types of the output params: prior to this patch for a given output parameter of type T, we would emit the DIE type as *T (presumably due to how parameter passing/returning worked prior to the register ABI); with this patch the emitted type will just be T, not *T. Fixes #59977. Change-Id: I5b5600be86473695663c75b85baeecad667b9245 Reviewed-on: https://go-review.googlesource.com/c/go/+/595715 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-03-06cmd/compile: mark DIEs of captured variablesAlessandro Arzilli
Adds a new custom attribute to the DIE of captured variables, containing the offset for the variable inside the closure struct. This can be used by debuggers to display the contents of a closure variable. Based on a sample program (delve) this increases the executable size by 0.06%. benchstat output: │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ Template 153.0m ± 6% 152.5m ± 14% ~ (p=0.684 n=10) Unicode 100.2m ± 15% 104.9m ± 7% ~ (p=0.247 n=10) GoTypes 943.6m ± 8% 986.2m ± 10% ~ (p=0.280 n=10) Compiler 97.79m ± 6% 101.63m ± 12% ~ (p=0.393 n=10) SSA 6.872 ± 37% 9.413 ± 106% ~ (p=0.190 n=10) Flate 128.0m ± 36% 125.0m ± 56% ~ (p=0.481 n=10) GoParser 214.9m ± 26% 201.4m ± 68% ~ (p=0.579 n=10) Reflect 452.6m ± 22% 412.2m ± 74% ~ (p=0.739 n=10) Tar 166.2m ± 27% 155.9m ± 73% ~ (p=0.393 n=10) XML 219.3m ± 24% 211.3m ± 76% ~ (p=0.739 n=10) LinkCompiler 523.2m ± 13% 513.5m ± 47% ~ (p=0.631 n=10) ExternalLinkCompiler 1.684 ± 2% 1.659 ± 25% ~ (p=0.218 n=10) LinkWithoutDebugCompiler 304.9m ± 12% 309.1m ± 7% ~ (p=0.631 n=10) StdCmd 70.76 ± 14% 68.66 ± 53% ~ (p=1.000 n=10) geomean 511.5m 515.4m +0.77% │ old.txt │ new.txt │ │ user-sec/op │ user-sec/op vs base │ Template 269.6m ± 13% 292.3m ± 17% ~ (p=0.393 n=10) Unicode 110.2m ± 8% 101.7m ± 18% ~ (p=0.247 n=10) GoTypes 2.181 ± 9% 2.356 ± 12% ~ (p=0.280 n=10) Compiler 119.1m ± 11% 121.9m ± 15% ~ (p=0.481 n=10) SSA 17.75 ± 52% 26.94 ± 123% ~ (p=0.190 n=10) Flate 256.2m ± 43% 226.8m ± 73% ~ (p=0.739 n=10) GoParser 427.0m ± 24% 422.3m ± 72% ~ (p=0.529 n=10) Reflect 990.5m ± 23% 905.5m ± 75% ~ (p=0.912 n=10) Tar 307.9m ± 27% 308.9m ± 64% ~ (p=0.393 n=10) XML 432.8m ± 24% 427.6m ± 89% ~ (p=0.796 n=10) LinkCompiler 796.9m ± 14% 800.4m ± 56% ~ (p=0.481 n=10) ExternalLinkCompiler 1.666 ± 4% 1.671 ± 28% ~ (p=0.971 n=10) LinkWithoutDebugCompiler 316.7m ± 12% 325.6m ± 8% ~ (p=0.579 n=10) geomean 579.5m 594.0m +2.51% │ old.txt │ new.txt │ │ text-bytes │ text-bytes vs base │ HelloSize 842.9Ki ± 0% 842.9Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 10.95Mi ± 0% 10.95Mi ± 0% ~ (p=1.000 n=10) ¹ geomean 3.003Mi 3.003Mi +0.00% ¹ all samples are equal │ old.txt │ new.txt │ │ data-bytes │ data-bytes vs base │ HelloSize 15.08Ki ± 0% 15.08Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 314.7Ki ± 0% 314.7Ki ± 0% ~ (p=1.000 n=10) ¹ geomean 68.88Ki 68.88Ki +0.00% ¹ all samples are equal │ old.txt │ new.txt │ │ bss-bytes │ bss-bytes vs base │ HelloSize 396.8Ki ± 0% 396.8Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 428.8Ki ± 0% 428.8Ki ± 0% ~ (p=1.000 n=10) ¹ geomean 412.5Ki 412.5Ki +0.00% ¹ all samples are equal │ old.txt │ new.txt │ │ exe-bytes │ exe-bytes vs base │ HelloSize 1.310Mi ± 0% 1.310Mi ± 0% +0.02% (p=0.000 n=10) CmdGoSize 16.37Mi ± 0% 16.38Mi ± 0% +0.01% (p=0.000 n=10) geomean 4.631Mi 4.632Mi +0.02% Change-Id: Ib416ee2d916ec61ad4a5c26bab09597595f57e04 Reviewed-on: https://go-review.googlesource.com/c/go/+/563816 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-02-26cmd/compile/internal/dwarfgen: refactor putvar and putAbstractVarAlessandro Arzilli
Currently, changing putvar or putAbstractVar involves: 1. changing the abbrevs array to add new abbrevs or modify existing ones 2. changing the DW_ABRV_XXX const block to add the new abbrevs, this const block must match the changes to the abbrevs array 3. change the code at the start of putvar and putAbstractVar that selects the abbrev to use 4. change the body of putvar/putAbstractVar to emit the right attributes in the right sequence Each change must agree with all other, this is error prone and if an mistake is made there is no compile time or runtime check detecting it. Erroneous code will simply produce unreadable debug sections. This commit adds a mechanism to automatically generate code for abbrev selection as well as the abbrev definitions based on static examination of the body of putvar and putAbstractVar. TestPutVarAbbrevGenerator is responsible for checking that the generated code is kept updated and will regenerated it by passing the '-generate' option to it. benchstat output: | old.txt | new.txt | | sec/op | sec/op vs base | Template 153.8m ± 6% 153.0m ± 6% ~ (p=0.853 n=10) Unicode 98.98m ± 19% 100.22m ± 15% ~ (p=0.796 n=10) GoTypes 1013.7m ± 13% 943.6m ± 8% ~ (p=0.353 n=10) Compiler 98.48m ± 10% 97.79m ± 6% ~ (p=0.353 n=10) SSA 8.921 ± 31% 6.872 ± 37% ~ (p=0.912 n=10) Flate 114.3m ± 21% 128.0m ± 36% ~ (p=0.436 n=10) GoParser 219.0m ± 27% 214.9m ± 26% ~ (p=0.631 n=10) Reflect 447.5m ± 20% 452.6m ± 22% ~ (p=0.684 n=10) Tar 166.9m ± 27% 166.2m ± 27% ~ (p=0.529 n=10) XML 218.6m ± 25% 219.3m ± 24% ~ (p=0.631 n=10) LinkCompiler 492.7m ± 12% 523.2m ± 13% ~ (p=0.315 n=10) ExternalLinkCompiler 1.684 ± 3% 1.684 ± 2% ~ (p=0.684 n=10) LinkWithoutDebugCompiler 296.0m ± 8% 304.9m ± 12% ~ (p=0.579 n=10) StdCmd 69.59 ± 15% 70.76 ± 14% ~ (p=0.436 n=10) geomean 516.0m 511.5m -0.87% | old.txt | new.txt | | user-sec/op | user-sec/op vs base | Template 281.5m ± 10% 269.6m ± 13% ~ (p=0.315 n=10) Unicode 107.3m ± 8% 110.2m ± 8% ~ (p=0.165 n=10) GoTypes 2.414 ± 16% 2.181 ± 9% ~ (p=0.315 n=10) Compiler 116.0m ± 16% 119.1m ± 11% ~ (p=0.971 n=10) SSA 25.47 ± 39% 17.75 ± 52% ~ (p=0.739 n=10) Flate 205.2m ± 25% 256.2m ± 43% ~ (p=0.393 n=10) GoParser 456.8m ± 28% 427.0m ± 24% ~ (p=0.912 n=10) Reflect 960.3m ± 22% 990.5m ± 23% ~ (p=0.280 n=10) Tar 299.8m ± 27% 307.9m ± 27% ~ (p=0.631 n=10) XML 425.0m ± 21% 432.8m ± 24% ~ (p=0.353 n=10) LinkCompiler 768.1m ± 11% 796.9m ± 14% ~ (p=0.631 n=10) ExternalLinkCompiler 1.713 ± 5% 1.666 ± 4% ~ (p=0.190 n=10) LinkWithoutDebugCompiler 313.0m ± 9% 316.7m ± 12% ~ (p=0.481 n=10) geomean 588.6m 579.5m -1.55% | old.txt | new.txt | | text-bytes | text-bytes vs base | HelloSize 842.9Ki ± 0% 842.9Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 10.95Mi ± 0% 10.95Mi ± 0% ~ (p=1.000 n=10) ¹ geomean 3.003Mi 3.003Mi +0.00% ¹ all samples are equal | old.txt | new.txt | | data-bytes | data-bytes vs base | HelloSize 15.08Ki ± 0% 15.08Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 314.7Ki ± 0% 314.7Ki ± 0% ~ (p=1.000 n=10) ¹ geomean 68.88Ki 68.88Ki +0.00% ¹ all samples are equal | old.txt | new.txt | | bss-bytes | bss-bytes vs base | HelloSize 396.8Ki ± 0% 396.8Ki ± 0% ~ (p=1.000 n=10) ¹ CmdGoSize 428.8Ki ± 0% 428.8Ki ± 0% ~ (p=1.000 n=10) ¹ geomean 412.5Ki 412.5Ki +0.00% ¹ all samples are equal | old.txt | new.txt | | exe-bytes | exe-bytes vs base | HelloSize 1.310Mi ± 0% 1.310Mi ± 0% -0.01% (p=0.000 n=10) CmdGoSize 16.37Mi ± 0% 16.37Mi ± 0% -0.00% (p=0.000 n=10) geomean 4.631Mi 4.631Mi -0.00% Change-Id: I7edf37b5a47fd9aceef931ddf2c701e66a7b38b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/563815 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-30cmd/link: add DW_AT_go_runtime_type to unsafe.Pointer and fix it forAlessandro Arzilli
uintptr Adds the DW_AT_go_runtime_type attribute to the debug_info entry for unsafe.Pointer (which is special) and fixes the debug_info entry of uintptr so that its DW_AT_go_runtime_type attribute has the proper class (it was accidentally using DW_CLS_ADDRESS instead of DW_CLS_GO_TYPEREF) Change-Id: I52e18593935fbda9bc425e849f4c7f50e9144ad4 Reviewed-on: https://go-review.googlesource.com/c/go/+/558275 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>
2023-09-01cmd/internal/dwarf: replace Sym.Length with Context.SizeMatthew Dempsky
Preparatory refactoring before next CL. Change-Id: I06fb4670b933fddff1a2a70f3cf1eb124cbd86ee Reviewed-on: https://go-review.googlesource.com/c/go/+/524899 Auto-Submit: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-01cmd/internal/obj: simplify filename handlingMatthew Dempsky
The old Go object file format used linker symbols like "gofile..foo" to record references to the filename "foo". But the current object file format has a dedicated section for file names, so we don't need these useless prefixes anymore. Also, change DWARF generation to pass around the src.Pos directly, rather than the old file symbols, which it just turned back into a file index before writing out anyway. Finally, directly record the FileIndex into src.PosBase, so that we can skip the map lookups. Change-Id: Ia4a5ebfa95da271f2522e45befdb9f137c16d373 Reviewed-on: https://go-review.googlesource.com/c/go/+/523378 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-29cmd/internal/{dwarf,obj}: stop substituting "" with pkgprefixMatthew Dempsky
cmd/asm and cmd/compile now always create symbols with the appropriate package prefixes, so cmd/internal/dwarf and cmd/internal/obj can stop worrying about qualifying names itself. Change-Id: I9aee5d759bf0d41a61722c777e7f66fce957e79e Reviewed-on: https://go-review.googlesource.com/c/go/+/523338 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29cmd: simplify some handling of package pathsMatthew Dempsky
We have obj.Link.Pkgpath, so we don't need to pass it redundantly in places where we already have an *obj.Link. Also, renaming the parser's "compilingRuntime" field to "allowABI", to match the "AllowAsmABI" name used by objabi.LookupPkgSpecial. Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's main entry point, by simply appending them to flags.D. Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/523297 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-30cmd/compile,cmd/link: set DW_AT_decl_line for function declarationsMichael Pratt
DW_AT_decl_line provides the line number of function declarations (the line containing the func keyword). This is the equivalent to CL 429638, but provided via DWARF. Note that the file of declarations (DW_AT_decl_file) is already provided for non-inlined functions. It is omitted for inlined functions because those DWARF subprograms may be generated outside of their source compilation unit, where referencing the file table is difficult. Fixes #57308. Change-Id: I3ad12e1f366c4465c2a588297988a5825ef7efec Reviewed-on: https://go-review.googlesource.com/c/go/+/458195 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-29cmd/internal/dwarf: remove redundant break statementcuiweixie
Change-Id: I20956187e925ef6ab35d23b23c40bbb0ee55ef4a Reviewed-on: https://go-review.googlesource.com/c/go/+/436702 Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-29cmd: fix a few function names on commentscui fliter
Change-Id: Ia0896bd1edf2558821244fecd1c297b599472f47 GitHub-Last-Rev: cfd1e1091a064cdc38469c02c6c013635d7d437b GitHub-Pull-Request: golang/go#55944 Reviewed-on: https://go-review.googlesource.com/c/go/+/436637 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-09all: use ":" for compiler generated symbolsCuong Manh Le
As it can't appear in user package paths. There is a hack for handling "go:buildid" and "type:*" on windows/386. Previously, windows/386 requires underscore prefix on external symbols, but that's only applied for SHOSTOBJ/SUNDEFEXT or cgo export symbols. "go.buildid" is STEXT, "type.*" is STYPE, thus they are not prefixed with underscore. In external linking mode, the external linker can't resolve them as external symbols. But we are lucky that they have "." in their name, so the external linker see them as Forwarder RVA exports. See: - https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/pe-dll.c;h=e7b82ba6ffadf74dc1b9ee71dc13d48336941e51;hb=HEAD#l972) This CL changes "." to ":" in symbols name, so theses symbols can not be found by external linker anymore. So a hacky way is adding the underscore prefix for these 2 symbols. I don't have enough knowledge to verify whether adding the underscore for all STEXT/STYPE symbols are fine, even if it could be, that would be done in future CL. Fixes #37762 Change-Id: I92eaaf24c0820926a36e0530fdb07b07af1fcc35 Reviewed-on: https://go-review.googlesource.com/c/go/+/317917 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-02all: use os/exec instead of internal/execabsRuss Cox
We added internal/execabs back in January 2021 in order to fix a security problem caused by os/exec's handling of the current directory. Now that os/exec has that code, internal/execabs is superfluous and can be deleted. This commit rewrites all the imports back to os/exec and deletes internal/execabs. For #43724. Change-Id: Ib9736baf978be2afd42a1225e2ab3fd5d33d19df Reviewed-on: https://go-review.googlesource.com/c/go/+/381375 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2021-09-15cmd/compile: emit DWARF info about dictionary entriesAlessandro Arzilli
When emitting the DIE of the instantiation of a generic function also emit one DW_TAG_typedef_type entry for each dictionary entry in use, referencing the shape type and having a custom attribute containing the index inside the dictionary. When emitting the DIE of variables that have an instantiated parametric type, instead of referencing the shape type directly go through the DW_TAG_typedef_type entry emitted for the dictionary entry describing the real type of the variable. Change-Id: Ia45d157ecd4c25e2b60300469e43bbb27a663582 Reviewed-on: https://go-review.googlesource.com/c/go/+/344929 Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Trust: Dan Scales <danscales@google.com> Trust: Jeremy Faller <jeremy@golang.org>
2021-09-15cmd/compile: mark wrapper functions with DW_AT_trampolineAlessandro Arzilli
Change DWARF generation to tag wrapper functions with the "DW_AT_trampoline attribute". The intent is that debuggers can pick up on this attr so as to skip through the wrapper to the eventual target. DWARF standard allows for a couple of different possible variants of the trampoline attr; this is the simplest variant (all it tells the debugger is that the function is a wrapper, doesn't include a reference to the wrapper routine). This implementation keys off the WRAPPER LSym attribute, which is set for method wrappers, ABI wrappers, and a selected set of runtime assembly routines (ex: "runtime.call32"). Change-Id: Ib53e1bc56c02b86ca3ac5e7da1a541ec262726cf Reviewed-on: https://go-review.googlesource.com/c/go/+/347352 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jeremy Faller <jeremy@golang.org>
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-07-01[dev.typeparams] cmd/internal/dwarf: remove putInlinedFunc's callersym paramMatthew Dempsky
This parameter is only used for debugging, and all of putInlinedFunc's callers were actually passing the callee symbol instead. Change-Id: I964825a514cc42a1b0bcbce4ef11a1a47084d882 Reviewed-on: https://go-review.googlesource.com/c/go/+/332370 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-16internal/buildcfg: move build configuration out of cmd/internal/objabiRuss Cox
The go/build package needs access to this configuration, so move it into a new package available to the standard library. Change-Id: I868a94148b52350c76116451f4ad9191246adcff Reviewed-on: https://go-review.googlesource.com/c/go/+/310731 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-03-23cmd/{compile,link}: relocate generation of DWARF for global varsThan McIntosh
Move DWARF generation for global variables from the linker to the compiler. This effectively parallelizes this part of DWARF generation, speeds up the linker minutely, and gives us a slightly more rational implementation (there was really no compelling reason to do DWARF gen for globals in the linker). Change-Id: I0c1c98d3a647258697e90eb91d1d8a9f6f7f376a Reviewed-on: https://go-review.googlesource.com/c/go/+/295011 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-23cmd/internal/dwarf: minor cleanupsThan McIntosh
Remove a stale comment, demote PutInlinedFunc from public to private, and remove an unused interface originally used for sorting vars. No change in functionality. Change-Id: I5ee1ad2b10b78b158e2223c6979bab830202db95 Reviewed-on: https://go-review.googlesource.com/c/go/+/295009 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-21all: introduce and use internal/execabsRoland Shoemaker
Introduces a wrapper around os/exec, internal/execabs, for use in all commands. This wrapper prevents exec.LookPath and exec.Command from running executables in the current directory. All imports of os/exec in non-test files in cmd/ are replaced with imports of internal/execabs. This issue was reported by RyotaK. Fixes CVE-2021-3115 Fixes #43783 Change-Id: I0423451a6e27ec1e1d6f3fe929ab1ef69145c08f Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955304 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Katie Hockman <katiehockman@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/284783 Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org>
2020-11-17cmd/compile: clean up buggy DWARF inlined info PC rangesThan McIntosh
Repair the code that generates PC ranges for DWARF inlined routine instances to insure that if II Y is a child of II X within the inline tree, X's ranges include the ranges from Y. This is similar to what we're already doing for DWARF scopes. Updates #33188. Change-Id: I9bb552777fcd1ae93dc01872707667ad092b1dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/248724 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Trust: Than McIntosh <thanm@google.com>
2020-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-05-04[dev.link] cmd: delete old object supportCherry Zhang
We are not going to merge to master until Go 1.16 cycle. The old object support can go now. Change-Id: I93e6f584974c7749d0a0c2e7a96def35134dc566 Reviewed-on: https://go-review.googlesource.com/c/go/+/231918 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-04[dev.link] cmd/internal/dwarf: revise Abbrevs() signatureThan McIntosh
The function Abbrevs() was returning an array of structures by value, which is not very efficient (this was showing up in a kubernetes kubelet linker profile). Switch the function to return a slice instead. Improves linker DwarfGenerateDebugSyms running time when linking the compiler in compilebench: DwarfGenerateDebugSyms 29.2ms ±144% 23.9ms ±125% -17.89% (p=0.000 n=99+99) Change-Id: I1132816563f208c63eb82a7932d9f2bcb2455324 Reviewed-on: https://go-review.googlesource.com/c/go/+/231558 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-23[dev.link] cmd/internal/dwarf: add back some constant prefixesCherry Zhang
They are still used by the old linker. This is for introducing gating for the new object file format and the new linker. Change-Id: I97bb6ab4cc2c03f90f199c705d4c127e45ca07f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/224621 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-03-12[dev.link] cmd/link: demote DWARF line symbols to anonymous auxThan McIntosh
Convert DWARF .debug_line symbols to anonymous aux syms, so as to save space in object files and reduce the number of symbols that have to be added to the linker's lookup tables. Change-Id: I5b350f036e21a7a7128cb08148ab7c243aaf0d0b Reviewed-on: https://go-review.googlesource.com/c/go/+/223018 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-12[dev.link] cmd/link: demote dwarf {range,loc} sub-symbols to auxThan McIntosh
When the compiler emits DWARF for a function F, in addition to the text symbol for F, it emits a set of sibling or child symbols that carry the various DWARF bits for F (for example, go.info.F, go.ranges.F, go.loc.F, and so on). Prior to the linker modernization work, name lookup was the way you made your way from a function symbol to one of its child DWARF symbols. We now have a new mechanism (aux symbols), so there is really no need for the DWARF sub-symbols to be named or to be dupok. This patch converts DWARF "range" and "loc" sub-symbols to be pure aux syms: unnamed, and connected to their parent text symbol only via aux data. This should presumably have performance benefits in that we add fewer symbols to the linker lookup tables. Other related DWARF sub-symbols (ex: go.line.*) will be handled in a subsequent patch. Change-Id: Iae3ec2d42452962d4afc1df4a1bd89ccdeadc6e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/222673 Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-02-27[dev.link] cmd/link: simplify DWARF DIE symbol payloadThan McIntosh
Get rid of of the linker's dwSym struct (which wraps a loader.Loader and a loader.Sym) in favor of just loader.Sym. This requires some minor tweaks to the cmd/internal/dwarf interfaces. Change-Id: Id3ffd7c41b2433ea04417040368700334bb0e611 Reviewed-on: https://go-review.googlesource.com/c/go/+/220982 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-11-03[dev.link] cmd/internal/dwarf: expand import path in function DIECherry Zhang
Currently, at compile time we emit a function DIE with '"".' in the function name, and we expand it at link time, with a really ugly function. We can just expand it at compile time instead. This way, we don't need to modify the symbol content at link time, and also no need to allocate memory for that. Keep the linker expansion, in case the compiler is invoked without the import path. Change-Id: Id53cd2e2d3eb61efceb8d44479c4b6ef890baa43 Reviewed-on: https://go-review.googlesource.com/c/go/+/204826 Reviewed-by: Than McIntosh <thanm@google.com>
2019-09-26cmd/compile: remove isStmt symbol from FuncInfoJeremy Faller
As promised in CL 188238, removing the obsolete symbol. Here are the latest stats. This is baselined at "e53edafb66" with only these changes applied, run on magna.cam. The linker looks straight better (in memory and speed). There is still a change I'm working on walking the progs to generate the debug_lines data in the compiler. That will likely result in a compiler speedup. name old time/op new time/op delta Template 324ms ± 3% 317ms ± 3% -2.07% (p=0.043 n=10+10) Unicode 142ms ± 4% 144ms ± 3% ~ (p=0.393 n=10+10) GoTypes 1.05s ± 2% 1.07s ± 2% +1.59% (p=0.019 n=9+9) Compiler 4.09s ± 2% 4.11s ± 1% ~ (p=0.218 n=10+10) SSA 12.5s ± 1% 12.7s ± 1% +1.00% (p=0.035 n=10+10) Flate 199ms ± 7% 203ms ± 5% ~ (p=0.481 n=10+10) GoParser 245ms ± 3% 246ms ± 5% ~ (p=0.780 n=9+10) Reflect 672ms ± 4% 688ms ± 3% +2.42% (p=0.015 n=10+10) Tar 280ms ± 4% 284ms ± 4% ~ (p=0.123 n=10+10) XML 379ms ± 4% 381ms ± 2% ~ (p=0.529 n=10+10) LinkCompiler 1.16s ± 4% 1.12s ± 2% -3.03% (p=0.001 n=10+9) ExternalLinkCompiler 2.28s ± 3% 2.23s ± 3% -2.51% (p=0.011 n=8+9) LinkWithoutDebugCompiler 686ms ± 9% 667ms ± 2% ~ (p=0.277 n=9+8) StdCmd 14.1s ± 1% 14.0s ± 1% ~ (p=0.739 n=10+10) name old user-time/op new user-time/op delta Template 604ms ±23% 564ms ± 7% ~ (p=0.661 n=10+9) Unicode 429ms ±40% 418ms ±37% ~ (p=0.579 n=10+10) GoTypes 2.43s ±12% 2.51s ± 7% ~ (p=0.393 n=10+10) Compiler 9.22s ± 3% 9.27s ± 3% ~ (p=0.720 n=9+10) SSA 26.3s ± 3% 26.6s ± 2% ~ (p=0.579 n=10+10) Flate 328ms ±19% 333ms ±12% ~ (p=0.842 n=10+9) GoParser 387ms ± 5% 378ms ± 9% ~ (p=0.356 n=9+10) Reflect 1.36s ±20% 1.43s ±21% ~ (p=0.631 n=10+10) Tar 469ms ±12% 471ms ±21% ~ (p=0.497 n=9+10) XML 685ms ±18% 698ms ±19% ~ (p=0.739 n=10+10) LinkCompiler 1.86s ±10% 1.87s ±11% ~ (p=0.968 n=10+9) ExternalLinkCompiler 3.20s ±13% 3.01s ± 8% -5.70% (p=0.046 n=8+9) LinkWithoutDebugCompiler 1.08s ±15% 1.09s ±20% ~ (p=0.579 n=10+10) name old alloc/op new alloc/op delta Template 36.3MB ± 0% 36.4MB ± 0% +0.26% (p=0.000 n=10+10) Unicode 28.5MB ± 0% 28.5MB ± 0% ~ (p=0.165 n=10+10) GoTypes 120MB ± 0% 121MB ± 0% +0.29% (p=0.000 n=9+10) Compiler 546MB ± 0% 548MB ± 0% +0.32% (p=0.000 n=10+10) SSA 1.84GB ± 0% 1.85GB ± 0% +0.49% (p=0.000 n=10+10) Flate 22.9MB ± 0% 23.0MB ± 0% +0.25% (p=0.000 n=10+10) GoParser 27.8MB ± 0% 27.9MB ± 0% +0.25% (p=0.000 n=10+8) Reflect 77.5MB ± 0% 77.7MB ± 0% +0.27% (p=0.000 n=9+9) Tar 34.5MB ± 0% 34.6MB ± 0% +0.23% (p=0.000 n=10+10) XML 44.2MB ± 0% 44.4MB ± 0% +0.32% (p=0.000 n=10+10) LinkCompiler 239MB ± 0% 230MB ± 0% -3.86% (p=0.000 n=10+10) ExternalLinkCompiler 243MB ± 0% 243MB ± 0% +0.22% (p=0.000 n=10+10) LinkWithoutDebugCompiler 164MB ± 0% 155MB ± 0% -5.45% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Template 371k ± 0% 372k ± 0% +0.44% (p=0.000 n=10+10) Unicode 340k ± 0% 340k ± 0% +0.05% (p=0.000 n=10+10) GoTypes 1.32M ± 0% 1.32M ± 0% +0.46% (p=0.000 n=10+10) Compiler 5.34M ± 0% 5.37M ± 0% +0.59% (p=0.000 n=10+10) SSA 17.6M ± 0% 17.7M ± 0% +0.63% (p=0.000 n=10+10) Flate 233k ± 0% 234k ± 0% +0.48% (p=0.000 n=10+10) GoParser 309k ± 0% 310k ± 0% +0.40% (p=0.000 n=10+10) Reflect 964k ± 0% 969k ± 0% +0.54% (p=0.000 n=10+10) Tar 346k ± 0% 348k ± 0% +0.48% (p=0.000 n=10+9) XML 424k ± 0% 426k ± 0% +0.51% (p=0.000 n=10+10) LinkCompiler 751k ± 0% 645k ± 0% -14.13% (p=0.000 n=10+10) ExternalLinkCompiler 1.79M ± 0% 1.69M ± 0% -5.30% (p=0.000 n=10+10) LinkWithoutDebugCompiler 217k ± 0% 222k ± 0% +2.02% (p=0.000 n=10+10) name old object-bytes new object-bytes delta Template 547kB ± 0% 559kB ± 0% +2.17% (p=0.000 n=10+10) Unicode 215kB ± 0% 216kB ± 0% +0.60% (p=0.000 n=10+10) GoTypes 1.99MB ± 0% 2.03MB ± 0% +2.02% (p=0.000 n=10+10) Compiler 7.86MB ± 0% 8.07MB ± 0% +2.73% (p=0.000 n=10+10) SSA 26.4MB ± 0% 27.2MB ± 0% +3.27% (p=0.000 n=10+10) Flate 337kB ± 0% 343kB ± 0% +2.02% (p=0.000 n=10+10) GoParser 432kB ± 0% 441kB ± 0% +2.11% (p=0.000 n=10+10) Reflect 1.33MB ± 0% 1.36MB ± 0% +1.87% (p=0.000 n=10+10) Tar 477kB ± 0% 487kB ± 0% +2.24% (p=0.000 n=10+10) XML 617kB ± 0% 632kB ± 0% +2.33% (p=0.000 n=10+10) name old export-bytes new export-bytes delta Template 18.5kB ± 0% 18.5kB ± 0% ~ (all equal) Unicode 7.92kB ± 0% 7.92kB ± 0% ~ (all equal) GoTypes 35.0kB ± 0% 35.0kB ± 0% ~ (all equal) Compiler 109kB ± 0% 109kB ± 0% +0.09% (p=0.000 n=10+10) SSA 137kB ± 0% 137kB ± 0% +0.03% (p=0.000 n=10+10) Flate 4.89kB ± 0% 4.89kB ± 0% ~ (all equal) GoParser 8.49kB ± 0% 8.49kB ± 0% ~ (all equal) Reflect 11.4kB ± 0% 11.4kB ± 0% ~ (all equal) Tar 10.5kB ± 0% 10.5kB ± 0% ~ (all equal) XML 16.7kB ± 0% 16.7kB ± 0% ~ (all equal) name old text-bytes new text-bytes delta HelloSize 760kB ± 0% 760kB ± 0% ~ (all equal) CmdGoSize 10.8MB ± 0% 10.8MB ± 0% ~ (all equal) name old data-bytes new data-bytes delta HelloSize 10.7kB ± 0% 10.7kB ± 0% ~ (all equal) CmdGoSize 312kB ± 0% 312kB ± 0% ~ (all equal) name old bss-bytes new bss-bytes delta HelloSize 122kB ± 0% 122kB ± 0% ~ (all equal) CmdGoSize 146kB ± 0% 146kB ± 0% ~ (all equal) name old exe-bytes new exe-bytes delta HelloSize 1.11MB ± 0% 1.13MB ± 0% +1.10% (p=0.000 n=10+10) CmdGoSize 14.9MB ± 0% 15.0MB ± 0% +0.77% (p=0.000 n=10+10) Change-Id: I42e6087cd6231dbdcfff5464e46d373474e455e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/192417 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com>
2019-09-23cmd/compile: add new symbol for debug line numbersJeremy Faller
This is broken out from: CL 187117 This new symbol will be populated by the compiler and contain debug line information that's currently generated in the linker. One might say it's sad to create a new symbol, but this symbol will replace the isStmt symbols. Testing: Ran go build -toolexec 'toolstash -cmp' Change-Id: If8f7ae4b43b7247076605b6429b7d03a1fd239c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/188238 Reviewed-by: Austin Clements <austin@google.com>
2019-05-13cmd/compile: remove large intermediate slice from gc.scopePCsDavid Chase
Three loops can be converted into one. Minor reviewer-recommended refactoring. Passes toolstash-check. Updates #27739. Change-Id: Ia87a11d88ae3ce56fcc4267fe6c5a9c13bf7f533 Reviewed-on: https://go-review.googlesource.com/c/go/+/176577 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2019-05-09cmd/compile: emit DWARF call_line attrs with data4 form on iOSThan McIntosh
When targeting iOS, change the format (DWARF "form") of the call line attribute for inlined subroutine DIEs, to work around an apparent bug in /usr/bin/symbols on Darwin. [Just for posterity: there is nothing wrong with using DW_FORM_udata for the call_line attribute form; this is perfectly legal DWARF (and is in fact recommended by the standard relative to data4, which is less descriptive and often takes more space). The form switch is there just to make the Apple tools happy.] Updates #31459. Change-Id: Iaf362788a8c6684eea4cde8956c0661b694cecc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/174538 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2019-04-23cmd/link: revert/revise CL 98075 because LLDB is very picky nowDavid Chase
This was originally Revert "cmd/link: fix up debug_range for dsymutil (revert CL 72371)" which has the effect of no longer using Base Address Selection Entries in DWARF. However, the build-time costs of that are about 2%, so instead the hacky fixup that generated technically incorrect DWARF was removed from the linker, and the choice is instead made in the compiler, dependent on platform, but also under control of a flag so that we can report this bug against LLDB/dsymutil/dwarfdump (really, the LLVM dwarf libraries). This however does not solve #31188; debugging still fails, but dwarfdump no longer complains. There are at least two LLDB bugs involved, and this change will at allow us to report them without them being rejected because our now-obsolete workaround for the first bug creates not-quite-DWARF. Updates #31188. Change-Id: I5300c51ad202147bab7333329ebe961623d2b47d Reviewed-on: https://go-review.googlesource.com/c/go/+/170638 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-04-02compile,link: export package name in debug_infoAlessandro Arzilli
Add a new custom attribute to compile units containing the package name of the package (i.e. the name after the 'package' keyword), so that debuggers can know it when it's different from the last segment of the package path. Change-Id: Ieadaab6f47091aabf2f4dc42c8524452eaa6715b Reviewed-on: https://go-review.googlesource.com/c/go/+/163677 Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@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>
2018-11-02all: use "reports whether" consistently in the few places that didn'tBrad Fitzpatrick
Go documentation style for boolean funcs is to say: // Foo reports whether ... func Foo() bool (rather than "returns true if") This CL also replaces 4 uses of "iff" with the same "reports whether" wording, which doesn't lose any meaning, and will prevent people from sending typo fixes when they don't realize it's "if and only if". In the past I think we've had the typo CLs updated to just say "reports whether". So do them all at once. (Inspired by the addition of another "returns true if" in CL 146938 in fd_plan9.go) Created with: $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true iff" | grep -v vendor) $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true if" | grep -v vendor) Change-Id: Ided502237f5ab0d25cb625dbab12529c361a8b9f Reviewed-on: https://go-review.googlesource.com/c/147037 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-24cmd: add DWARF64 support for aix portClément Chigot
This commit adds support for DWARF 64bits which is needed for AIX operating system. It also adds the save of each compilation unit's size which will be used during XCOFF generation in a following patch. Updates: #25893 Change-Id: Icdd0a4dd02bc0a9f0df319c351fb1db944610015 Reviewed-on: https://go-review.googlesource.com/c/138729 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>