-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Reenable codecvt in the dylib. #73679
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
@llvm/pr-subscribers-libcxx Author: Mark de Wever (mordante) ChangesThe header is used in the dylib, this is not an issue at the moment since the dylib is built using C++23. Post release comments in #72496 seem to indicate this removal is an issue for Fuchsia, this is a test so see whether it fixes the issue for their builds. Full diff: https://github.com/llvm/llvm-project/pull/73679.diff 1 Files Affected:
diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt
index 7a363280d52127c..bdf4f7b6a201ee0 100644
--- a/libcxx/include/codecvt
+++ b/libcxx/include/codecvt
@@ -63,7 +63,7 @@ class codecvt_utf8_utf16
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
+#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -555,7 +555,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
+#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
|
@zeroomega @petrhosek can you test whether this fixes the issues on Fuchsia? |
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 LGTM if this fixes Fuchsia's issues.
I can confirm this patch fixed the build failure on windows runtime with libcxx. The build step now passed without issue.
|
Ah, it is still related, see the test failure message. @petrhosek and I discussed about the reason why this Fuchsia unrelated breakage wasn't caught by the upstream libcxx bots. It is likely due to the toolchain used when building libcxx and runtimes. In our case, we always use a relatively recent clang we built to build the ToT clang. The ToT clang will then be used to build the runtime. In upstream llvm bots, for runtime builds, it usually uses a last stable release clang to build the ToT runtime directly to reduce build time. In this case, the bug like this won't be caught until there is a new llvm stable release. I think for libcxx, at least there should be a few bots configured in a way that bots need to use ToT clang to build libcxx and corresponding runtimes for the host platform. Otherwise, breakage like this will be hide in dark. |
We do have a bot that runs all of our tests against a just-built Clang using the bootstrapping build, which should catch that. |
Do you have a link to that specific bots so we can take a look at the build steps and configurations? |
Here's a random run that succeeded with that bot: https://buildkite.com/llvm-project/libcxx-ci/builds/31767#018bfa05-2b78-4a7e-92c1-ff46e2e9fd9a. The bot has been using the same configuration for a while. We're having some infra-related issues with the bots so I didn't provide a link to the job for this specific patch, which failed spuriously. |
I just checked all 4 clang-cl bots (since this bug only happens on building windows runtime), all of them uses the clang-cl from path |
Ah, that's right, our bootstrapping build job runs on Linux. But regardless, I am really surprised that this type of issue would be caused by the version of Clang in use. Did you folks figure out the exact reason for the failure? |
I had a quick look at these failures and it seems these are Windows only tests.
I strongly expect the libc++ toolchain on our Windows CI does not use C++26. This is something we (libc++) need to check.
Based on the failures and that this patch fixed building the dylib I have a very strong impression Fuchsia builds libc++ in C++26 mode. Can you tell what the value of the __cplusplus` macro for your compiler is. (Regardless of that value we need to fix it, but I want to understand why it fails.) I'll look at an updated fix later today. |
We're trying to reproduce the issue locally, but I see
That's not something we set explicitly in our build, you can see all our CMake flags here: llvm-project/clang/cmake/caches/Fuchsia-stage2.cmake Lines 130 to 132 in 5e7e0d6
AFAICT this flag is coming from: llvm-project/libcxx/utils/libcxx/test/params.py Lines 107 to 120 in 5e7e0d6
On our builders this is going to select c++26 as the default value because with tip-of-tree Clang the following test succeeds:
$ clang++ -std=c++26 -x c++ /dev/null -fsyntax-only However, with Clang version that's used by libc++ Buildkite builders I get: $ clang -std=c++26 -x c++ /dev/null -fsyntax-only
error: invalid value 'c++26' in '-std=c++26' As consequence, the logic for selecting the default version will continue through the list of C++ version and try This likely explains why you haven't observed this issue but we do and it's down to our builder using the just-built Clang to compile libc++ tests. |
I believe we should be able to use the following in our CMake cache file as a temporary workaround: set(LIBCXX_TEST_PARAMS "std=c++23" CACHE STRING "") |
I just fetched the toolchain from the failed task I mentioned. By default, without supplying any std flag, the I belive what @petrhosek found out about how libcxx select c++ std is the reason why we are seeing the test failures. |
Thanks a lot for the analysis @petrhosek , this is extremely useful. So yeah the problem's on our side, basically the library fails to build in C++26 mode on Windows and we never noticed because our Windows bot is building as C++23. |
I'm quite puzzled, based on the
The first part of the dylib we would have found if any bot tried to build the dylib with C++26. The latest issues would require a Windows bot to test C++26. @zeroomega @petrhosek I just pushed another commit can you test whether that completely fixes the issue for you? |
@mordante I can confirm e60378bf3e56769134882356d587e7369dfac972 clears the test failure (and build failure as well) on Windows. As I mentioned in #72496 (comment) , The build failure is also due to the highest C++ level was picked by the build configuration. We might want to make sure only supported C++ level was used. |
The header is used in the dylib, this is not an issue at the moment since the dylib is built using C++23. Post release comments in llvm#72496 seem to indicate this removal is an issue for Fuchsia, this is a test so see whether it fixes the issue for their builds.
e60378b
to
8b85edb
Compare
@mordante CI passed. I added a comment to the effect that passing |
@petrhosek Your issues should be fixed now, I think. Please let us know if not. |
@@ -17,6 +17,9 @@ | |||
// REQUIRES: windows | |||
// UNSUPPORTED: no-wide-characters | |||
|
|||
// TODO: This should not be necessary |
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.
What work is needed to make this not necessary?
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.
Looks like get_wide_temp_file_name()
in libcxx/test/support/wide_temp_file.h
is using codecvt
when it shouldn't be.
We really shouldn't be depending on far away configuration options like LLVM_HAVE_LINK_VERSION_SCRIPT here. This patch simplifies the enablement of the linker scripts and as a result gets rid of an undesirable dependency on HandleLLVMOptions.cmake. As a drive-by, the patch also stops taking into account whether Python3 is available. This should have no bearing on whether we generate a linker script or not, which is required for correctness. If someone tries to build libc++ and generate a linker script but Python3 is not available, they should get an error instead of silently getting an incorrect installation of the library.
The header is used in the dylib, this is not an issue at the moment since the dylib is built using C++23.
Post release comments in #72496 seem to indicate this removal is an issue for Fuchsia, this is a test so see whether it fixes the issue for their builds.