Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Regression: clang-tidy ignores -Wno-unknown-cuda-version and -Xcuda-ptxas #50612

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR51645
Status NEW
Importance P release blocker
Reported by Carlos Galvez (carlosgalvezp@gmail.com)
Reported on 2021-08-27 02:53:06 -0700
Last modified on 2021-09-08 00:53:15 -0700
Version unspecified
Hardware PC Linux
CC alexfh@google.com, carlosgalvezp@gmail.com, djasper@google.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Hi,

We are switching from clang-tidy 12 to 13, and have been using it successfully
to analyze our CUDA code.

However in version 13 clang-tidy ignores the following command-line argument:

clang-tidy foo.cu -- -Wno-unknown-cuda-version

error: Unknown CUDA version. version.txt: 10.2.311. Assuming the latest
supported version 10.1 [clang-diagnostic-unknown-cuda-version,-warnings-as-
errors]

It also fails to understand CUDA-specific flags, like -Xcuda-ptxas:

error: argument unused during compilation: '-Xcuda-ptxas -Werror' [clang-
diagnostic-unused-command-line-argument,-warnings-as-errors]

clang compiler, on the other hand, works fine for both flags.

Why is that?
Quuxplusone commented 3 years ago
The problem is not there if I run clang-tidy like this:

clang-tidy -checks=-*,cppcoreguidelines*,...

I.e. if I first disable all checks (-*) and then I add the ones I want.

Why would that be? I want to enable all checks by default and then opt-out of
the ones I'm not interested in. Maintaining a list of checks to opt-in is
tedious and easy to miss on good checks.
Quuxplusone commented 3 years ago
Hi again,

I've bisected the issue and it seems it was introduced in this commit:
2935737da32dd21bf02e1a3c912a340de660d557

Clang trunk doesn't have the issue with "cuda-diagnostic-unknown-cuda-version",
but still complains about "unused command-line" "-Xptxas -Werror".
Quuxplusone commented 3 years ago

Probably the reason why clang trunk no longer complains about "unknown cuda version" is that it now supports CUDA 11.4 and we are using 10.2.

Still I think disabling such a warning should work for clang-tidy. Would it be possible to add a unit test to run clang-tidy on CUDA code and prevent these issues in the future? I've seen also segfaults on some commits so I think it would be a good idea to have a test in place.