tools/build: tweak unused value workaround
PATCH 1/1 tools/build: tweak unused value workaround
Clang has -Wself-assign enabled by default under -Wall, which always gets -Werror'ed on this file, causing sync-compare-and-swap to be disabled by default. The generally-accepted way to spell "this value is intentionally unused," is casting it to void. This is accepted by both GCC and Clang with -Wall enabled: https://godbolt.org/z/qqZ9r3
--- tools/build/feature/test-sync-compare-and-swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/feature/test-sync-compare-and-swap.c +1 -1
@@ -7,7 +7,7 @@ int main(int argc, char *argv[]) {uint64_t old, new = argc; - argv = argv; + (void )argv;do { old =__sync_val_compare_and_swap (&x,0 ,0 ); }while (!__sync_bool_compare_and_swap (&x, old, new));
Signature · 1 line
2.26.0.110.g2183baf09c-goog
Quoted 6 lines · On Tue, 14 Apr 2020 12:56:38 -0700 George Burgess IV <[email protected]> wrote:
Clang has -Wself-assign enabled by default under -Wall, which always gets -Werror'ed on this file, causing sync-compare-and-swap to be disabled by default. The generally-accepted way to spell "this value is intentionally unused," is casting it to
void. This is accepted by both GCC and Clang with -Wall enabled: https://godbolt.org/z/qqZ9r3
What does "disabled by default" mean? Presumably it should now be enabled, but I don't think this disabling happens in the mainline kernel tree?
Quoted 3 lines · Andrew Morton
What does "disabled by default" mean? Presumably it should now be enabled, but I don't think this disabling happens in the mainline kernel tree?
Disabled when perf does its configure-ish checks. Concretely,
```
~/linux/tools/perf $ make V=1 VF=1 CC=$clang -f Makefile.perf notarget \
|& grep 'Auto-detecting\|sync-compare-and-swap'
Auto-detecting system features:
... sync-compare-and-swap: [ OFF ]
```