{"record":{"id":"134c7326a4229c7a","repo":"golang/go","slug":"asan-is-not-supported-with-s-compiler-d-d-n","errorCode":null,"errorMessage":"-asan is not supported with %s compiler %d.%d\\n","messagePattern":"-asan is not supported with (.+?) compiler (.+?)\\.(.+?)\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/init.go","lineNumber":445,"sourceCode":"\t\t}()\n\t})\n\treturn compiler.version, compiler.err\n}\n\n// compilerRequiredAsanVersion is a copy of the function defined in\n// cmd/cgo/internal/testsanitizers/cc_test.go\n// compilerRequiredAsanVersion reports whether the compiler is the version\n// required by Asan.\nfunc compilerRequiredAsanVersion() error {\n\tcompiler, err := compilerVersion()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"-asan: the version of $(go env CC) could not be parsed\")\n\t}\n\n\tswitch compiler.name {\n\tcase \"gcc\":\n\t\tif runtime.GOARCH == \"ppc64le\" && compiler.major < 9 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\t\tif compiler.major < 7 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\tcase \"clang\":\n\t\tif compiler.major < 9 {\n\t\t\treturn fmt.Errorf(\"-asan is not supported with %s compiler %d.%d\\n\", compiler.name, compiler.major, compiler.minor)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"-asan: C compiler is not gcc or clang\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":427,"sourceCodeEnd":459,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/init.go#L427-L459","documentation":"Thrown by the go toolchain when building with -asan (AddressSanitizer) on ppc64le and the C compiler (go env CC) is gcc with a major version below 9. ppc64le needs gcc 9+ because earlier gcc revisions lack working Asan support on that architecture. It originates from compilerRequiredAsanVersion, a copy of the check in cmd/cgo/internal/testsanitizers/cc_test.go.","triggerScenarios":"Run `CGO_ENABLED=1 go build -asan` (or `go test -asan`) on GOARCH=ppc64le while CC resolves to gcc 7 or gcc 8. compilerVersion() parses `$(CC) -dumpversion`, the switch hits case \"gcc\", and the ppc64le && major<9 branch fires.","commonSituations":"Using the system gcc on an older ppc64le distro (e.g. RHEL 8 ships gcc 8); cross-compiling to ppc64le from a host with an older toolchain; CC overridden to a vendor gcc that reports an old dumpversion.","solutions":["Install/upgrade to gcc 9+ (e.g. `gcc-9` package) on the ppc64le host and rebuild.","Point CC at a newer gcc: `CC=gcc-9 go build -asan` (or `export CC=/usr/bin/gcc-9`).","Switch the C compiler to clang 9+: `CC=clang go build -asan`.","Verify with `$(go env CC) -dumpversion`; if it prints <9 on ppc64le, the build will fail."],"exampleFix":"// before\n// CC=gcc-8 go build -asan  (fails on ppc64le)\n\n// after\n// CC=gcc-9 go build -asan","handlingStrategy":"validation","validationCode":"// Run before `go build -asan` on ppc64le\nif runtime.GOARCH == \"ppc64le\" {\n    out, err := exec.Command(\"go\", \"env\", \"CC\").Output()\n    if err != nil { log.Fatal(err) }\n    cc := strings.TrimSpace(string(out))\n    v, err := exec.Command(cc, \"-dumpversion\").Output()\n    if err != nil { log.Fatal(err) }\n    maj := strings.Split(strings.TrimSpace(string(v)), \".\")[0]\n    if n, _ := strconv.Atoi(maj); n < 9 {\n        log.Fatalf(\"ppc64le -asan needs gcc>=9, got %s\", maj)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin CC to gcc-9+ on ppc64le CI hosts.","Assert compiler version in CI before running -asan tests.","Document the gcc-9 requirement in your build README."],"tags":["go-toolchain","asan","ppc64le","gcc","cgo"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}