{"record":{"id":"ef4cb7b34ce0ceb1","repo":"golang/go","slug":"cannot-parse-s-wl-v-s-v","errorCode":null,"errorMessage":"cannot parse %s -Wl,-V (%s): %v\n","messagePattern":"cannot parse (.+?) -Wl,-V \\((.+?)\\): (.+?)\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/dwarf/dwarf.go","lineNumber":1679,"sourceCode":"\tname, args := extld[0], extld[1:]\n\targs = append(args, \"-Wl,-V\")\n\tout, err := exec.Command(name, args...).CombinedOutput()\n\tif err != nil {\n\t\t// The normal output should display ld version and\n\t\t// then fails because \".main\" is not defined:\n\t\t// ld: 0711-317 ERROR: Undefined symbol: .main\n\t\tif !bytes.Contains(out, []byte(\"0711-317\")) {\n\t\t\treturn false, fmt.Errorf(\"%s -Wl,-V failed: %v\\n%s\", extld, err, out)\n\t\t}\n\t}\n\t// gcc -Wl,-V output should be:\n\t//   /usr/bin/ld: LD X.X.X(date)\n\t//   ...\n\tout = bytes.TrimPrefix(out, []byte(\"/usr/bin/ld: LD \"))\n\tvers := string(bytes.Split(out, []byte(\"(\"))[0])\n\tsubvers := strings.Split(vers, \".\")\n\tif len(subvers) != 3 {\n\t\treturn false, fmt.Errorf(\"cannot parse %s -Wl,-V (%s): %v\\n\", extld, out, err)\n\t}\n\tif v, err := strconv.Atoi(subvers[0]); err != nil || v < 7 {\n\t\treturn false, nil\n\t} else if v > 7 {\n\t\treturn true, nil\n\t}\n\tif v, err := strconv.Atoi(subvers[1]); err != nil || v < 2 {\n\t\treturn false, nil\n\t} else if v > 2 {\n\t\treturn true, nil\n\t}\n\tif v, err := strconv.Atoi(subvers[2]); err != nil || v < 2 {\n\t\treturn false, nil\n\t}\n\treturn true, nil\n}\n","sourceCodeStart":1661,"sourceCodeEnd":1696,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/dwarf/dwarf.go#L1661-L1696","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// No user code fix — this is a toolchain-level parse of system ld output.\n// Verify on AIX:\n//   $ /usr/bin/ld -V 2>&1 | head -5\n// Expected: /usr/bin/ld: LD 7.2.2(some_date)\n// If format differs, file a Go issue with the actual output.","handlingStrategy":"validation","validationCode":"// Before linking on AIX, verify ld version output format:\n// Run from shell: /usr/bin/ld -V 2>&1 | head -5\n// Parse programmatically:\nfunc checkAIXLdVersion(extld string) error {\n    cmd := exec.Command(extld, \"-Wl,-V\")\n    out, err := cmd.CombinedOutput()\n    if err != nil {\n        return fmt.Errorf(\"cannot run %s -Wl,-V: %w\", extld, err)\n    }\n    if !bytes.HasPrefix(out, []byte(\"/usr/bin/ld: LD \")) {\n        return fmt.Errorf(\"unexpected ld output format: %s\", out)\n    }\n    verLine := bytes.TrimPrefix(out, []byte(\"/usr/bin/ld: LD \"))\n    verPart := bytes.Split(verLine, []byte(\"(\"))[0]\n    parts := bytes.Split(verPart, []byte(\".\"))\n    if len(parts) != 3 {\n        return fmt.Errorf(\"version has %d parts, expected 3\", len(parts))\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Wrap the linker call and report the ld version on failure:\n// (toolchain-level; no Go API to catch — report to user)\nif err := link(); err != nil {\n    if strings.Contains(err.Error(), \"cannot parse\") && strings.Contains(err.Error(), \"-Wl,-V\") {\n        log.Fatalf(\"AIX linker version detection failed. Check output of '%s -Wl,-V'\", extld)\n    }\n    log.Fatal(err)\n}","preventionTips":["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."],"tags":["aix","linker","dwarf","external-linker","version-detection"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}