diff options
author | Tobias Bosch <tbosch@google.com> | 2019-09-26 09:45:35 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-09-26 20:19:44 +0000 |
commit | 8bb8b5b10282a5b603bb68e6c527d6b221d8f23d (patch) | |
tree | d20f602f7ee8e79872411028ef198acaab5e1d72 | |
parent | 52bf1077e4117f4497d0cff09443d1e843058e7f (diff) | |
download | toolchain-utils-8bb8b5b10282a5b603bb68e6c527d6b221d8f23d.tar.gz |
Support extra args for llvm next.
Also removes the capability of defining the old
wrapper path now that we are getting close to
landing it.
BUG=chromium:773875
TEST=golden tests and comparison against old wrapper.
Change-Id: I543ddb1651edf2a269917f8afb5a667129bc3561
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1826986
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-x | compiler_wrapper/build.py | 5 | ||||
-rw-r--r-- | compiler_wrapper/bundle.README | 2 | ||||
-rw-r--r-- | compiler_wrapper/config.go | 39 | ||||
-rw-r--r-- | compiler_wrapper/config_test.go | 67 | ||||
-rw-r--r-- | compiler_wrapper/cros_hardened_config_test.go | 51 | ||||
-rw-r--r-- | compiler_wrapper/cros_host_config_test.go | 6 | ||||
-rw-r--r-- | compiler_wrapper/cros_nonhardened_config_test.go | 3 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json | 126 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json | 653 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json | 375 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json | 246 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json | 269 | ||||
-rw-r--r-- | compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_path.json | 233 | ||||
-rw-r--r-- | compiler_wrapper/testutil_test.go | 11 |
14 files changed, 2045 insertions, 41 deletions
diff --git a/compiler_wrapper/build.py b/compiler_wrapper/build.py index 6cbfa893..658e7488 100755 --- a/compiler_wrapper/build.py +++ b/compiler_wrapper/build.py @@ -21,7 +21,8 @@ def parse_args(): required=True, choices=['cros.hardened', 'cros.nonhardened', 'cros.host']) parser.add_argument('--use_ccache', required=True, choices=['true', 'false']) - parser.add_argument('--old_wrapper_path', required=True) + parser.add_argument( + '--use_llvm_next', required=True, choices=['true', 'false']) parser.add_argument('--output_file', required=True, type=str) return parser.parse_args() @@ -33,7 +34,7 @@ def calc_go_args(args, version): '-X', 'main.UseCCache=' + args.use_ccache, '-X', - 'main.OldWrapperPath=' + args.old_wrapper_path, + 'main.UseLlvmNext=' + args.use_llvm_next, '-X', 'main.Version=' + version, ] diff --git a/compiler_wrapper/bundle.README b/compiler_wrapper/bundle.README index 530d04ea..10a28ee0 100644 --- a/compiler_wrapper/bundle.README +++ b/compiler_wrapper/bundle.README @@ -6,7 +6,7 @@ Toolchain utils compiler wrapper sources. Build the wrapper: ./build --config=<config name> --use_ccache=<bool> \ - --old_wrapper_path=<path> --output_file=<file> + --use_llvm_next=<bool> --output_file=<file> ATTENTION: The files in this folder are generated. Do not modify manually! diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go index 92e503d9..4270cf5e 100644 --- a/compiler_wrapper/config.go +++ b/compiler_wrapper/config.go @@ -35,15 +35,16 @@ type config struct { // Values fills config.version. var Version = "" -// OldWrapperPath can be set via a linker flag. -// Value fills config.oldWrapperPath. -var OldWrapperPath = "" - // UseCCache can be set via a linker flag. // Value will be passed to strconv.ParseBool. // E.g. go build -ldflags '-X config.UseCCache=true'. var UseCCache = "unknown" +// UseLlvmNext can be set via a linker flag. +// Value will be passed to strconv.ParseBool. +// E.g. go build -ldflags '-X config.UseLlvmNext=true'. +var UseLlvmNext = "unknown" + // ConfigName can be set via a linker flag. // Value has to be one of: // - "cros.hardened" @@ -56,29 +57,45 @@ func getRealConfig() (*config, error) { if err != nil { return nil, wrapErrorwithSourceLocf(err, "invalid format for UseCCache") } - config, err := getConfig(ConfigName, useCCache, OldWrapperPath, Version) + useLlvmNext, err := strconv.ParseBool(UseLlvmNext) + if err != nil { + return nil, wrapErrorwithSourceLocf(err, "invalid format for UseLLvmNext") + } + // FIXME: Remove comparison to old wrapper once the new wrapper has landed. + oldWrapperPath := "" + config, err := getConfig(ConfigName, useCCache, useLlvmNext, oldWrapperPath, Version) if err != nil { return nil, err } return config, nil } -func getConfig(configName string, useCCache bool, oldWrapperPath string, version string) (*config, error) { - var cfg *config +func getConfig(configName string, useCCache bool, useLlvmNext bool, oldWrapperPath string, version string) (*config, error) { + cfg := config{} switch configName { case "cros.hardened": - cfg = crosHardenedConfig + cfg = *crosHardenedConfig case "cros.nonhardened": - cfg = crosNonHardenedConfig + cfg = *crosNonHardenedConfig case "cros.host": - cfg = crosHostConfig + cfg = *crosHostConfig default: return nil, newErrorwithSourceLocf("unknown config name: %s", configName) } cfg.useCCache = useCCache + if useLlvmNext { + cfg.clangFlags = append(cfg.clangFlags, llvmNextFlags...) + } cfg.oldWrapperPath = oldWrapperPath cfg.version = version - return cfg, nil + return &cfg, nil +} + +var llvmNextFlags = []string{ + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", } // Full hardening. diff --git a/compiler_wrapper/config_test.go b/compiler_wrapper/config_test.go index bdcf5069..3d3f946d 100644 --- a/compiler_wrapper/config_test.go +++ b/compiler_wrapper/config_test.go @@ -12,6 +12,7 @@ func TestRealConfigWithUseCCacheFlag(t *testing.T) { resetGlobals() defer resetGlobals() ConfigName = "cros.hardened" + UseLlvmNext = "false" UseCCache = "false" cfg, err := getRealConfig() @@ -32,16 +33,47 @@ func TestRealConfigWithUseCCacheFlag(t *testing.T) { } UseCCache = "invalid" - _, err = getRealConfig() - if err == nil { + if _, err := getRealConfig(); err == nil { t.Fatalf("UseCCache: Expected an error, got none") } } +func TestRealConfigWithUseLLvmFlag(t *testing.T) { + resetGlobals() + defer resetGlobals() + ConfigName = "cros.hardened" + UseCCache = "false" + + UseLlvmNext = "false" + cfg, err := getRealConfig() + if err != nil { + t.Fatal(err) + } + if isUsingLLvmNext(cfg) { + t.Fatal("UseLLvmNext: Expected not to be used") + } + + UseLlvmNext = "true" + cfg, err = getRealConfig() + if err != nil { + t.Fatal(err) + } + + if !isUsingLLvmNext(cfg) { + t.Fatal("UseLLvmNext: Expected to be used") + } + + UseLlvmNext = "invalid" + if _, err := getRealConfig(); err == nil { + t.Fatalf("UseLlvmNext: Expected an error, got none") + } +} + func TestRealConfigWithConfigNameFlag(t *testing.T) { resetGlobals() defer resetGlobals() UseCCache = "false" + UseLlvmNext = "false" ConfigName = "cros.hardened" cfg, err := getRealConfig() @@ -71,29 +103,11 @@ func TestRealConfigWithConfigNameFlag(t *testing.T) { } ConfigName = "invalid" - _, err = getRealConfig() - if err == nil { + if _, err := getRealConfig(); err == nil { t.Fatalf("ConfigName: Expected an error, got none") } } -func TestRealConfigWithOldWrapperPath(t *testing.T) { - resetGlobals() - defer resetGlobals() - UseCCache = "false" - ConfigName = "cros.hardened" - - OldWrapperPath = "somepath" - - cfg, err := getRealConfig() - if err != nil { - t.Fatal(err) - } - if cfg.oldWrapperPath != "somepath" { - t.Fatalf("OldWrapperPath: Expected somepath, got %s", cfg.oldWrapperPath) - } -} - func isSysrootHardened(cfg *config) bool { for _, arg := range cfg.commonFlags { if arg == "-pie" { @@ -103,9 +117,18 @@ func isSysrootHardened(cfg *config) bool { return false } +func isUsingLLvmNext(cfg *config) bool { + for _, arg := range cfg.clangFlags { + if arg == "-Wno-reorder-init-list" { + return true + } + } + return false +} + func resetGlobals() { // Set all global variables to a defined state. - OldWrapperPath = "" + UseLlvmNext = "unknown" ConfigName = "unknown" UseCCache = "unknown" } diff --git a/compiler_wrapper/cros_hardened_config_test.go b/compiler_wrapper/cros_hardened_config_test.go index 9d5f700a..b6d47da8 100644 --- a/compiler_wrapper/cros_hardened_config_test.go +++ b/compiler_wrapper/cros_hardened_config_test.go @@ -17,11 +17,13 @@ import ( const oldHardenedWrapperPathForTest = "$CHROOT/usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/gcc-bin/4.9.x/sysroot_wrapper.hardened" const crosHardenedGoldenDir = "testdata/cros_hardened_golden" const crosHardenedNoCCacheGoldenDir = "testdata/cros_hardened_noccache_golden" +const crosHardenedLlvmNextGoldenDir = "testdata/cros_hardened_llvmnext_golden" func TestCrosHardenedConfig(t *testing.T) { withTestContext(t, func(ctx *testContext) { + useLlvmNext := false useCCache := true - cfg, err := getConfig("cros.hardened", useCCache, oldHardenedWrapperPathForTest, "123") + cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123") if err != nil { t.Fatal(err) } @@ -33,8 +35,9 @@ func TestCrosHardenedConfig(t *testing.T) { func TestCrosHardenedConfigWithoutCCache(t *testing.T) { withTestContext(t, func(ctx *testContext) { + useLlvmNext := false useCCache := false - cfg, err := getConfig("cros.hardened", useCCache, oldHardenedWrapperPathForTest, "123") + cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123") if err != nil { t.Fatal(err) } @@ -68,6 +71,50 @@ func TestCrosHardenedConfigWithoutCCache(t *testing.T) { }) } +func TestCrosHardenedConfigWithLlvmNext(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + useLlvmNext := true + useCCache := true + cfg, err := getConfig("cros.hardened", useCCache, useLlvmNext, oldHardenedWrapperPathForTest, "123") + if err != nil { + t.Fatal(err) + } + ctx.updateConfig(cfg) + + // Create a copy of the old wrapper where we add the llvm next flags + if ctx.cfg.oldWrapperPath != "" { + oldWrapperContent, err := ioutil.ReadFile(ctx.cfg.oldWrapperPath) + if err != nil { + t.Fatal(err) + } + oldWrapperLlvmNextFlags := ` +LLVM_NEXT_FLAGS_TO_ADD = set(['-Wno-reorder-init-list', +'-Wno-final-dtor-non-final-class', +'-Wno-implicit-int-float-conversion', +'-Wno-return-stack-address' +])` + oldWrapperContent = regexp.MustCompile(`LLVM_NEXT_FLAGS_TO_ADD = set\(\[\]\)`).ReplaceAll(oldWrapperContent, []byte(oldWrapperLlvmNextFlags)) + ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "oldwrapper_llvmnext") + if err := ioutil.WriteFile(ctx.cfg.oldWrapperPath, oldWrapperContent, 0666); err != nil { + t.Fatal(err) + } + } + + // Only run the subset of the sysroot wrapper tests that execute commands. + gomaPath := path.Join(ctx.tempDir, "gomacc") + ctx.writeFile(gomaPath, "") + gomaEnv := "GOMACC_PATH=" + gomaPath + runGoldenRecords(ctx, crosHardenedLlvmNextGoldenDir, []goldenFile{ + createGccPathGoldenInputs(ctx, gomaEnv), + createClangPathGoldenInputs(ctx, gomaEnv), + createClangSyntaxGoldenInputs(gomaEnv), + createBisectGoldenInputs(), + createForceDisableWErrorGoldenInputs(), + createClangTidyGoldenInputs(gomaEnv), + }) + }) +} + func createSyswrapperGoldenInputs(ctx *testContext) []goldenFile { gomaPath := path.Join(ctx.tempDir, "gomacc") ctx.writeFile(gomaPath, "") diff --git a/compiler_wrapper/cros_host_config_test.go b/compiler_wrapper/cros_host_config_test.go index 28575928..5137b561 100644 --- a/compiler_wrapper/cros_host_config_test.go +++ b/compiler_wrapper/cros_host_config_test.go @@ -16,8 +16,9 @@ const crosGccHostGoldenDir = "testdata/cros_gcc_host_golden" func TestCrosClangHostConfig(t *testing.T) { withTestContext(t, func(ctx *testContext) { + useLlvmNext := false useCCache := false - cfg, err := getConfig("cros.host", useCCache, oldClangHostWrapperPathForTest, "123") + cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldClangHostWrapperPathForTest, "123") if err != nil { t.Fatal(err) } @@ -45,8 +46,9 @@ func TestCrosClangHostConfig(t *testing.T) { func TestCrosGccHostConfig(t *testing.T) { withTestContext(t, func(ctx *testContext) { + useLlvmNext := false useCCache := false - cfg, err := getConfig("cros.host", useCCache, oldGccHostWrapperPathForTest, "123") + cfg, err := getConfig("cros.host", useCCache, useLlvmNext, oldGccHostWrapperPathForTest, "123") if err != nil { t.Fatal(err) } diff --git a/compiler_wrapper/cros_nonhardened_config_test.go b/compiler_wrapper/cros_nonhardened_config_test.go index b6748db6..bf8af4d2 100644 --- a/compiler_wrapper/cros_nonhardened_config_test.go +++ b/compiler_wrapper/cros_nonhardened_config_test.go @@ -13,8 +13,9 @@ const crosNonHardenedGoldenDir = "testdata/cros_nonhardened_golden" func TestCrosNonHardenedConfig(t *testing.T) { withTestContext(t, func(ctx *testContext) { + useLlvmNext := false useCCache := true - cfg, err := getConfig("cros.nonhardened", useCCache, oldNonHardenedWrapperPathForTest, "123") + cfg, err := getConfig("cros.nonhardened", useCCache, useLlvmNext, oldNonHardenedWrapperPathForTest, "123") if err != nil { t.Fatal(err) } diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json new file mode 100644 index 00000000..2987a557 --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/bisect.json @@ -0,0 +1,126 @@ +[ + { + "wd": "/tmp/stable", + "env": [ + "BISECT_STAGE=someBisectStage", + "BISECT_DIR=someBisectDir" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/python2", + "args": [ + "-c", + "import bisect_driver; sys.exit(bisect_driver.bisect_driver(sys.argv[1], sys.argv[2], sys.argv[3:]))", + "someBisectStage", + "someBisectDir", + "/usr/bin/ccache", + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "BISECT_STAGE=someBisectStage", + "BISECT_DIR=someBisectDir" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/python2", + "args": [ + "-c", + "import bisect_driver; sys.exit(bisect_driver.bisect_driver(sys.argv[1], sys.argv[2], sys.argv[3:]))", + "someBisectStage", + "someBisectDir", + "/usr/bin/ccache", + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + } +] diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json new file mode 100644 index 00000000..f0472987 --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clang_path.json @@ -0,0 +1,653 @@ +[ + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang++", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "../../usr/bin/clang++", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "CLANG=somepath/clang" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "somepath/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "-Xclang-path=/somedir", + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/somedir/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "-resource-dir=someResourceDir", + "--gcc-toolchain=/usr", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "GOMACC_PATH=/tmp/stable/gomacc" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "-Xclang-path=/somedir", + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "/somedir/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "-resource-dir=someResourceDir", + "--gcc-toolchain=/usr", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "-Xclang-path=/somedir", + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/somedir/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "-resource-dir=someResourceDir", + "--gcc-toolchain=/usr", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./a/b/c/d/e/f/g/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./symlinked/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "a/b/usr/bin/clang", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-Ba/b/bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "somedir/x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "PATH=/tmp/stable/pathenv" + ], + "wrapper": { + "cmd": { + "path": "x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + } +] diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json new file mode 100644 index 00000000..4ff173cb --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/clangtidy.json @@ -0,0 +1,375 @@ +[ + { + "wd": "/tmp/stable", + "env": [ + "WITH_TIDY=1" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "../../usr/bin/clang-tidy", + "args": [ + "-checks=*,google*,-bugprone-narrowing-conversions,-cppcoreguidelines-*,-fuchsia-*,-google-build-using-namespace,-google-default-arguments,-google-explicit-constructor,-google-readability*,-google-runtime-int,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-llvm-namespace-comment,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-modernize-*,-readability-*", + "main.cc", + "--", + "-resource-dir=someResourceDir", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + }, + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "WITH_TIDY=1", + "GOMACC_PATH=/tmp/stable/gomacc" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "../../usr/bin/clang-tidy", + "args": [ + "-checks=*,google*,-bugprone-narrowing-conversions,-cppcoreguidelines-*,-fuchsia-*,-google-build-using-namespace,-google-default-arguments,-google-explicit-constructor,-google-readability*,-google-runtime-int,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-llvm-namespace-comment,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-modernize-*,-readability-*", + "main.cc", + "--", + "-resource-dir=someResourceDir", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + }, + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "WITH_TIDY=1", + "GOMACC_PATH=/tmp/stable/gomacc" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerrorclang-tidy failed" + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "../../usr/bin/clang-tidy", + "args": [ + "-checks=*,google*,-bugprone-narrowing-conversions,-cppcoreguidelines-*,-fuchsia-*,-google-build-using-namespace,-google-default-arguments,-google-explicit-constructor,-google-readability*,-google-runtime-int,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-llvm-namespace-comment,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-modernize-*,-readability-*", + "main.cc", + "--", + "-resource-dir=someResourceDir", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "WITH_TIDY=1", + "GOMACC_PATH=/tmp/stable/gomacc" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--print-resource-dir" + ] + }, + "stdout": "someResourceDir" + }, + { + "cmd": { + "path": "../../usr/bin/clang-tidy", + "args": [ + "-checks=*,google*,-bugprone-narrowing-conversions,-cppcoreguidelines-*,-fuchsia-*,-google-build-using-namespace,-google-default-arguments,-google-explicit-constructor,-google-readability*,-google-runtime-int,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-braces-around-statements,-hicpp-no-array-decay,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-llvm-namespace-comment,-misc-non-private-member-variables-in-classes,-misc-unused-parameters,-modernize-*,-readability-*", + "main.cc", + "--", + "-resource-dir=someResourceDir", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + } + }, + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + } +] diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json new file mode 100644 index 00000000..d459417d --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json @@ -0,0 +1,246 @@ +[ + { + "wd": "/tmp/stable", + "env": [ + "FORCE_DISABLE_WERROR=1" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "FORCE_DISABLE_WERROR=1" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stderr": "-Werror originalerror", + "exitcode": 1 + }, + { + "cmd": { + "path": "ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-Wno-error" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "FORCE_DISABLE_WERROR=1" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-clang", + "args": [ + "main.cc" + ] + }, + "stderr": "-Werror originalerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stderr": "-Werror originalerror", + "exitcode": 1 + }, + { + "cmd": { + "path": "ccache", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-Wno-error" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002", + "CCACHE_CPP2=yes" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + } +] diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json new file mode 100644 index 00000000..c692036d --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_clang_syntax.json @@ -0,0 +1,269 @@ +[ + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "-clang-syntax", + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-fsyntax-only", + "-stdlib=libstdc++" + ] + } + }, + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "GOMACC_PATH=/tmp/stable/gomacc" + ], + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "-clang-syntax", + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "../../usr/bin/clang", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-fsyntax-only", + "-stdlib=libstdc++" + ] + } + }, + { + "cmd": { + "path": "/tmp/stable/gomacc", + "args": [ + "./x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "-clang-syntax", + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-fsyntax-only", + "-stdlib=libstdc++" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "-clang-syntax", + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "../../usr/bin/clang", + "args": [ + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-Qunused-arguments", + "-grecord-gcc-switches", + "-fno-addrsig", + "-Wno-tautological-constant-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-unknown-warning-option", + "-Wno-section", + "-static-libgcc", + "-fuse-ld=lld", + "-Wno-reorder-init-list", + "-Wno-final-dtor-non-final-class", + "-Wno-implicit-int-float-conversion", + "-Wno-return-stack-address", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-B../../bin", + "-target", + "x86_64-cros-linux-gnu", + "-fsyntax-only", + "-stdlib=libstdc++" + ] + } + }, + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + } +] diff --git a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_path.json b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_path.json new file mode 100644 index 00000000..24ad65ae --- /dev/null +++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/gcc_path.json @@ -0,0 +1,233 @@ +[ + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + }, + "stdout": "somemessage", + "stderr": "someerror", + "exitcode": 1 + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "/tmp/stable/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/tmp/stable/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./a/b/c/d/e/f/g/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "wrapper": { + "cmd": { + "path": "./symlinked/x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "./symlinked/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/tmp/stable/a/b/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + }, + { + "wd": "/tmp/stable", + "env": [ + "PATH=/tmp/stable/pathenv" + ], + "wrapper": { + "cmd": { + "path": "x86_64-cros-linux-gnu-gcc", + "args": [ + "main.cc" + ] + } + }, + "cmds": [ + { + "cmd": { + "path": "/usr/bin/ccache", + "args": [ + "/tmp/stable/pathenv/x86_64-cros-linux-gnu-gcc.real", + "--sysroot=/usr/x86_64-cros-linux-gnu", + "-fno-reorder-blocks-and-partition", + "-Wno-unused-local-typedefs", + "-Wno-maybe-uninitialized", + "-fstack-protector-strong", + "-fPIE", + "-pie", + "-D_FORTIFY_SOURCE=2", + "-fno-omit-frame-pointer", + "main.cc", + "-mno-movbe" + ], + "env_updates": [ + "CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu", + "CCACHE_DIR=/var/cache/distfiles/ccache", + "CCACHE_UMASK=002" + ] + } + } + ] + } +] diff --git a/compiler_wrapper/testutil_test.go b/compiler_wrapper/testutil_test.go index 3eb2c5fa..95d6fc52 100644 --- a/compiler_wrapper/testutil_test.go +++ b/compiler_wrapper/testutil_test.go @@ -108,6 +108,17 @@ func (ctx *testContext) run(cmd *command, stdin io.Reader, stdout io.Writer, std // Keep calling the old wrapper when we are comparing the output of the // old wrapper to the new wrapper. if isCompareToOldWrapperCmd(cmd) { + // Make sure we have a PATH in the env as the old wrapper needs that. + pathFound := false + for _, arg := range ctx.env { + if arg == "PATH" { + pathFound = true + break + } + } + if !pathFound { + ctx.env = append(ctx.env, "PATH=") + } return runCmd(ctx, cmd, nil, stdout, stderr) } ctx.cmdCount++ |