Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy is missing since llvm-mingw 16 #429

Closed
wang-bin opened this issue May 31, 2024 · 7 comments
Closed

clang-tidy is missing since llvm-mingw 16 #429

wang-bin opened this issue May 31, 2024 · 7 comments

Comments

@wang-bin
Copy link

the last release contains clang-tidy is https://github.com/mstorsjo/llvm-mingw/releases/tag/20230320

@mstorsjo
Copy link
Owner

Yes; last year I switched the release process over to be built on github actions - this was discussed in #336. As part of tradeoffs done there, I decided to omit clang-tools-extra from the unix builds, to keep build times more manageable. (First I omitted LLDB as well, but that was requested back in #359.)

But since runner speeds have been increased since, I guess I could consider reenabling clang-tools-extra there as well, if there's a concrete demand for it. (I could also consider to only skip it from nightly builds, but perhaps it's not worth the complexity.)

@mstorsjo
Copy link
Owner

mstorsjo commented Jun 3, 2024

I pushed a fix for this now in 9b18842, so the next release should include clang-tidy on unix as well.

There is talks about a LLVM 18.1.7 release happening this week, so in that case, there'll be a new release soon that will include these tools.

@wang-bin
Copy link
Author

wang-bin commented Jun 3, 2024

thanks. i use clang-tidy to analyze my code on macos. llvm from homebrew can analyze mac and linux code, but i don't know how to use it for windows. llvm-mingw's clang-tidy can.

@mstorsjo
Copy link
Owner

mstorsjo commented Jun 7, 2024

The latest release, at https://github.com/mstorsjo/llvm-mingw/releases/tag/20240606, now should include clang-tidy in the unix packages too.

@wang-bin
Copy link
Author

wang-bin commented Jun 7, 2024

Thanks, it works. But I have problems when using it on macOS with cmake. cmake command is

cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=llvm-mingw.cmake -DLLVM_MINGW=/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal -DCMAKE_CXX_CLANG_TIDY=/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin/clang-tidy

Then I get build error:

[1/2 0.073 1]Building CXX object CMakeFiles/tidy.dir/main.cpp.obj
FAILED: CMakeFiles/tidy.dir/main.cpp.obj 
/opt/homebrew/Cellar/cmake/3.29.0/bin/cmake -E __run_co_compile --tidy="/Volumes/dev/llvm-mingw/bin/clang-tidy;--extra-arg-before=--driver-mode=g++" --source=/tmp/tidy/main.cpp -- /Volumes/dev/llvm-mingw/bin/aarch64-w64-mingw32-clang++   -gcodeview -MD -MT CMakeFiles/tidy.dir/main.cpp.obj -MF CMakeFiles/tidy.dir/main.cpp.obj.d -o CMakeFiles/tidy.dir/main.cpp.obj -c /tmp/tidy/main.cpp
/tmp/tidy/main.cpp:1:10: error: 'string' file not found [clang-diagnostic-error]
    1 | #include <string>
      |          ^~~~~~~~
1 error generated.
Error while processing /tmp/tidy/main.cpp.
Found compiler error(s).
ninja: build stopped: subcommand failed.

I add --extra-arg=-v for clang-tidy, i.e. cmake -E __run_co_compile --tidy="/Volumes/dev/llvm-mingw/bin/clang-tidy;--extra-arg-before=--driver-mode=g++;--extra-arg=-v" --source=/tmp/tidy/main.cpp -- /Volumes/dev/llvm-mingw/bin/aarch64-w64-mingw32-clang++ -gcodeview -MD -MT CMakeFiles/tidy.dir/main.cpp.obj -MF CMakeFiles/tidy.dir/main.cpp.obj.d -o CMakeFiles/tidy.dir/main.cpp.obj -c /tmp/tidy/main.cpp

the result is

/tmp/tidy/main.cpp:1:10: error: 'string' file not found [clang-diagnostic-error]
    1 | #include <string>
      |          ^~~~~~~~
clang version 18.1.7 (https://github.com/llvm/llvm-project.git 768118d1ad38bf13c545828f67bd6b474d61fc55)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin/../include/c++/v1"
ignoring nonexistent directory "/usr/include/c++/v1"
clang Invocation:
 "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin/clang-tool" "-cc1" "-triple" "arm64-apple-macosx14.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" "-fsyntax-only" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" "-fcompatibility-qualified-id-block-type-checking" "-fvisibility-inlines-hidden-static-local-var" "-fbuiltin-headers-in-system-modules" "-fdefine-target-os-macros" "-target-cpu" "apple-m1" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+v8.5a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+complxnum" "-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" "+fp16fml" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+pauth" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" "+sha3" "-target-feature" "+neon" "-target-abi" "darwinpcs" "-gno-column-info" "-gcodeview" "-debugger-tuning=lldb" "-fdebug-compilation-dir=/tmp/tidy/build" "-target-linker-version" "1015.7" "-v" "-fcoverage-compilation-dir=/tmp/tidy/build" "-resource-dir" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-fmax-type-align=16" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c++" "/tmp/tidy/main.cpp"

clang -cc1 version 18.1.7 based upon LLVM 18.1.7 default target arm64-apple-darwin23.4.0
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
1 error generated.
Error while processing /tmp/tidy/main.cpp.
Found compiler error(s).

We can see the default target triple is arm64-apple-macosx14.0.0, and clang-tool is invoked but infact it does not exist, is it right? I change the triple /opt/homebrew/Cellar/cmake/3.29.0/bin/cmake -E __run_co_compile --tidy="/Volumes/dev/llvm-mingw/bin/clang-tidy;--extra-arg-before=--driver-mode=g++;--extra-arg=--target=x86_64-w64-windows-gnu;--extra-arg=-v" --source=/tmp/tidy/main.cpp -- /Volumes/dev/llvm-mingw/bin/aarch64-w64-mingw32-clang++ -gcodeview -MD -MT CMakeFiles/tidy.dir/main.cpp.obj -MF CMakeFiles/tidy.dir/main.cpp.obj.d -o CMakeFiles/tidy.dir/main.cpp.obj -c /tmp/tidy/main.cpp but still get an error because "c++/v1" is not included in -internal-isystem

/tmp/tidy/main.cpp:1:10: error: 'string' file not found [clang-diagnostic-error]
    1 | #include <string>
      |          ^~~~~~~~
clang version 18.1.7 (https://github.com/llvm/llvm-project.git 768118d1ad38bf13c545828f67bd6b474d61fc55)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin
clang Invocation:
 "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/bin/clang-tool" "-cc1" "-triple" "x86_64-w64-windows-gnu" "-fsyntax-only" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "main.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-mms-bitfields" "-funwind-tables=2" "-fno-use-init-array" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-gno-column-info" "-gcodeview" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp/tidy/build" "-target-linker-version" "1015.7" "-v" "-fcoverage-compilation-dir=/tmp/tidy/build" "-resource-dir" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++/backward" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++/" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++//backward" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++/" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++//x86_64-w64-mingw32" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++//backward" "-internal-isystem" "include/c++" "-internal-isystem" "include/c++/x86_64-w64-mingw32" "-internal-isystem" "include/c++/backward" "-internal-isystem" "include/g++-v0.0.0" "-internal-isystem" "include/g++-v0.0.0/x86_64-w64-mingw32" "-internal-isystem" "include/g++-v0.0.0/backward" "-internal-isystem" "include/g++-v0.0" "-internal-isystem" "include/g++-v0.0/x86_64-w64-mingw32" "-internal-isystem" "include/g++-v0.0/backward" "-internal-isystem" "include/g++-v0" "-internal-isystem" "include/g++-v0/x86_64-w64-mingw32" "-internal-isystem" "include/g++-v0/backward" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18/include" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include" "-internal-isystem" "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/usr/include" "-fdeprecated-macro" "-ferror-limit" "19" "-fno-use-cxa-atexit" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions" "-exception-model=seh" "-faddrsig" "-x" "c++" "/tmp/tidy/main.cpp"

clang -cc1 version 18.1.7 based upon LLVM 18.1.7 default target arm64-apple-darwin23.4.0
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++/"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
ignoring nonexistent directory "include/g++-v0.0.0"
ignoring nonexistent directory "include/g++-v0.0.0/x86_64-w64-mingw32"
ignoring nonexistent directory "include/g++-v0.0.0/backward"
ignoring nonexistent directory "include/g++-v0.0"
ignoring nonexistent directory "include/g++-v0.0/x86_64-w64-mingw32"
ignoring nonexistent directory "include/g++-v0.0/backward"
ignoring nonexistent directory "include/g++-v0"
ignoring nonexistent directory "include/g++-v0/x86_64-w64-mingw32"
ignoring nonexistent directory "include/g++-v0/backward"
ignoring nonexistent directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/usr/include"
ignoring duplicate directory "/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++"
#include "..." search starts here:
#include <...> search starts here:
 /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include/c++
 /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/lib/clang/18/include
 /Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32/include
End of search list.
1 error generated.
Error while processing /tmp/tidy/main.cpp.
Found compiler error(s).

So I have to add more options for clang-tidy or cmake, finally this works /opt/homebrew/Cellar/cmake/3.29.0/bin/cmake -E __run_co_compile --tidy="/Volumes/dev/llvm-mingw/bin/clang-tidy;--extra-arg-before=--driver-mode=g++;--extra-arg=--target=x86_64-w64-windows-gnu;--extra-arg=-v;--extra-arg=--sysroot=/Volumes/dev/llvm-mingw-20240606-ucrt-macos-universal/x86_64-w64-mingw32;--extra-arg=-I=/include/c++/v1" --source=/tmp/tidy/main.cpp -- /Volumes/dev/llvm-mingw/bin/aarch64-w64-mingw32-clang++ -gcodeview -MD -MT CMakeFiles/tidy.dir/main.cpp.obj -MF CMakeFiles/tidy.dir/main.cpp.obj.d -o CMakeFiles/tidy.dir/main.cpp.obj -c /tmp/tidy/main.cpp

@mstorsjo
Copy link
Owner

mstorsjo commented Jun 7, 2024

Instead of specifying the libc++ include dir manually, pass -stdlib=libc++.

I haven't used clang-tidy myself, but I guess we'd need to provide wrappers that set these defaults, or use a toolchain file like in #430 to pass those parameters, if they get picked up from there and used with clang-tidy too.

@wang-bin
Copy link
Author

wang-bin commented Jun 7, 2024

-stdlib=libc++ works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants