This is an archive of the discontinued LLVM Phabricator instance.

[libc] Make clang-tidy use host compiler's resource dir.
ClosedPublic

Authored by PaulkaToast on May 19 2020, 7:20 PM.

Details

Summary

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.

Diff Detail

Event Timeline

PaulkaToast created this revision.May 19 2020, 7:20 PM

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?

PaulkaToast marked an inline comment as done.May 20 2020, 11:13 PM
PaulkaToast added inline comments.
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 (:

sivachandra accepted this revision.May 21 2020, 4:12 PM
sivachandra added inline comments.
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.

This revision is now accepted and ready to land.May 21 2020, 4:12 PM
PaulkaToast marked 2 inline comments as done.
PaulkaToast added inline comments.
libc/cmake/modules/LLVMLibCObjectRules.cmake
228

I tried it out and it doesn't seem too noisy to me. Thanks for the suggestion!

Harbormaster completed remote builds in B57609: Diff 265644.
This revision was automatically updated to reflect the committed changes.