diff options
author | mobiletc-prebuild <mobiletc-prebuild@google.com> | 2024-02-15 08:00:21 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-02-15 16:36:24 +0000 |
commit | 674ee6b0ada0a5ce365ef8b30873cd6d286bce2d (patch) | |
tree | 762356af4b6711ab4cb983618e6f6d8897dfe057 | |
parent | f1aac8ff2488d24315f7c55f17af0e5009ce4524 (diff) | |
download | toolchain-utils-674ee6b0ada0a5ce365ef8b30873cd6d286bce2d.tar.gz |
compiler_wrapper: automatic sync
This CL automatically brings toolchain-utils' compiler_wrapper/
directory in sync with chromiumos-overlay's. Please see
go/crostc-repo/+/main:sync_compiler_wrapper_within_cros.sh for more info
on this process.
BUG=None
TEST=None
Change-Id: I8e43f915da44101b5b4a28d9fccb198ecdcac2cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5299664
Tested-by: mobiletc-prebuild Role Account <mobiletc-prebuild@google.com>
Reviewed-by: Bob Haarman <inglorion@chromium.org>
Commit-Queue: Bob Haarman <inglorion@chromium.org>
Auto-Submit: mobiletc-prebuild Role Account <mobiletc-prebuild@google.com>
-rw-r--r-- | compiler_wrapper/disable_werror_flag.go | 16 | ||||
-rw-r--r-- | compiler_wrapper/disable_werror_flag_test.go | 38 |
2 files changed, 47 insertions, 7 deletions
diff --git a/compiler_wrapper/disable_werror_flag.go b/compiler_wrapper/disable_werror_flag.go index 0546de9f..5382c1bd 100644 --- a/compiler_wrapper/disable_werror_flag.go +++ b/compiler_wrapper/disable_werror_flag.go @@ -43,11 +43,6 @@ func processForceDisableWerrorFlag(env env, cfg *config, builder *commandBuilder } } - // CrOS only wants this functionality for clang. - if builder.target.compilerType != clangType { - return forceDisableWerrorConfig{enabled: false} - } - // CrOS supports two modes for enabling this flag: // 1 (preferred). A CFLAG that specifies the directory to write reports to. e.g., // `-D_CROSTC_FORCE_DISABLE_WERROR=/path/to/directory`. This flag will be removed from the @@ -70,10 +65,19 @@ func processForceDisableWerrorFlag(env env, cfg *config, builder *commandBuilder return "" }) + // CrOS only wants this functionality to apply to clang, though flags should also be removed + // for GCC. + if builder.target.compilerType != clangType { + return forceDisableWerrorConfig{enabled: false} + } + if sawArg { return forceDisableWerrorConfig{ reportDir: argDir, - enabled: true, + // Skip this when in src_configure: some build systems ignore CFLAGS + // modifications after configure, so this flag must be specified before + // src_configure, but we only want the flag to apply to actual builds. + enabled: !isInConfigureStage(env), } } diff --git a/compiler_wrapper/disable_werror_flag_test.go b/compiler_wrapper/disable_werror_flag_test.go index 74e915e0..008c46ea 100644 --- a/compiler_wrapper/disable_werror_flag_test.go +++ b/compiler_wrapper/disable_werror_flag_test.go @@ -496,7 +496,20 @@ func TestChromeOSForceDisableWerrorWorksAsFlag(t *testing.T) { }) } -func TestChromeOSForceDisableWerrorRemovesFlags(t *testing.T) { +func TestChromeOSForceDisableWerrorIsSuppressedInSrcConfigure(t *testing.T) { + withForceDisableWErrorTestContext(t, func(ctx *testContext) { + ctx.env = append(ctx.env, "EBUILD_PHASE=configure") + builder := newWerrorCommandBuilderOrDie(t, ctx, commandBuilderOpts{ + cflags: []string{"-D_CROSTC_FORCE_DISABLE_WERROR=/foo"}, + }) + werrorConfig := processForceDisableWerrorFlag(ctx, ctx.cfg, builder) + if werrorConfig.enabled { + t.Fatalf("Disable -Werror should be disabled during src_configure.") + } + }) +} + +func TestChromeOSForceDisableWerrorRemovesClangFlags(t *testing.T) { withForceDisableWErrorTestContext(t, func(ctx *testContext) { builder := newWerrorCommandBuilderOrDie(t, ctx, commandBuilderOpts{ cflags: []string{ @@ -524,6 +537,29 @@ func TestChromeOSForceDisableWerrorRemovesFlags(t *testing.T) { }) } +func TestChromeOSForceDisableWerrorRemovesGCCFlagsButDoesNotEnableFeature(t *testing.T) { + withForceDisableWErrorTestContext(t, func(ctx *testContext) { + builder := newWerrorCommandBuilderOrDie(t, ctx, commandBuilderOpts{ + cflags: []string{ + "-D_CROSTC_FORCE_DISABLE_WERROR=/foo", + "-D_CROSTC_FORCE_DISABLE_WERROR=/bar", + "-Wfoo", + "-D_CROSTC_FORCE_DISABLE_WERROR=/baz", + }, + }) + builder.target.compilerType = gccType + werrorConfig := processForceDisableWerrorFlag(ctx, ctx.cfg, builder) + if werrorConfig.enabled { + t.Fatalf("Disable -Werror should not be enabled for GCC.") + } + + args := builder.build().Args + if want := []string{"-Wfoo"}; !reflect.DeepEqual(args, want) { + t.Errorf("Got builder args %#v; want %#v", args, want) + } + }) +} + func TestClangTidyNoDoubleBuild(t *testing.T) { withTestContext(t, func(ctx *testContext) { ctx.cfg.isAndroidWrapper = true |