aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2021-01-25 12:11:56 -0800
committerGeorge Burgess <gbiv@chromium.org>2021-01-29 17:39:12 +0000
commit8126715006b533888697689276b771cf6cdc2063 (patch)
tree7f8273650dd0fb798b199a52882b885df2860917 /compiler_wrapper
parent77a0c2073a603ce6698f3667036e62a572cbb37c (diff)
downloadtoolchain-utils-8126715006b533888697689276b771cf6cdc2063.tar.gz
compiler_wrapper: disable force-disable-werror with GCC
Enabling this functionality with GCC is pointless -- we don't roll it, so we don't want to catch new -Werrors with it. We're having some GCC-specific functionality coming in soon; disabling this simplifies things some. BUG=chromium:1166017 TEST=CQ Change-Id: I3f73a8124ea85a2f14fd5c909a9bbed2b46f28f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2648431 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rw-r--r--compiler_wrapper/compiler_wrapper.go2
-rw-r--r--compiler_wrapper/compiler_wrapper_test.go4
-rw-r--r--compiler_wrapper/disable_werror_flag.go7
-rw-r--r--compiler_wrapper/disable_werror_flag_test.go30
4 files changed, 36 insertions, 7 deletions
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go
index f47b09c9..21a308b8 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -149,7 +149,7 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int
compilerCmd = removeRusageFromCommand(compilerCmd)
}
- if shouldForceDisableWerror(env, cfg) {
+ if shouldForceDisableWerror(env, cfg, mainBuilder.target.compilerType) {
if bisectStage != "" {
return 0, newUserErrorf("BISECT_STAGE is meaningless with FORCE_DISABLE_WERROR")
}
diff --git a/compiler_wrapper/compiler_wrapper_test.go b/compiler_wrapper/compiler_wrapper_test.go
index 680312f9..dc2a9dd5 100644
--- a/compiler_wrapper/compiler_wrapper_test.go
+++ b/compiler_wrapper/compiler_wrapper_test.go
@@ -115,7 +115,7 @@ func TestLogRusageAndForceDisableWError(t *testing.T) {
return nil
}
}
- ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ ctx.must(callCompiler(ctx, ctx.cfg, ctx.newCommand(clangX86_64, mainCc)))
if _, err := os.Stat(logFileName); os.IsNotExist(err) {
t.Errorf("no logfile created at TOOLCHAIN_RUSAGE_OUTPUT path %q", logFileName)
} else if err != nil {
@@ -146,7 +146,7 @@ func TestErrorOnBisectAndForceDisableWError(t *testing.T) {
"BISECT_STAGE=xyz",
"FORCE_DISABLE_WERROR=1",
}
- stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ stderr := ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(clangX86_64, mainCc)))
if err := verifyNonInternalError(stderr, "BISECT_STAGE is meaningless with FORCE_DISABLE_WERROR"); err != nil {
t.Error(err)
}
diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go
index 3974dcb3..9bbf2e25 100644
--- a/compiler_wrapper/disable_werror_flag.go
+++ b/compiler_wrapper/disable_werror_flag.go
@@ -19,10 +19,15 @@ import (
const numWErrorEstimate = 30
-func shouldForceDisableWerror(env env, cfg *config) bool {
+func shouldForceDisableWerror(env env, cfg *config, ty compilerType) bool {
if cfg.isAndroidWrapper {
return cfg.useLlvmNext
}
+
+ // We only want this functionality for clang.
+ if ty != clangType {
+ return false
+ }
value, _ := env.getenv("FORCE_DISABLE_WERROR")
return value != ""
}
diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go
index 0c43dbe0..d0054262 100644
--- a/compiler_wrapper/disable_werror_flag_test.go
+++ b/compiler_wrapper/disable_werror_flag_test.go
@@ -412,13 +412,21 @@ func TestAndroidDisableWerror(t *testing.T) {
// Disable werror ON
ctx.cfg.useLlvmNext = true
- if !shouldForceDisableWerror(ctx, ctx.cfg) {
+ if !shouldForceDisableWerror(ctx, ctx.cfg, gccType) {
+ t.Errorf("disable Werror not enabled for Android with useLlvmNext")
+ }
+
+ if !shouldForceDisableWerror(ctx, ctx.cfg, clangType) {
t.Errorf("disable Werror not enabled for Android with useLlvmNext")
}
// Disable werror OFF
ctx.cfg.useLlvmNext = false
- if shouldForceDisableWerror(ctx, ctx.cfg) {
+ if shouldForceDisableWerror(ctx, ctx.cfg, gccType) {
+ t.Errorf("disable-Werror enabled for Android without useLlvmNext")
+ }
+
+ if shouldForceDisableWerror(ctx, ctx.cfg, clangType) {
t.Errorf("disable-Werror enabled for Android without useLlvmNext")
}
})
@@ -426,12 +434,28 @@ func TestAndroidDisableWerror(t *testing.T) {
func TestChromeOSNoForceDisableWerror(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
- if shouldForceDisableWerror(ctx, ctx.cfg) {
+ if shouldForceDisableWerror(ctx, ctx.cfg, gccType) {
+ t.Errorf("disable Werror enabled for ChromeOS without FORCE_DISABLE_WERROR set")
+ }
+
+ if shouldForceDisableWerror(ctx, ctx.cfg, clangType) {
t.Errorf("disable Werror enabled for ChromeOS without FORCE_DISABLE_WERROR set")
}
})
}
+func TestChromeOSForceDisableWerrorOnlyAppliesToClang(t *testing.T) {
+ withForceDisableWErrorTestContext(t, func(ctx *testContext) {
+ if !shouldForceDisableWerror(ctx, ctx.cfg, clangType) {
+ t.Errorf("Disable -Werror should be enabled for clang.")
+ }
+
+ if shouldForceDisableWerror(ctx, ctx.cfg, gccType) {
+ t.Errorf("Disable -Werror should be disabled for gcc.")
+ }
+ })
+}
+
func TestClangTidyNoDoubleBuild(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
ctx.cfg.isAndroidWrapper = true