aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper
diff options
context:
space:
mode:
authorJian Cai <jiancai@google.com>2021-07-29 11:19:33 -0700
committerJian Cai <jiancai@google.com>2021-08-25 20:10:35 +0000
commit7d81944cccf39425fb02325706c5b33b950790c4 (patch)
treed7a42d4dba28c4f3510fa566f9b9503816ede56e /compiler_wrapper
parent751072756ae84a130ee63208a8c34c4521b57599 (diff)
downloadtoolchain-utils-7d81944cccf39425fb02325706c5b33b950790c4.tar.gz
compiler_wrapper: support -W[no-]unused-set-variable
BUG=b:194845241 TEST=emerge-atlas harfbuzz Change-Id: I262883ee20ed0fc69fcc3bf119d3068f4cf7729b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/3061363 Tested-by: Jian Cai <jiancai@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rw-r--r--compiler_wrapper/clang_flags.go7
-rw-r--r--compiler_wrapper/clang_flags_test.go3
-rw-r--r--compiler_wrapper/cros_hardened_config_test.go12
-rw-r--r--compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json126
-rw-r--r--compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json183
-rw-r--r--compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json156
6 files changed, 2 insertions, 485 deletions
diff --git a/compiler_wrapper/clang_flags.go b/compiler_wrapper/clang_flags.go
index c69d1b3d..84149bf6 100644
--- a/compiler_wrapper/clang_flags.go
+++ b/compiler_wrapper/clang_flags.go
@@ -63,11 +63,8 @@ func processClangFlags(builder *commandBuilder) error {
// Clang may use different options for the same or similar functionality.
gccToClang := map[string]string{
- "-Wno-error=cpp": "-Wno-#warnings",
- "-Wno-error=maybe-uninitialized": "-Wno-error=uninitialized",
- "-Wno-error=unused-but-set-variable": "-Wno-error=unused-variable",
- "-Wno-unused-but-set-variable": "-Wno-unused-variable",
- "-Wunused-but-set-variable": "-Wunused-variable",
+ "-Wno-error=cpp": "-Wno-#warnings",
+ "-Wno-error=maybe-uninitialized": "-Wno-error=uninitialized",
}
// Note: not using builder.transformArgs as we need to add multiple arguments
diff --git a/compiler_wrapper/clang_flags_test.go b/compiler_wrapper/clang_flags_test.go
index 7abbbb16..25c13c74 100644
--- a/compiler_wrapper/clang_flags_test.go
+++ b/compiler_wrapper/clang_flags_test.go
@@ -183,10 +183,7 @@ func TestConvertGccToClangFlags(t *testing.T) {
in string
out string
}{
- {"-Wno-error=unused-but-set-variable", "-Wno-error=unused-variable"},
{"-Wno-error=maybe-uninitialized", "-Wno-error=uninitialized"},
- {"-Wno-unused-but-set-variable", "-Wno-unused-variable"},
- {"-Wunused-but-set-variable", "-Wunused-variable"},
{"-Wno-error=cpp", "-Wno-#warnings"},
{"-Xclang-only=-abc=xyz", "-abc=xyz"},
}
diff --git a/compiler_wrapper/cros_hardened_config_test.go b/compiler_wrapper/cros_hardened_config_test.go
index fe9f0213..337b27fe 100644
--- a/compiler_wrapper/cros_hardened_config_test.go
+++ b/compiler_wrapper/cros_hardened_config_test.go
@@ -538,18 +538,6 @@ func createClangArgsGoldenInputs() goldenFile {
Cmds: okResults,
},
{
- WrapperCmd: newGoldenCmd(clangX86_64, "-Wno-error=unused-but-set-variable", mainCc),
- Cmds: okResults,
- },
- {
- WrapperCmd: newGoldenCmd(clangX86_64, "-Wno-unused-but-set-variable", mainCc),
- Cmds: okResults,
- },
- {
- WrapperCmd: newGoldenCmd(clangX86_64, "-Wunused-but-set-variable", mainCc),
- Cmds: okResults,
- },
- {
WrapperCmd: newGoldenCmd(clangX86_64, "-Xclang-only=-someflag", mainCc),
Cmds: okResults,
},
diff --git a/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
index 6d943c9c..01a50a96 100644
--- a/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_clang_host_golden/clang_specific_args.json
@@ -147,132 +147,6 @@
"cmd": {
"path": "./x86_64-cros-linux-gnu-clang",
"args": [
- "-Wno-error=unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/tmp/stable/clang",
- "args": [
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fuse-ld=lld",
- "-fdebug-default-version=5",
- "-Wno-unused-local-typedefs",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-Wno-unknown-warning-option",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-Wno-error=unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wno-unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/tmp/stable/clang",
- "args": [
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fuse-ld=lld",
- "-fdebug-default-version=5",
- "-Wno-unused-local-typedefs",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-Wno-unknown-warning-option",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-Wno-unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wunused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/tmp/stable/clang",
- "args": [
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fuse-ld=lld",
- "-fdebug-default-version=5",
- "-Wno-unused-local-typedefs",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-Wno-unknown-warning-option",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-Wunused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
"-Xclang-only=-someflag",
"main.cc"
]
diff --git a/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
index dd026196..f93c958b 100644
--- a/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_hardened_golden/clang_specific_args.json
@@ -204,189 +204,6 @@
"cmd": {
"path": "./x86_64-cros-linux-gnu-clang",
"args": [
- "-Wno-error=unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-fuse-ld=lld",
- "--unwindlib=libgcc",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-fstack-protector-strong",
- "-fPIE",
- "-pie",
- "-D_FORTIFY_SOURCE=2",
- "-fno-omit-frame-pointer",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wno-error=unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wno-unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-fuse-ld=lld",
- "--unwindlib=libgcc",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-fstack-protector-strong",
- "-fPIE",
- "-pie",
- "-D_FORTIFY_SOURCE=2",
- "-fno-omit-frame-pointer",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wno-unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wunused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fno-addrsig",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-fuse-ld=lld",
- "--unwindlib=libgcc",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-fcommon",
- "-fstack-protector-strong",
- "-fPIE",
- "-pie",
- "-D_FORTIFY_SOURCE=2",
- "-fno-omit-frame-pointer",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wunused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
"-Xclang-only=-someflag",
"main.cc"
]
diff --git a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
index 1c809647..2b73d51b 100644
--- a/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
+++ b/compiler_wrapper/testdata/cros_nonhardened_golden/clang_specific_args.json
@@ -177,162 +177,6 @@
"cmd": {
"path": "./x86_64-cros-linux-gnu-clang",
"args": [
- "-Wno-error=unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wno-error=unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wno-unused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wno-unused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
- "-Wunused-but-set-variable",
- "main.cc"
- ]
- }
- },
- "cmds": [
- {
- "cmd": {
- "path": "/usr/bin/ccache",
- "args": [
- "../../usr/bin/clang",
- "--sysroot=/usr/x86_64-cros-linux-gnu",
- "-Qunused-arguments",
- "-fdebug-default-version=5",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-Wno-final-dtor-non-final-class",
- "-Werror=poison-system-directories",
- "-fexperimental-new-pass-manager",
- "-Wno-compound-token-split-by-macro",
- "-Wno-deprecated-declarations",
- "-fcrash-diagnostics-dir=/tmp/stable/clang_crash_diagnostics",
- "-static-libgcc",
- "--prefix=../../bin/x86_64-cros-linux-gnu-",
- "-Wunused-variable",
- "main.cc",
- "-Wno-implicit-int-float-conversion",
- "-Wno-compound-token-split-by-space",
- "-Wno-string-concatenation",
- "-Wno-deprecated-copy",
- "-mno-movbe",
- "-B../../bin",
- "-target",
- "x86_64-cros-linux-gnu"
- ],
- "env_updates": [
- "CCACHE_DIR=/var/cache/distfiles/ccache",
- "CCACHE_UMASK=002",
- "CCACHE_CPP2=yes"
- ]
- }
- }
- ]
- },
- {
- "wd": "/tmp/stable",
- "wrapper": {
- "cmd": {
- "path": "./x86_64-cros-linux-gnu-clang",
- "args": [
"-Xclang-only=-someflag",
"main.cc"
]