{"record":{"id":"f7556c0eb5441a40","repo":"golang/go","slug":"gccgo-importcfg-does-not-support-shared-libraries","errorCode":null,"errorMessage":"gccgo -importcfg does not support shared libraries","messagePattern":"gccgo -importcfg does not support shared libraries","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/gccgo.go","lineNumber":192,"sourceCode":"\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"importmap\":\n\t\t\tif before == \"\" || after == \"\" {\n\t\t\t\treturn fmt.Errorf(`importcfg:%d: invalid importmap: syntax is \"importmap old=new\": %s`, lineNum, line)\n\t\t\t}\n\t\t\tbeforeA := gccgoArchive(root, before)\n\t\t\tafterA := gccgoArchive(root, after)\n\t\t\tif err := sh.Mkdir(filepath.Dir(beforeA)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := sh.Mkdir(filepath.Dir(afterA)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := sh.Symlink(afterA, beforeA); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase \"packageshlib\":\n\t\t\treturn fmt.Errorf(\"gccgo -importcfg does not support shared libraries\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (tools gccgoToolchain) asm(b *Builder, a *Action, sfiles []string) ([]string, error) {\n\tp := a.Package\n\tvar ofiles []string\n\tfor _, sfile := range sfiles {\n\t\tbase := filepath.Base(sfile)\n\t\tofile := a.Objdir + base[:len(base)-len(\".s\")] + \".o\"\n\t\tofiles = append(ofiles, ofile)\n\t\tsfile = fsys.Actual(mkAbs(p.Dir, sfile))\n\t\tdefs := []string{\"-D\", \"GOOS_\" + cfg.Goos, \"-D\", \"GOARCH_\" + cfg.Goarch}\n\t\tif pkgpath := tools.gccgoCleanPkgpath(b, p); pkgpath != \"\" {\n\t\t\tdefs = append(defs, `-D`, `GOPKGPATH=`+pkgpath)\n\t\t}\n\t\tdefs = tools.maybePIC(defs)","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/gccgo.go#L174-L210","documentation":"The gccgo importcfg reader encounters a `packageshlib` directive, which is only valid for the gc toolchain's shared-library mode (-buildmode=shared / -linkshared). gccgo does not support this directive through importcfg, so any occurrence returns this error immediately.","triggerScenarios":"Fires in the gccgo importcfg reader's `case \"packageshlib\"` branch - any presence of that directive when compiling/linking with -compiler=gccgo.","commonSituations":"Passing -buildmode=shared or -linkshared together with -compiler=gccgo, or mixing gc-built shared libraries into a gccgo build.","solutions":["Do not use -buildmode=shared or -linkshared with gccgo","Switch to the gc toolchain if shared-library mode is required","Build statically with gccgo instead"],"exampleFix":"// before (unsupported with gccgo)\ngo build -buildmode=shared -compiler=gccgo std\n// after (use gc for shared mode)\ngo build -buildmode=shared std","handlingStrategy":"validation","validationCode":"// Reject shared-library buildmode when using gccgo before building\nif os.Getenv(\"GOCompiler\") == \"gccgo\" || strings.Contains(buildmode, \"shared\") {\n    if strings.Contains(buildmode, \"shared\") && compilerIsGccgo {\n        return fmt.Errorf(\"gccgo does not support shared-library mode via importcfg\")\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not combine -buildmode=shared or -linkshared with -compiler=gccgo","Use the gc toolchain for shared-library build modes","Build statically with gccgo when shared mode is unsupported"],"tags":["go-toolchain","gccgo","importcfg","shared-libraries"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}