golang/go · error

-asan is not supported with %s compiler %d.%d\n

Error message

-asan is not supported with %s compiler %d.%d\n

What it means

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.

Source

Thrown at src/cmd/go/internal/work/init.go:445

		}()
	})
	return compiler.version, compiler.err
}

// compilerRequiredAsanVersion is a copy of the function defined in
// cmd/cgo/internal/testsanitizers/cc_test.go
// compilerRequiredAsanVersion reports whether the compiler is the version
// required by Asan.
func compilerRequiredAsanVersion() error {
	compiler, err := compilerVersion()
	if err != nil {
		return fmt.Errorf("-asan: the version of $(go env CC) could not be parsed")
	}

	switch compiler.name {
	case "gcc":
		if runtime.GOARCH == "ppc64le" && compiler.major < 9 {
			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
		}
		if compiler.major < 7 {
			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
		}
	case "clang":
		if compiler.major < 9 {
			return fmt.Errorf("-asan is not supported with %s compiler %d.%d\n", compiler.name, compiler.major, compiler.minor)
		}
	default:
		return fmt.Errorf("-asan: C compiler is not gcc or clang")
	}
	return nil
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Install/upgrade to gcc 9+ (e.g. `gcc-9` package) on the ppc64le host and rebuild.
  2. Point CC at a newer gcc: `CC=gcc-9 go build -asan` (or `export CC=/usr/bin/gcc-9`).
  3. Switch the C compiler to clang 9+: `CC=clang go build -asan`.
  4. Verify with `$(go env CC) -dumpversion`; if it prints <9 on ppc64le, the build will fail.

Example fix

// before
// CC=gcc-8 go build -asan  (fails on ppc64le)

// after
// CC=gcc-9 go build -asan
Defensive patterns

Strategy: validation

Validate before calling

// Run before `go build -asan` on ppc64le
if runtime.GOARCH == "ppc64le" {
    out, err := exec.Command("go", "env", "CC").Output()
    if err != nil { log.Fatal(err) }
    cc := strings.TrimSpace(string(out))
    v, err := exec.Command(cc, "-dumpversion").Output()
    if err != nil { log.Fatal(err) }
    maj := strings.Split(strings.TrimSpace(string(v)), ".")[0]
    if n, _ := strconv.Atoi(maj); n < 9 {
        log.Fatalf("ppc64le -asan needs gcc>=9, got %s", maj)
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/134c7326a4229c7a. Report an issue: GitHub.