golang/go · error
%s -Wl,-V failed: %v %s
Error message
%s -Wl,-V failed: %v %s
What it means
Returned by IsDWARFEnabledOnAIXLd when invoking `extld -Wl,-V` fails AND the combined output does not contain the marker `0711-317` (the AIX ld 'Undefined symbol: .main' error that proves ld actually ran). The check is used to detect whether the AIX linker supports DWARF under -bnoobjreorder (only ld >= 7.2.2). If ld is missing, crashes, or is not AIX ld, this error surfaces.
Source
Thrown at src/cmd/internal/dwarf/dwarf.go:1669
}
// byChildIndexCmp compares two *dwarf.Var by child index.
func byChildIndexCmp(a, b *Var) int { return cmp.Compare(a.ChildIndex, b.ChildIndex) }
// IsDWARFEnabledOnAIXLd returns true if DWARF is possible on the
// current extld.
// AIX ld doesn't support DWARF with -bnoobjreorder with version
// prior to 7.2.2.
func IsDWARFEnabledOnAIXLd(extld []string) (bool, error) {
name, args := extld[0], extld[1:]
args = append(args, "-Wl,-V")
out, err := exec.Command(name, args...).CombinedOutput()
if err != nil {
// The normal output should display ld version and
// then fails because ".main" is not defined:
// ld: 0711-317 ERROR: Undefined symbol: .main
if !bytes.Contains(out, []byte("0711-317")) {
return false, fmt.Errorf("%s -Wl,-V failed: %v\n%s", extld, err, out)
}
}
// gcc -Wl,-V output should be:
// /usr/bin/ld: LD X.X.X(date)
// ...
out = bytes.TrimPrefix(out, []byte("/usr/bin/ld: LD "))
vers := string(bytes.Split(out, []byte("("))[0])
subvers := strings.Split(vers, ".")
if len(subvers) != 3 {
return false, fmt.Errorf("cannot parse %s -Wl,-V (%s): %v\n", extld, out, err)
}
if v, err := strconv.Atoi(subvers[0]); err != nil || v < 7 {
return false, nil
} else if v > 7 {
return true, nil
}
if v, err := strconv.Atoi(subvers[1]); err != nil || v < 2 {
return false, nilView on GitHub (pinned to b6b368adc5)
Solutions
- Ensure CC points at a working AIX gcc/xlc: `CC=<path> go build` and verify `<CC> -Wl,-V` runs manually.
- Confirm you are actually on an AIX host when targeting GOOS=aix.
- Check PATH includes the directory containing the external linker.
- Use a newer AIX linker (>= 7.2.2) if DWARF support is the goal.
Example fix
// before CC=/opt/freeware/bin/gcc-notreally go build # missing/broken // after CC=/opt/freeware/bin/gcc go build # valid AIX gcc, -Wl,-V works
Defensive patterns
Strategy: validation
Validate before calling
// before building for AIX, verify the external linker runs -Wl,-V:
cc := os.Getenv("CC"); if cc == "" { cc = "gcc" }
out, err := exec.Command(cc, "-Wl,-V").CombinedOutput()
if err != nil { return fmt.Errorf("extld %s unusable: %w\n%s", cc, err, out) } Prevention
- On AIX hosts, ensure CC points at a working gcc/xlc on PATH.
- Don't target GOOS=aix from non-AIX hosts without a proper cross toolchain.
- Verify `<CC> -Wl,-V` works manually before invoking the Go build.
When it happens
Trigger: Building for GOOS=aix with an external linker (typically gcc) where `gcc -Wl,-V` fails — wrong extld configured (CC env var pointing at a non-existent or non-AIX compiler), PATH issues, broken AIX ld install, or ld crashing before printing its version banner.
Common situations: Cross-compiling to AIX from a non-AIX host without a proper AIX toolchain, mis-set CC/CXX environment variables, broken xlc/gcc install on the AIX build host, or running the AIX build path on a non-AIX system by mistake.
Related errors
- cannot parse %s -Wl,-V (%s): %v
- fail to seek
- dwarf: null reference in %d
- unqualified symbol name: %v
- subprogram DIE high not convertible to uint64
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/8114dd26a1139924.
Report an issue: GitHub.