aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2020-04-01 12:48:13 -0700
committerGeorge Burgess <gbiv@chromium.org>2020-04-01 20:41:55 +0000
commitf34383b1f6ed0f9f0db1dfa729d6f8dcad67743a (patch)
tree07d2cbdf27bf20cc171a1301479794fbfe3bf76f /compiler_wrapper
parentafadccb836da9e84f0bc5cfcf5566ce8b1322272 (diff)
downloadtoolchain-utils-f34383b1f6ed0f9f0db1dfa729d6f8dcad67743a.tar.gz
compiler_wrapper: disable -Wno-error on conftest-y files
There are some ebuilds that (unfortunately) run configure steps inside of their regular `make` invocations. Rather than trying to fix those as they pop up, add a heuristic to our -Wno-error bits. This is similar to a heuristic goma added a while back when experimenting with full builds of CrOS using goma. BUG=None TEST=unittests Change-Id: I23efdc8ad5ea29621b105040bc33786896f6e486 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2132722 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rw-r--r--compiler_wrapper/disable_werror_flag.go16
-rw-r--r--compiler_wrapper/disable_werror_flag_test.go33
2 files changed, 48 insertions, 1 deletions
diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go
index 3decbf29..2800c5fa 100644
--- a/compiler_wrapper/disable_werror_flag.go
+++ b/compiler_wrapper/disable_werror_flag.go
@@ -41,6 +41,20 @@ func disableWerrorFlags(originalArgs []string) []string {
return noErrors
}
+func isLikelyAConfTest(cfg *config, cmd *command) bool {
+ // Android doesn't do mid-build `configure`s, so we don't need to worry about this there.
+ if cfg.isAndroidWrapper {
+ return false
+ }
+
+ for _, a := range cmd.Args {
+ if strings.HasPrefix(a, "conftest.c") {
+ return true
+ }
+ }
+ return false
+}
+
func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, originalCmd *command) (exitCode int, err error) {
originalStdoutBuffer := &bytes.Buffer{}
originalStderrBuffer := &bytes.Buffer{}
@@ -62,7 +76,7 @@ func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, origin
}
// The only way we can do anything useful is if it looks like the failure
// was -Werror-related.
- if originalExitCode == 0 || !bytes.Contains(originalStderrBuffer.Bytes(), []byte("-Werror")) {
+ if originalExitCode == 0 || !bytes.Contains(originalStderrBuffer.Bytes(), []byte("-Werror")) || isLikelyAConfTest(cfg, originalCmd) {
originalStdoutBuffer.WriteTo(env.stdout())
originalStderrBuffer.WriteTo(env.stderr())
return originalExitCode, nil
diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go
index bd4d376e..9d762599 100644
--- a/compiler_wrapper/disable_werror_flag_test.go
+++ b/compiler_wrapper/disable_werror_flag_test.go
@@ -71,6 +71,39 @@ func TestDoubleBuildWithWNoErrorFlag(t *testing.T) {
})
}
+func TestKnownConfigureFileParsing(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ for _, f := range []string{"conftest.c", "conftest.cpp"} {
+ if !isLikelyAConfTest(ctx.cfg, ctx.newCommand(clangX86_64, f)) {
+ t.Errorf("%q isn't considered a conf test file", f)
+ }
+ }
+ })
+}
+
+func TestDoubleBuildWithKnownConfigureFile(t *testing.T) {
+ withForceDisableWErrorTestContext(t, func(ctx *testContext) {
+ ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
+ switch ctx.cmdCount {
+ case 1:
+ if err := verifyArgCount(cmd, 0, "-Wno-error"); err != nil {
+ return err
+ }
+ fmt.Fprint(stderr, "-Werror originalerror")
+ return newExitCodeError(1)
+ default:
+ t.Fatalf("unexpected command: %#v", cmd)
+ return nil
+ }
+ }
+
+ ctx.mustFail(callCompiler(ctx, ctx.cfg, ctx.newCommand(clangX86_64, "conftest.c")))
+ if ctx.cmdCount != 1 {
+ t.Errorf("expected 1 call. Got: %d", ctx.cmdCount)
+ }
+ })
+}
+
func TestDoubleBuildWithWNoErrorAndCCache(t *testing.T) {
withForceDisableWErrorTestContext(t, func(ctx *testContext) {
ctx.cfg.useCCache = true