Skip to content

Commit df34d5e

Browse files
committed
cmd/link: add flag help to go doc via internal/flagdoc
The 'go doc cmd/link' command showed incomplete flag help compared to 'go tool link -h'. This change adds a new internal package flagdoc with duplicated flag variables so that 'go doc' displays full help without build conflicts. Fixes #72086
1 parent d55ecea commit df34d5e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Package flagdoc contains flag definitions for 'go doc cmd/link'.
6+
// It duplicates flags from internal/ld/main.go to show full help.
7+
package flagdoc
8+
9+
import (
10+
"cmd/internal/quoted"
11+
"flag"
12+
)
13+
14+
var (
15+
// === LINKER FLAGS FOR go doc cmd/link ===
16+
// Duplicated from cmd/link/internal/ld/main.go
17+
Buildid = flag.String("buildid", "", "record `id` as Go toolchain build id")
18+
BindNow = flag.Bool("bindnow", false, "mark a dynamically linked ELF object for immediate function binding")
19+
Outfile = flag.String("o", "", "write output to `file`")
20+
PluginPath = flag.String("pluginpath", "", "full path name for plugin")
21+
Fipso = flag.String("fipso", "", "write fips module to `file`")
22+
InstallSuffix = flag.String("installsuffix", "", "set package directory `suffix`")
23+
DumpDep = flag.Bool("dumpdep", false, "dump symbol dependency graph")
24+
Race = flag.Bool("race", false, "enable race detector")
25+
Msan = flag.Bool("msan", false, "enable MSan interface")
26+
Asan = flag.Bool("asan", false, "enable ASan interface")
27+
Aslr = flag.Bool("aslr", true, "enable ASLR for buildmode=c-shared on windows")
28+
FieldTrack = flag.String("k", "", "set field tracking `symbol`")
29+
LibGCC = flag.String("libgcc", "", "compiler support lib for internal linking; use \"none\" to disable")
30+
Tmpdir = flag.String("tmpdir", "", "use `directory` for temporary files")
31+
Extld = new(quoted.Flag)
32+
Extldflags = new(quoted.Flag)
33+
Extar = flag.String("extar", "", "archive program for buildmode=c-archive")
34+
CaptureHostObjs = flag.String("capturehostobjs", "", "capture host object files loaded during internal linking to specified dir")
35+
Aflag = flag.Bool("a", false, "no-op (deprecated)")
36+
Cflag = flag.Bool("c", false, "dump call graph")
37+
Dflag = flag.Bool("d", false, "disable dynamic executable")
38+
Fflag = flag.Bool("f", false, "ignore version mismatch")
39+
Gflag = flag.Bool("g", false, "disable go package data checks")
40+
Hflag = flag.Bool("h", false, "halt on error")
41+
Nflag = flag.Bool("n", false, "no-op (deprecated)")
42+
Sflag = flag.Bool("s", false, "disable symbol table")
43+
HostBuildid = flag.String("B", "", "set ELF NT_GNU_BUILD_ID `note` or Mach-O UUID; use \"gobuildid\" to generate it from the Go build ID; \"none\" to disable")
44+
Interpreter = flag.String("I", "", "use `linker` as ELF dynamic linker")
45+
CheckLinkname = flag.Bool("checklinkname", true, "check linkname symbol references")
46+
DebugTramp = flag.Int("debugtramp", 0, "debug trampolines")
47+
DebugTextSize = flag.Int("debugtextsize", 0, "debug text section max size")
48+
DebugNosplit = flag.Bool("debugnosplit", false, "dump nosplit call graph")
49+
StrictDups = flag.Int("strictdups", 0, "sanity check duplicate symbol contents during object file reading (1=warn 2=err).")
50+
Round = flag.Int64("R", -1, "set address rounding `quantum`")
51+
TextAddr = flag.Int64("T", -1, "set the start address of text symbols")
52+
DataAddr = flag.Int64("D", -1, "set the start address of data symbols")
53+
FuncAlign = flag.Int("funcalign", 0, "set function align to `N` bytes")
54+
EntrySymbol = flag.String("E", "", "set `entry` symbol name")
55+
PruneWeakMap = flag.Bool("pruneweakmap", true, "prune weak mapinit refs")
56+
RandLayout = flag.Int64("randlayout", 0, "randomize function layout")
57+
AllErrors = flag.Bool("e", false, "no limit on number of errors reported")
58+
CpuProfile = flag.String("cpuprofile", "", "write cpu profile to `file`")
59+
MemProfile = flag.String("memprofile", "", "write memory profile to `file`")
60+
MemProfileRate = flag.Int64("memprofilerate", 0, "set runtime.MemProfileRate to `rate`")
61+
Benchmark = flag.String("benchmark", "", "set to 'mem' or 'cpu' to enable phase benchmarking")
62+
BenchmarkProfile = flag.String("benchmarkprofile", "", "emit phase profiles to `base`_phase.{cpu,mem}prof")
63+
Wflag = new(bool)
64+
)

0 commit comments

Comments
 (0)