-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[libcxx] Add a missing include for __bit_iterator #127015
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
Conversation
This is to fix compile error with explicit Clang modules like ``` ../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required 85 | typedef __bit_iterator<vector, false> pointer; | ^ ../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable 23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | ^ ```
@llvm/pr-subscribers-libcxx Author: Takuto Ikuta (atetubou) ChangesThis is to fix compile error with explicit Clang modules like
Full diff: https://github.com/llvm/llvm-project/pull/127015.diff 1 Files Affected:
diff --git a/libcxx/include/__vector/vector_bool.h b/libcxx/include/__vector/vector_bool.h
index 35f0f745e201c..714c86ae2bb96 100644
--- a/libcxx/include/__vector/vector_bool.h
+++ b/libcxx/include/__vector/vector_bool.h
@@ -18,6 +18,7 @@
#include <__bit_reference>
#include <__config>
#include <__functional/unary_function.h>
+#include <__fwd/bit_reference.h>
#include <__fwd/functional.h>
#include <__fwd/vector.h>
#include <__iterator/distance.h>
|
@ldionne We really need to make sure this type of issues is caught by the CI. |
@atetubou Thank you for the patches! |
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 is an incorrect fix. vector_bool.h
includes <__bit_reference>
, which actually defines __bit_iterator
.
@ian-twilightcoder Can you please take a look? |
@philnik777 Adding this include disappeared the error in our project. I'm still not sure when modules build can rely on indirect include and when not. Another way to remove the error is update modulemap config to export |
It's probably a fix. That doesn't mean it's the correct fix. Given that it should already be available, I don't think it's correct.
We already do that, so this is probably something more complicated. Let's see what Ian thinks. |
This is to fix compile error with explicit Clang modules like ``` ../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required 85 | typedef __bit_iterator<vector, false> pointer; | ^ ../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable 23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | ^ ```
I was looking at this a few days ago. I don't really understand the error, both the header includes and the module exports look like this should work as-is. However, explicit exports like libc++ does in its module map are not very well tested/kind of barely supported at all, so I'm not surprised that there are issues, especially with lsv. Mostly we've fixed these sorts of things by adding extra |
This is to fix compile error with explicit Clang modules like ``` ../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required 85 | typedef __bit_iterator<vector, false> pointer; | ^ ../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable 23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | ^ ```
This is to fix compile error with explicit Clang modules like ``` ../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required 85 | typedef __bit_iterator<vector, false> pointer; | ^ ../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable 23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | ^ ```
/cherry-pick 672e385 |
/pull-request #131382 |
@atetubou Do you have a reproducer for this issue? Can you please share it? |
I got this one to reproduce on macOS after updating libc++ in my SDK to the llvm 20 one.
If I use C++20 or later it no longer reproduces, which is very strange. |
I tried to create small repro case even with |
Thanks a lot @ian-twilightcoder. So what's going on here is that we don't have a CI job that tests the combination of C++17 AND clang modules with LSV enabled. Our LSV modules build was using C++23, which is kinda pointless since LSV is implied by C++ >= 20 nowadays (I learned that yesterday). If we wanted to have coverage for this, we could basically switch our clang-LSV build to use C++17 instead of removing it as I was planning to do in #131667. Edit: This is now #131815. |
I think I have a reduced reproducer. It looks like a Clang bug to me. This seems to depend on the order in which things are defined in the modulemap. I filed #131814 for this issue. In the meantime, I'll add a comment on the include that was added in this PR so it can be cleaned up when the Clang bug is fixed, or if we determine that another change in libc++ is required. |
Now that we have a better understanding of what's going on, I'd like to echo what @philnik777 said in #127015 (comment). We shouldn't fix things blindly by patching over them without understanding the root cause, especially when we do so without adding proper test coverage. I know those are just build issues so it may seem like a "simple hacky fix" is good enough, but it really isn't since this sort of technical debt compounds over years of development and gets us to a place where we don't understand our codebase anymore. Going forward, let's please try to go to the bottom of these kinds of issues, that's the only way we'll build something solid. |
That's what I was trying to say in #127015 (comment). lsv is a bit buggy, and it seems to get worse without |
@atetubou Did you encounter this issue while building with modules and LSV enabled? |
This is to fix compile error with explicit Clang modules like ``` ../../third_party/libc++/src/include/__vector/vector_bool.h:85:11: error: default argument of '__bit_iterator' must be imported from module 'std.bit_reference_fwd' before it is required 85 | typedef __bit_iterator<vector, false> pointer; | ^ ../../third_party/libc++/src/include/__fwd/bit_reference.h:23:68: note: default argument declared here is not reachable 23 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> | ^ ``` (cherry picked from commit 672e385)
@ldionne Yes, we use |
This is to fix compile error with explicit Clang modules like