When building llvm-libc with linting enabled, clang-tidy would use the resource dir of the monorepo rather then the host compiler's resource dir. This presented issues when including headers from the host compiler e.g. for sanitizers. Therefore this patch explicitly tells clang-tidy to use the host compiler's resource dir.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I think I understand the problem with clang-tidy that you are trying to solve here. Also, I like the overall idea of this patch. But, see my inline comment.
libc/cmake/modules/LLVMLibCHeaderRules.cmake | ||
---|---|---|
131 | This fallback seems more confusing than useful. For example, will it find stddef.h from /usr/include or will it find stddef.h from the compiler's resource dir? Perhaps a better alternate is to compile a stub using the -E option and grep out the path to stddef.h. To keep it simple, may be we should just disable the header file check when we can't get the resource dir? One minor point, this check is really not a rule. So, can we just put this whole function not as a function in libc/CMakeLists.txt? |
libc/cmake/modules/LLVMLibCHeaderRules.cmake | ||
---|---|---|
131 | Yeah, I'm not the biggest fan of this fallback that's why I made the TODO. I liked the idea of disabling the check since most compiler do support the --print-resource-dir flag. As for where the rule lives I think your suggestion is good. I'll update the revision accordingly (: |
libc/CMakeLists.txt | ||
---|---|---|
87 | Can you move this to right before/after the linting related code. | |
libc/cmake/modules/LLVMLibCObjectRules.cmake | ||
228 | Instead of leaving it empty, may be: COMMAND ${CMAKE_COMMAND} -E echo "Header file check skipped" Not sure if it is going to get too noisy. Other option is to append this message to the COMMENT of the custom command. |
libc/cmake/modules/LLVMLibCObjectRules.cmake | ||
---|---|---|
228 | I tried it out and it doesn't seem too noisy to me. Thanks for the suggestion! |
Can you move this to right before/after the linting related code.