Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/test/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ function(add_header_test target_name source_file deps std_mode)
${source_file}
COMPILE_OPTIONS
-Werror
-Wsystem-headers
-Wall
-Wextra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to be setting -Wsystem-headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to, but it shouldn't hurt. I'll try it.

These will only be considered "system headers" by the compiler if they're found in a directory that's put on the path with -isystem rather than -I or -idirafter or anything else. AFAICT we use -isystem for the clang headers (the ones copied from clang/lib/Headers) but not for our own. So if I'm right, then using -Wsystem-headers here will only make things fail if the clang headers are not warning-clean, not the libc headers. (I personally am a big fan of thorough warning-clean behavior and -Wsystem-headers, but many headers both in OS installs and perhaps clang and libc++ headers are not actually warning clean in my experience, unfortunately.) For the libc headers, -idirafter is actually the right thing to be using IMHO. But it only really matters to use that instead of -I if you're using toolchain-supplied libc++ headers, which the libc cmake build does not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wrong! I'm not sure yet how we're plumbing things, but we are getting the system header exception for the libc headers. And boy howdy do we need it! To start with, every file uses // comments that -std=c89 rejects. But there are many other issues that look like real bugs. So I think I will indeed turn it on, and the list of fixes needed to get these tests passing is even longer than we thought.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can recall, the use of <> vs "" for #include preprocessor directives changes one of the numbers in the generated line markers. Those control whether the diagnostic is considered from a system header or not. Unless -Wsystem-headers is set, such diagnostics are elided rather than emitted. There's a few other command line flags, a pragma, and specific system directories that can change this, too. I remember setting it once, seeing the additional diagnostics from my system headers, and thinking "ok, well, won't be fixing those any time soon, better leave that warning flag off for now..."

-std=${std_mode}
Expand Down
2 changes: 1 addition & 1 deletion libc/test/include/header-test-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
* See https://llvm.org/LICENSE.txt for license information.
* SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception
* SPDXList-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

#include <@HEADER_NAME@>
Expand Down
Loading