{"record":{"id":"b75b2b80cda8fc38","repo":"golang/go","slug":"buildmode-s-not-supported-on-s-s","errorCode":null,"errorMessage":"buildmode %s not supported on %s/%s","messagePattern":"buildmode (.+?) not supported on (.+?)/(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/ld/config.go","lineNumber":55,"sourceCode":"\t\tcase \"darwin/arm64\", \"windows/arm64\": // On these platforms, everything is PIE\n\t\t\t*mode = BuildModePIE\n\t\tdefault:\n\t\t\t*mode = BuildModeExe\n\t\t}\n\tcase \"pie\":\n\t\t*mode = BuildModePIE\n\tcase \"c-archive\":\n\t\t*mode = BuildModeCArchive\n\tcase \"c-shared\":\n\t\t*mode = BuildModeCShared\n\tcase \"shared\":\n\t\t*mode = BuildModeShared\n\tcase \"plugin\":\n\t\t*mode = BuildModePlugin\n\t}\n\n\tif !platform.BuildModeSupported(\"gc\", s, buildcfg.GOOS, buildcfg.GOARCH) {\n\t\treturn fmt.Errorf(\"buildmode %s not supported on %s/%s\", s, buildcfg.GOOS, buildcfg.GOARCH)\n\t}\n\n\treturn nil\n}\n\nfunc (mode BuildMode) String() string {\n\tswitch mode {\n\tcase BuildModeUnset:\n\t\treturn \"\" // avoid showing a default in usage message\n\tcase BuildModeExe:\n\t\treturn \"exe\"\n\tcase BuildModePIE:\n\t\treturn \"pie\"\n\tcase BuildModeCArchive:\n\t\treturn \"c-archive\"\n\tcase BuildModeCShared:\n\t\treturn \"c-shared\"\n\tcase BuildModeShared:","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/ld/config.go#L37-L73","documentation":"The Go linker validates that the requested buildmode is supported on the target GOOS/GOARCH platform combination using platform.BuildModeSupported. Even if the buildmode string is recognized, some combinations are unsupported (e.g. shared mode requires Linux, plugin mode has limited platform support, c-shared requires specific architectures).","triggerScenarios":"After successfully parsing the buildmode string into a BuildMode constant, the linker calls platform.BuildModeSupported(\"gc\", s, buildcfg.GOOS, buildcfg.GOARCH). If this returns false, the error includes the buildmode, OS, and architecture to help the user identify the incompatibility.","commonSituations":"Using -buildmode=shared on macOS or Windows (only supported on Linux); using -buildmode=plugin on an unsupported architecture; requesting PIE on a platform that does not support it; cross-compiling to a target where the buildmode is not implemented.","solutions":["Check the Go documentation for buildmode platform support matrix","Switch to a supported GOOS/GOARCH for the desired buildmode (e.g. use GOOS=linux for -buildmode=shared)","Use a different buildmode that is supported on your target platform","If the platform should support it, verify you are using a recent enough Go version"],"exampleFix":"# before (shared mode not supported on macOS)\nGOOS=darwin GOARCH=amd64 go build -buildmode=shared ./mylib\n\n# after (shared mode supported on Linux)\nGOOS=linux GOARCH=amd64 go build -buildmode=shared ./mylib","handlingStrategy":"validation","validationCode":"// Check platform support before setting buildmode\n// This mirrors the linker's internal platform.BuildModeSupported check\nfunc isBuildModeSupported(mode, goos, goarch string) bool {\n    // Consult the Go platform support table\n    // e.g. -buildmode=shared only on linux/*\n    // e.g. -buildmode=plugin on linux/amd64, linux/arm64, darwin/amd64, etc.\n    return platform.BuildModeSupported(\"gc\", mode, goos, goarch)\n}","typeGuard":null,"tryCatchPattern":"// Catch unsupported buildmode and suggest alternatives\nif err := mode.Set(s); err != nil {\n    if strings.Contains(err.Error(), \"not supported\") {\n        fmt.Fprintf(os.Stderr, \"%v\\nTry a different GOOS/GOARCH or buildmode.\\n\", err)\n    }\n    return err\n}","preventionTips":["Consult the Go documentation for the buildmode/platform support matrix","Test buildmode compatibility in CI for each target platform before relying on it","Keep a reference of which buildmodes work on which GOOS/GOARCH combinations"],"tags":["buildmode","configuration","linker","go-toolchain","platform-support"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}