diff --git a/main.go b/main.go index 99b2692..497d97e 100644 --- a/main.go +++ b/main.go @@ -578,11 +578,26 @@ func transformCompile(args []string) ([]string, error) { return append(flags, newPaths...), nil } +var blacklistedPackages = [...]string{ + // Hardcoded variables and methods names + "runtime", + + // Constants in asm code + "internal/cpu", + "internal/bytealg", +} + // isPrivate checks if GOPRIVATE matches path. // // To allow using garble without GOPRIVATE for standalone main packages, it will // default to not matching standard library packages. func isPrivate(path string) bool { + for _, blacklistedPackage := range blacklistedPackages { + if path == blacklistedPackage || strings.HasPrefix(path, blacklistedPackage+"/") { + return false + } + } + println(path) if path == "main" || path == "command-line-arguments" || strings.HasPrefix(path, "plugin/unnamed") { // TODO: why don't we see the full package path for main // packages? The linker has it at the top of -importcfg, but not diff --git a/testdata/scripts/goprivate.txt b/testdata/scripts/goprivate.txt index 599d5fb..e5e4cd6 100644 --- a/testdata/scripts/goprivate.txt +++ b/testdata/scripts/goprivate.txt @@ -4,9 +4,8 @@ stderr 'does not match any packages' [short] stop -# TODO: https://github.com/mvdan/garble/issues/108 -# env GOPRIVATE='*' -# garble build -o bin ./standalone +env GOPRIVATE='*' +garble build -o bin ./standalone -- go.mod -- module test/main