aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler_wrapper/compiler_wrapper.go4
-rw-r--r--compiler_wrapper/config.go5
-rw-r--r--compiler_wrapper/disable_werror_flag.go27
-rw-r--r--compiler_wrapper/disable_werror_flag_test.go44
4 files changed, 70 insertions, 10 deletions
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go
index c614b99f..11fd8199 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -108,14 +108,14 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int
}
rusageLogfileName := getRusageLogFilename(env)
bisectStage := getBisectStage(env)
- if shouldForceDisableWError(env) {
+ if newWarningsDir, ok := getNewWarningsDir(env, cfg); ok {
if rusageLogfileName != "" {
return 0, newUserErrorf("GETRUSAGE is meaningless with FORCE_DISABLE_WERROR")
}
if bisectStage != "" {
return 0, newUserErrorf("BISECT_STAGE is meaningless with FORCE_DISABLE_WERROR")
}
- return doubleBuildWithWNoError(env, cfg, compilerCmd)
+ return doubleBuildWithWNoError(env, cfg, newWarningsDir, compilerCmd)
}
if shouldCompileWithFallback(env) {
if rusageLogfileName != "" {
diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go
index 5f389684..70c27f06 100644
--- a/compiler_wrapper/config.go
+++ b/compiler_wrapper/config.go
@@ -14,6 +14,8 @@ type config struct {
isAndroidWrapper bool
// Whether to use ccache.
useCCache bool
+ // Whether llvmNext wrapper.
+ useLlvmNext bool
// Flags to add to gcc and clang.
commonFlags []string
// Flags to add to gcc only.
@@ -83,6 +85,7 @@ func getConfig(configName string, useCCache bool, useLlvmNext bool, version stri
return nil, newErrorwithSourceLocf("unknown config name: %s", configName)
}
cfg.useCCache = useCCache
+ cfg.useLlvmNext = useLlvmNext
if useLlvmNext {
cfg.clangFlags = append(cfg.clangFlags, llvmNextFlags...)
}
@@ -208,5 +211,5 @@ var androidConfig = &config{
gccFlags: []string{},
clangFlags: []string{},
clangPostFlags: []string{},
- newWarningsDir: "/tmp/fatal_clang_warnings",
+ newWarningsDir: "",
}
diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go
index 864397dd..406fdef9 100644
--- a/compiler_wrapper/disable_werror_flag.go
+++ b/compiler_wrapper/disable_werror_flag.go
@@ -9,16 +9,29 @@ import (
"encoding/json"
"io/ioutil"
"os"
+ "path"
"strings"
"syscall"
)
-func shouldForceDisableWError(env env) bool {
- value, _ := env.getenv("FORCE_DISABLE_WERROR")
- return value != ""
+func getNewWarningsDir(env env, cfg *config) (dirName string, ok bool) {
+ if cfg.isAndroidWrapper {
+ if cfg.useLlvmNext {
+ value, _ := env.getenv("OUT_DIR")
+ if value != "" {
+ return path.Join(value, "warnings_reports"), true
+ }
+ }
+ } else {
+ value, _ := env.getenv("FORCE_DISABLE_WERROR")
+ if value != "" {
+ return cfg.newWarningsDir, true
+ }
+ }
+ return "", false
}
-func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCode int, err error) {
+func doubleBuildWithWNoError(env env, cfg *config, newWarningsDir string, originalCmd *command) (exitCode int, err error) {
originalStdoutBuffer := &bytes.Buffer{}
originalStderrBuffer := &bytes.Buffer{}
// TODO: This is a bug in the old wrapper that it drops the ccache path
@@ -73,8 +86,8 @@ func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCo
defer syscall.Umask(oldMask)
// Allow root and regular users to write to this without issue.
- if err := os.MkdirAll(cfg.newWarningsDir, 0777); err != nil {
- return 0, wrapErrorwithSourceLocf(err, "error creating warnings directory %s", cfg.newWarningsDir)
+ if err := os.MkdirAll(newWarningsDir, 0777); err != nil {
+ return 0, wrapErrorwithSourceLocf(err, "error creating warnings directory %s", newWarningsDir)
}
// Have some tag to show that files aren't fully written. It would be sad if
@@ -85,7 +98,7 @@ func doubleBuildWithWNoError(env env, cfg *config, originalCmd *command) (exitCo
// Coming up with a consistent name for this is difficult (compiler command's
// SHA can clash in the case of identically named files in different
// directories, or similar); let's use a random one.
- tmpFile, err := ioutil.TempFile(cfg.newWarningsDir, "warnings_report*.json"+incompleteSuffix)
+ tmpFile, err := ioutil.TempFile(newWarningsDir, "warnings_report*.json"+incompleteSuffix)
if err != nil {
return 0, wrapErrorwithSourceLocf(err, "error creating warnings file")
}
diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go
index fb25d193..eb907e6b 100644
--- a/compiler_wrapper/disable_werror_flag_test.go
+++ b/compiler_wrapper/disable_werror_flag_test.go
@@ -11,6 +11,7 @@ import (
"io"
"io/ioutil"
"os"
+ "path"
"path/filepath"
"strings"
"testing"
@@ -372,3 +373,46 @@ func TestDoubleBuildWerrorChmodsThingsAppropriately(t *testing.T) {
}
})
}
+
+func TestAndroidGetNewWarningsDir(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ outDir := "/foo/bar"
+ expectedDir := path.Join(outDir, "warnings_reports")
+
+ ctx.env = []string{"OUT_DIR=" + outDir}
+ ctx.cfg.isAndroidWrapper = true
+
+ // Disable werror ON
+ ctx.cfg.useLlvmNext = true
+ dir, ok := getNewWarningsDir(ctx, ctx.cfg)
+ if !ok || dir != expectedDir {
+ t.Errorf("disable Werror not enabled for Android with useLlvmNext (dirName=%q ok=%t), expectedDir=%q", dir, ok, expectedDir)
+ }
+
+ // Disable werror OFF
+ ctx.cfg.useLlvmNext = false
+ dir, ok = getNewWarningsDir(ctx, ctx.cfg)
+ if ok || dir != "" {
+ t.Errorf("disable Werror incorrectly enabled for Android without useLlvmNext (dirName=%q ok=%t)", dir, ok)
+ }
+ })
+}
+
+func TestChromeOSGetNewWarningsDirOn(t *testing.T) {
+ withForceDisableWErrorTestContext(t, func(ctx *testContext) {
+ dir, ok := getNewWarningsDir(ctx, ctx.cfg)
+ if !ok || dir != ctx.cfg.newWarningsDir {
+ t.Errorf("disable Werror not enabled for ChromeOS with FORCE_DISABLE_WERROR set (dirName=%q ok=%t) expectedDir=%q", dir, ok, ctx.cfg.newWarningsDir)
+ }
+
+ })
+}
+
+func TestChromeOSGetNewWarningsDirOff(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ dir, ok := getNewWarningsDir(ctx, ctx.cfg)
+ if ok || dir != "" {
+ t.Errorf("disable Werror incorrectly enabled for ChromeOS without FORCE_DISABLE_WERROR set (dirName=%q ok=%t)", dir, ok)
+ }
+ })
+}