-
Notifications
You must be signed in to change notification settings - Fork 186
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
Copy Checked C headers to clang system header directory. #168
Conversation
This adds a CMake file for copying the Checked C headers into the clang system header directory as part of the clang build. This avoids people having to copy the Checked C header files to their specific project, which would be error prone and result in synchronization problems. It is a little clunky to store all of these header files in the clang system header directory because it includes wrapper files that are not needed by the compiler. This seems to be better and simpler than the alternatives, so we're using it. This updates all the samples in the Checked C repo to no longer use the full relative path the stdchecked.h. We can just rely on it being picked up as part of the system search path.
include/CMakeLists.txt
Outdated
) | ||
|
||
# Hack - compute the CLANG version from the LLVM version. The | ||
# CLANG_VERSION variable is not available at this during the build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing word "not available at this point during the build."
I've address the code review feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One proposed change, but it doesn't have to happen in this PR.
threads_checked.h | ||
time_checked.h | ||
_builtin_stdio_checked.h | ||
_builtin_string_checked.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead use files(GLOB files *.h)
which will pick up all header files in this directory, just in case we add more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cmake documentation advises against using GLOB: https://cmake.org/cmake/help/v3.9/command/file.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's infuriating, but i guess it means it's explicit when we add new headers.
// macros from interfering with explicit declarations of library functions. | ||
// It is legal to #undef a macro that isn't defined, so we don't need to | ||
// conditionalize this. | ||
#undef strncmp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i said, I'm happy with this fix 👍
This adds a CMake file for copying the Checked C headers into the
clang system header directory as part of the clang build. This avoids
people having to copy the Checked C header files to their specific project,
which would be error prone and result in synchronization problems. This
change also fixes an issue with strncmp on Linux by undefining a problematic
macro.
It is a little clunky to store all of these header files in the clang system
header directory because it includes wrapper files that are not needed
by the compiler. This seems to be better and simpler than the
alternatives, so we're using it.
This updates all the samples in the Checked C repo to no longer
use the full relative path the stdchecked.h. We can just rely on
it being picked up as part of the system search path.
This change has matching changes for the Checked C LLVM repo, the
Checked C clang repo, and the Checked C LLVM Test Suite Repo.
Testing:
x86 when the testing was pointed at the matching branches in all
the repos.