From bd46c2938038cfa5f34b64d2c42cb963524325c9 Mon Sep 17 00:00:00 2001 From: pagran <67878280+pagran@users.noreply.github.com> Date: Tue, 25 Aug 2020 18:22:53 +0300 Subject: [PATCH] add blacklist for runtime std packages --- main.go | 5 +++++ testdata/scripts/goprivate.txt | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 99b2692..58c2e53 100644 --- a/main.go +++ b/main.go @@ -578,11 +578,16 @@ func transformCompile(args []string) ([]string, error) { return append(flags, newPaths...), nil } +const privateBlacklist = "runtime,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 { + if GlobsMatchPath(privateBlacklist, path) { + return false + } 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