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

Copy Checked C headers to clang system header directory. #168

Merged
merged 4 commits into from
Jun 6, 2017

Conversation

dtarditi
Copy link
Contributor

@dtarditi dtarditi commented Jun 5, 2017

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:

  • Passed automation testing for Linux x64 LNT testing and Windows
    x86 when the testing was pointed at the matching branches in all
    the repos.

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.
)

# Hack - compute the CLANG version from the LLVM version. The
# CLANG_VERSION variable is not available at this during the build.
Copy link
Collaborator

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."

@dtarditi
Copy link
Contributor Author

dtarditi commented Jun 5, 2017

I've address the code review feedback.

Copy link
Collaborator

@lenary lenary left a 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
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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
Copy link
Collaborator

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 👍

@dtarditi dtarditi merged commit bbef5f7 into master Jun 6, 2017
@lenary lenary deleted the checkedc-headers branch June 6, 2017 00:09
@lenary lenary restored the checkedc-headers branch June 6, 2017 00:10
@dtarditi dtarditi deleted the checkedc-headers branch August 29, 2017 22:27
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

Successfully merging this pull request may close these issues.

None yet

3 participants