aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2020-02-26 17:59:58 -0800
committerGeorge Burgess <gbiv@chromium.org>2020-02-28 17:33:01 +0000
commitc3bb0cbac10890324c5004fd6d7819102a2e6995 (patch)
treefde36cf96f66ded8d3cacc10de9f97bceeb323d8
parentee7e22c6435048f1b37db4d944e3b6f4c65a77e5 (diff)
downloadtoolchain-utils-c3bb0cbac10890324c5004fd6d7819102a2e6995.tar.gz
When double-build-with-Wno-error, add -Wno-error=foo for -Werror=foo
This will gracefully handle cases where a warning enforced with -Werror got stricter in upstream. This change also needs updates to golden testdata. No additional tests added since this is covered by existing tests. Originally reviewed in https://android-review.googlesource.com/c/1244796. BUG=b:149836702 TEST=go test Change-Id: I94624deb258b15e131387377b99bfb1747dca1a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2079548 Tested-by: Pirama Arumuga Nainar <pirama@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
-rw-r--r--compiler_wrapper/disable_werror_flag.go12
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json6
-rw-r--r--compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json6
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json6
6 files changed, 31 insertions, 11 deletions
diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go
index 406fdef9..0d68d560 100644
--- a/compiler_wrapper/disable_werror_flag.go
+++ b/compiler_wrapper/disable_werror_flag.go
@@ -31,6 +31,16 @@ func getNewWarningsDir(env env, cfg *config) (dirName string, ok bool) {
return "", false
}
+func disableWerrorFlags(originalArgs []string) []string {
+ noErrors := []string{"-Wno-error"}
+ for _, flag := range originalArgs {
+ if strings.HasPrefix(flag, "-Werror=") {
+ noErrors = append(noErrors, strings.Replace(flag, "-Werror", "-Wno-error", 1))
+ }
+ }
+ return noErrors
+}
+
func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, originalCmd *command) (exitCode int, err error) {
originalStdoutBuffer := &bytes.Buffer{}
originalStderrBuffer := &bytes.Buffer{}
@@ -57,7 +67,7 @@ func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, origin
retryStderrBuffer := &bytes.Buffer{}
retryCommand := &command{
Path: originalCmd.Path,
- Args: append(originalCmd.Args, "-Wno-error"),
+ Args: append(originalCmd.Args, disableWerrorFlags(originalCmd.Args)...),
EnvUpdates: originalCmd.EnvUpdates,
}
retryExitCode, err := wrapSubprocessErrorWithSourceLoc(retryCommand,
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
index 248fcb4b..2393e71a 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/force_disable_werror.json
@@ -94,7 +94,8 @@
"-Wno-unknown-warning-option",
"main.cc",
"-Wno-implicit-int-float-conversion",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
]
}
}
@@ -159,7 +160,8 @@
"-Wno-unknown-warning-option",
"main.cc",
"-Wno-implicit-int-float-conversion",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
index f975f452..f796764a 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/force_disable_werror.json
@@ -136,7 +136,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",
@@ -233,7 +234,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",
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
index f975f452..f796764a 100644
--- a/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_llvmnext_golden/force_disable_werror.json
@@ -136,7 +136,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",
@@ -233,7 +234,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",
diff --git a/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
index 59dfb93e..078c05da 100644
--- a/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_hardened_noccache_golden/force_disable_werror.json
@@ -121,7 +121,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
]
}
}
@@ -204,7 +205,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
]
},
"stdout": "somemessage",
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json b/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
index 787ce95d..9787e8a6 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/force_disable_werror.json
@@ -112,7 +112,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",
@@ -193,7 +194,8 @@
"-B../../bin",
"-target",
"x86_64-cros-linux-gnu",
- "-Wno-error"
+ "-Wno-error",
+ "-Wno-error=poison-system-directories"
],
"env_updates": [
"CCACHE_BASEDIR=/usr/x86_64-cros-linux-gnu",