-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libcxx] Remove the second inclusion of the system header #120946
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It had been done that way because the first
include_next <stdio.h>
could potentially be the target of a__need_size_t
macro (for example), which would result in the first inclusion only declaringsize_t
, not everything that should be instdio.h
.After your patch, I believe that the following might not work anymore:
That's because I'd assume
#include <stdio.h>
to only definesize_t
when it gets included after defining the macro. I would expect e.g.puts
to only be defined the second time aroundstdio.h
is included, which you removed.But if I'm wrong (and I'm happy to be), then I don't mind this patch.
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.
Isn't what you describe exactly the user asked for though? If we wanted to not support this we could just
#undef
all the__need_
macros and be done with it.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.
I think some system headers do rely on
__need
macros working though, that's why things broke when I attempted https://reviews.llvm.org/D131425.Take for example
wchar.h
. If it gets included with a__need
macro, our current implementation would fail because the C library'swchar.h
would not define e.g.wcsstr(...)
, but we use it in our implementation later in libc++'s ownwchar.h
. That's why I was including the header once again after the first time, with the intent that all required declarations would surely be available after including the C library'swchar.h
header for the second time.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.
Hm, that's indeed a problem. It doesn't seem to affect the CI though, which makes me wonder whether there's actually a
__need_
macro inwchar.h
orstdlib.h
(I couldn't find any in my glibc). Maybe this problem solved itself somehow?stddef.h
shouldn't be affected, since we don't actually use any of the libc-provided symbols instddef.h
directly.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.
@petrhosek What version of glibc were you folks using when you saw the issues in #119025?
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.
2.19
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.
We only support glibc 2.24 and above as documented in https://libcxx.llvm.org. Since this change is technically incorrect (as explained above), I'm not sure what to do with this. When are you moving away from glibc 2.19?
Uh oh!
There was an error while loading. Please reload this page.
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.
We support glibc 2.19 because some of the Linux binaries we build run in Android CI which still uses Ubuntu 14.04, so the answer is "Whenever Android CI stops using Ubuntu 14.04." According to https://wiki.ubuntu.com/Releases, Ubuntu 14.04 EOL is April 2026, so I expect it'll happen sometime before that, but I don't know if there's any date set already. @pirama-arumuga-nainar or @kongy might know 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.
I can't reproduce the issue I mentioned above. Since we're also not seeing any issues in our CI, let's leave things as-is but pay attention in case a bug report gets filed during the LLVM 20 release.