{"record":{"id":"8114dd26a1139924","repo":"golang/go","slug":"s-wl-v-failed-v-s","errorCode":null,"errorMessage":"%s -Wl,-V failed: %v\n%s","messagePattern":"(.+?) -Wl,-V failed: (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/dwarf/dwarf.go","lineNumber":1669,"sourceCode":"}\n\n// byChildIndexCmp compares two *dwarf.Var by child index.\nfunc byChildIndexCmp(a, b *Var) int { return cmp.Compare(a.ChildIndex, b.ChildIndex) }\n\n// IsDWARFEnabledOnAIXLd returns true if DWARF is possible on the\n// current extld.\n// AIX ld doesn't support DWARF with -bnoobjreorder with version\n// prior to 7.2.2.\nfunc IsDWARFEnabledOnAIXLd(extld []string) (bool, error) {\n\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","sourceCodeStart":1651,"sourceCodeEnd":1687,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/dwarf/dwarf.go#L1651-L1687","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nCC=/opt/freeware/bin/gcc-notreally go build # missing/broken\n\n// after\nCC=/opt/freeware/bin/gcc go build # valid AIX gcc, -Wl,-V works","handlingStrategy":"validation","validationCode":"// before building for AIX, verify the external linker runs -Wl,-V:\ncc := os.Getenv(\"CC\"); if cc == \"\" { cc = \"gcc\" }\nout, err := exec.Command(cc, \"-Wl,-V\").CombinedOutput()\nif err != nil { return fmt.Errorf(\"extld %s unusable: %w\\n%s\", cc, err, out) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["dwarf","aix","linker","extld","cross-compile"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}