golang/go · error
cannot parse %s -Wl,-V (%s): %v
Error message
cannot parse %s -Wl,-V (%s): %v
What it means
This error is thrown during AIX linker version detection inside the Go linker's DWARF package. The linker shells out to the external linker (`extld -Wl,-V`) and expects output matching `/usr/bin/ld: LD X.X.X(date)`. After stripping the prefix and splitting on `(`, it takes the version string and splits on `.`. If the result does not have exactly 3 dot-separated numeric components, this error fires. It means the AIX system linker produced output in an unexpected format.
Source
Thrown at src/cmd/internal/dwarf/dwarf.go:1679
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, nil
} else if v > 2 {
return true, nil
}
if v, err := strconv.Atoi(subvers[2]); err != nil || v < 2 {
return false, nil
}
return true, nil
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Check the output of `gcc -Wl,-V` or `ld -V` directly on the AIX system to see what format the version string is in.
- Ensure you are using the native IBM AIX linker (`/usr/bin/ld`) and not a GNU ld wrapper.
- Upgrade or downgrade your Go toolchain to a version that supports your AIX ld version format.
- If the ld version is genuinely supported, report the version string format to the Go project so the parser can be updated.
Example fix
// No user code fix — this is a toolchain-level parse of system ld output. // Verify on AIX: // $ /usr/bin/ld -V 2>&1 | head -5 // Expected: /usr/bin/ld: LD 7.2.2(some_date) // If format differs, file a Go issue with the actual output.
Defensive patterns
Strategy: validation
Validate before calling
// Before linking on AIX, verify ld version output format:
// Run from shell: /usr/bin/ld -V 2>&1 | head -5
// Parse programmatically:
func checkAIXLdVersion(extld string) error {
cmd := exec.Command(extld, "-Wl,-V")
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("cannot run %s -Wl,-V: %w", extld, err)
}
if !bytes.HasPrefix(out, []byte("/usr/bin/ld: LD ")) {
return fmt.Errorf("unexpected ld output format: %s", out)
}
verLine := bytes.TrimPrefix(out, []byte("/usr/bin/ld: LD "))
verPart := bytes.Split(verLine, []byte("("))[0]
parts := bytes.Split(verPart, []byte("."))
if len(parts) != 3 {
return fmt.Errorf("version has %d parts, expected 3", len(parts))
}
return nil
} Try / catch
// Wrap the linker call and report the ld version on failure:
// (toolchain-level; no Go API to catch — report to user)
if err := link(); err != nil {
if strings.Contains(err.Error(), "cannot parse") && strings.Contains(err.Error(), "-Wl,-V") {
log.Fatalf("AIX linker version detection failed. Check output of '%s -Wl,-V'", extld)
}
log.Fatal(err)
} Prevention
- Ensure the AIX system uses the native IBM /usr/bin/ld, not a GNU ld wrapper.
- Verify ld -V output format before building Go programs on AIX.
- Use a Go toolchain version known to support your AIX ld version.
When it happens
Trigger: Calling the linker on AIX (GOOS=aix) where `extld -Wl,-V` returns a version string without exactly 3 dot-separated fields. Occurs when the system `/usr/bin/ld` is a non-standard or newer/older version whose `-Wl,-V` output format differs, or when the output contains extra text before the version that prevents clean parsing.
Common situations: Building Go programs on AIX with a linker version whose `-V` output format changed. Using a third-party or GNU ld wrapper on AIX instead of the native IBM ld. Cross-compiling with GOOS=aix from a non-AIX host that has a misconfigured or absent AIX toolchain. Upgrading AIX to a version where IBM changed the ld version string format.
Related errors
- %s -Wl,-V failed: %v %s
- 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/ef4cb7b34ce0ceb1.
Report an issue: GitHub.