-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc++] First attempt to regroup a few modules in the modulemap #98214
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,11 @@ | |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// UNSUPPORTED: no-threads | ||
|
||
// XFAIL: availability-synchronization_library-missing | ||
|
||
// UNSUPPORTED: no-threads | ||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
// XFAIL: availability-synchronization_library-missing | ||
// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header | ||
|
||
#include <__stop_token/atomic_unique_lock.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we instead just add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can, but I think I'd rather add it on a per test basis to avoid making it too easy to include detail headers unknowingly. |
||
#include <atomic> | ||
|
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.
Shouldn't these still be submodules?
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.
I don't know? Is there a reason why we should prefer making it a submodule rather than listing private headers like this? Genuine question, I'm not an expert on Clang modules.
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.
Yes generally every header should be in its own submodule. Otherwise including
stop_token
when building with modules will implicitly include all of these headers as well, even ifstop_token
itself doesn't include them.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.
But
<stop_token>
does need these headers.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.
Well yes. The stop_token implementation headers are a bit unique in that stop_token itself directly includes all of them, and none of the other headers do. Something more typical is like __type_traits headers. You can't do like this.
algorithm
includes __type_traits/A.h it will also get type_traits and all of the other headers declared at the same level.algorithm
can't include __type_traits/A.h because it's private.So while this is fine for stop_token, it's going to unravel fast when you try to do some of the more significant ones.
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.
This seems like a surprising best practice. Aren't we trying to stop building so many small modules in the first place? The way I understand it:
stop_token
is a module, and it has both public APIs and private APIs, as denoted by the public/private headers declared in that moduletype_traits
is a module, but it has almost exclusively public headers because__type_traits/xxxxx.h
are meant to be included directly from other parts of the code.Either way -- we don't currently expect other parts of the code to include implementation details of
<stop_token>
. If they did, I would argue for moving these parts (e.g.intrusive_shared_ptr
) to another module that contains generally-useful utilities, or tomemory
, or something. But obviously<stop_token>
should stay a leaf module whatever happens, and in that sense I think it makes most sense to define it the way it is currently defined (with private headers).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.
Submodules only control visibility. If you make a submodule for all of the __stop_token headers, it'll still build all of them into a single pcm. It only controls what's visible when something includes __stop_token/atomic_unique_lock.h. i.e. if you have this.
Then std_stop_token builds the same as it does the way you have it right now and still cuts down on all the module builds/pcms. The difference is that if something includes __stop_token/atomic_unique_lock.h, then it behaves like non-modular C and you only get __stop_token/atomic_unique_lock.h. But the way you have it, if you build with modules then you also get stop_token and all of the other __stop_token headers, which is pretty unintuitive.
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 see, thanks for the clarification. This is clearly relevant for how to setup e.g.
type_traits
. However, forstop_token
, nobody outside of thestop_token
module can include__stop_token/atomic_unique_lock.h
, right?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 long as you keep it a
private
header, yes that's right.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 believe the original mega module had submodules for all of the implementation headers like I'm suggesting btw)