[libcxx-commits] [libcxx] [libc++] Reenable codecvt in the dylib. (PR #73679)

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 28 23:47:36 PST 2023


petrhosek wrote:

We're trying to reproduce the issue locally, but I see `-std=c++26` in the failing test output I see the following (you need to scroll to the right to see it since the command line is so long, or just search for `-std=c++26`):
```
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe C:\b\s\w\ir\x\w\github-mordante-llvm-project\libcxx\test\libcxx\input.output\file.streams\fstreams\ofstream.members\open_wchar_pointer.pass.cpp --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static -nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings  -llibc++experimental -nostdlib -L C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\input.output\file.streams\fstreams\ofstream.members\Output\open_wchar_pointer.pass.cpp.dir\t.tmp.exe
# executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 'C:\b\s\w\ir\x\w\github-mordante-llvm-project\libcxx\test\libcxx\input.output\file.streams\fstreams\ofstream.members\open_wchar_pointer.pass.cpp' --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static -nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety -Wuser-defined-warnings -llibc++experimental -nostdlib -L C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\input.output\file.streams\fstreams\ofstream.members\Output\open_wchar_pointer.pass.cpp.dir\t.tmp.exe'
# .---command stderr------------
# | In file included from C:\b\s\w\ir\x\w\github-mordante-llvm-project\libcxx\test\libcxx\input.output\file.streams\fstreams\ofstream.members\open_wchar_pointer.pass.cpp:23:
# | C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support\wide_temp_file.h:23:38: error: no member named 'codecvt_utf8_utf16' in namespace 'std'
# |    23 |     return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(get_temp_file_name());
# |       |                                 ~~~~~^
# | C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support\wide_temp_file.h:23:64: error: expected '(' for function-style cast or type construction
# |    23 |     return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(get_temp_file_name());
# |       |                                                         ~~~~~~~^
# | C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support\wide_temp_file.h:23:66: error: expected '(' for function-style cast or type construction
# |    23 |     return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(get_temp_file_name());
# |       |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
# | C:/b/s/w/ir/x/w/github-mordante-llvm-project/libcxx/test/support\wide_temp_file.h:23:68: error: expected expression
# |    23 |     return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(get_temp_file_name());
# |       |                                                                    ^
# | 4 errors generated.
# `-----------------------------
# error: command failed with exit status: 1
```
That's not something we set explicitly in our build, you can see all our CMake flags here: https://github.com/llvm/llvm-project/blob/5e7e0d603204ede803323a825318e365a87f73e9/clang/cmake/caches/Fuchsia-stage2.cmake#L130-L132

AFAICT this flag is coming from: https://github.com/llvm/llvm-project/blob/5e7e0d603204ede803323a825318e365a87f73e9/libcxx/utils/libcxx/test/params.py#L107-L120
On our builders this is going to select `c++26` as the default value because with tip-of-tree Clang the following test succeeds:
```bash
$ clang++ -std=c++26 -x c++ /dev/null -fsyntax-only
```
However, with Clang version that's used by libc++ Buildkite builders I get:
```bash
$ 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](https://github.com/llvm/llvm-project/blob/5e7e0d603204ede803323a825318e365a87f73e9/libcxx/utils/libcxx/test/params.py#L113) will continue through the list of C++ version and try `c++23` next, that test will succeed and because of [the replacement logic](https://github.com/llvm/llvm-project/blob/5e7e0d603204ede803323a825318e365a87f73e9/libcxx/utils/libcxx/test/params.py#L84) will pickup `c++2b` as the default version which is what I see in output of all libc++ Buildkite builders.

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.

https://github.com/llvm/llvm-project/pull/73679


More information about the libcxx-commits mailing list