This is an archive of the discontinued LLVM Phabricator instance.

[sanitizers] fix test failing for -Wunused-command-line-argument
ClosedPublic

Authored by protze.joachim on Feb 16 2021, 1:52 AM.

Details

Summary

GotsanRuntimeCheck fails for me, because of unused command-line arguments in combination with the -Werror flag.
This build error blocks the check-all target.

I run into this issue during 12.0 testing, so I think this should also be backported.

Diff Detail

Event Timeline

protze.joachim requested review of this revision.Feb 16 2021, 1:52 AM
protze.joachim created this revision.

What is the unused argument? Maybe we should remove the unused argument instead?

FAILED: projects/compiler-rt/lib/tsan/CMakeFiles/GotsanRuntimeCheck 
cd /dev/shm/jprotze/llvm-project/compiler-rt/lib/tsan/go && env "CC=/home/pj416018/sw/UTIL/ccache/bin/clang " IN_TMPDIR=1 SILENT=1 /dev/shm/jprotze/llvm-project/compiler-rt/lib/tsan/go/buildgo.sh
clang-11: error: argument unused during compilation: '-I ../rtl' [-Werror,-Wunused-command-line-argument]
clang-11: error: argument unused during compilation: '-I ../..' [-Werror,-Wunused-command-line-argument]
clang-11: error: argument unused during compilation: '-I ../../sanitizer_common' [-Werror,-Wunused-command-line-argument]
clang-11: error: argument unused during compilation: '-I ../../../include' [-Werror,-Wunused-command-line-argument]

Removing those include directories causes issues in the same compilation step. I'm using ccache-swig as a compiler cache. Probably, this tool breaks the compilation steps further down but does not filter the arguments properly.

How about passing the CMAKE_C_FLAGS into the script? Because of ccache, I use the -Wno-unused-command-line-argument flags anyways.

dvyukov accepted this revision.Feb 16 2021, 11:19 PM

How about passing the CMAKE_C_FLAGS into the script? Because of ccache, I use the -Wno-unused-command-line-argument flags anyways.

This looks fine to me.

This revision is now accepted and ready to land.Feb 16 2021, 11:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2021, 12:21 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
thakis added a subscriber: thakis.Feb 18 2021, 4:52 PM

This breaks building with PGO: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8854980816661584704/+/steps/package_clang/0/stdout?format=raw

FAILED: projects/compiler-rt/lib/tsan/CMakeFiles/GotsanRuntimeCheck 
cd /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/tsan/go && env "CC=/b/s/w/ir/cache/builder/src/third_party/llvm-bootstrap-install/bin/clang " "EXTRA_CFLAGS=--gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -fprofile-instr-use=\"/b/s/w/ir/cache/builder/src/third_party/llvm-instrumented/profdata.prof\" -flto=thin -Wall -Wno-unused-parameter" IN_TMPDIR=1 SILENT=1 /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/tsan/go/buildgo.sh
error: Could not read profile "/b/s/w/ir/cache/builder/src/third_party/llvm-instrumented/profdata.prof": No such file or directory
1 error generated.

Mkay, they I guess we need to revert. Or, Joachim, do you have any ideas for an alternative fix? We could whitelist/blacklist flags from $EXTRA_CFLAGS... I can't think of anything better atm.

@thakis thanks for reverting the patch. I was offline over the weekend.

The new patch sets -Wno-error=unused-command-line-argument if -Wno-unused-command-line-argument or -Wno-error=unused-command-line-argument is in $CMAKE_C_FLAGS instead of passing CMAKE_C_FLAGS into the script.

dvyukov reopened this revision.Feb 22 2021, 9:38 AM
This revision is now accepted and ready to land.Feb 22 2021, 9:38 AM
dvyukov accepted this revision.Feb 22 2021, 9:38 AM

This is fine with me.