Linux: What is the status of libc++ in LLVM 15 apt packages (ranges, format)?

I installed the apt packages from here: https://apt.llvm.org/
I don’t get any ranges, std::format stuff. I’m I missing something?

[build] /usr/bin/clang++   -g -stdlib=libc++ -W -Wall -Werror -Wpedantic -std=c++2b -MD -MT CMakeFiles/ClangTest.dir/src/main.cpp.o -MF CMakeFiles/ClangTest.dir/src/main.cpp.o.d -o CMakeFiles/ClangTest.dir/src/main.cpp.o -c /home/hristo/Projects/ClangTest/src/main.cpp
[build] /home/hh/Projects/ClangTest/src/main.cpp:166:20: error: no member named 'views' in namespace 'std'
[build]        ints | std::views::filter(even) | std::views::transform(square)) {
[build]               ~~~~~^
[build] /home/hh/Projects/ClangTest/src/main.cpp:166:47: error: no member named 'views' in namespace 'std'
[build]        ints | std::views::filter(even) | std::views::transform(square)) {
[build]                                          ~~~~~^
[build] /home/hh/Projects/ClangTest/src/main.cpp:167:10: error: no member named 'format' in namespace 'std'
[build]     std::format("where am i? {}", "\n");
[build]     ~~~~~^

Pass -fexperimental-library to clang to enable functions that are not ABI stable yet.

Thank you. It was right there in the Release notes but I didn’t read them:

Clang now implements the -fexperimental-library flag. This flag can be used to enable experimental library features such as TSes and other in-progress work like <ranges> and <format>. Using this flag makes it unnecessary to manually link against libc++experimental.a – just use -fexperimental-library and the compiler will do what’s needed to make experimental features work. However, be aware that experimental features are not stable!

I can compile a minimal sample but I’m getting linker error with . Am I still missing something or should I report it>

[build] [1/2] Building CXX object CMakeFiles/ClangTest.dir/src/main.cpp.o
[build] [2/2] Linking CXX executable ClangTest
[build] FAILED: ClangTest 
[build] : && /usr/bin/clang++ -g -fuse-ld=lld -static -lc++ CMakeFiles/ClangTest.dir/src/main.cpp.o -o ClangTest   && :
[build] ld.lld: error: undefined symbol: typeinfo for std::__1::format_error
[build] >>> referenced by format_error.h:40 (/usr/lib/llvm-15/bin/../include/c++/v1/__format/format_error.h:40)
[build] >>>               CMakeFiles/ClangTest.dir/src/main.cpp.o:(std::__1::__throw_format_error[abi:v15000](char const*))
[build] 
[build] ld.lld: error: undefined symbol: std::__1::format_error::~format_error()
[build] >>> referenced by format_error.h:40 (/usr/lib/llvm-15/bin/../include/c++/v1/__format/format_error.h:40)
[build] >>>               CMakeFiles/ClangTest.dir/src/main.cpp.o:(std::__1::__throw_format_error[abi:v15000](char const*))
[build] 
[build] ld.lld: error: undefined symbol: vtable for std::__1::format_error
[build] >>> referenced by format_error.h:33 (/usr/lib/llvm-15/bin/../include/c++/v1/__format/format_error.h:33)
[build] >>>               CMakeFiles/ClangTest.dir/src/main.cpp.o:(std::__1::format_error::format_error[abi:v15000](char const*))
[build] >>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
[build] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[build] ninja: build stopped: subcommand failed.

Pass the same flag to the linker as well.

I have no success:

target_compile_features(${PROJECT_NAME}
  PRIVATE
    cxx_std_23
)

target_compile_options(${PROJECT_NAME}
  PRIVATE
    $<$<CXX_COMPILER_ID:GNU>:-fcoroutines>
    $<$<CXX_COMPILER_ID:Clang>:-stdlib=libc++ -fexperimental-library>
    $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-W -Wall -Werror -Wpedantic>
)
target_link_options(${PROJECT_NAME}
  PRIVATE
    $<$<CXX_COMPILER_ID:Clang>:-fuse-ld=lld -static -fexperimental-library -lc++>
)
[build] [1/1] Linking CXX executable ClangTest
[build] FAILED: ClangTest 
[build] : && /usr/bin/clang++ -g -fuse-ld=lld -static -fexperimental-library -lc++ CMakeFiles/ClangTest.dir/src/main.cpp.o -o ClangTest   && :
[build] ld.lld: error: undefined symbol: typeinfo for std::__1::format_error
[build] >>> referenced by format_error.h:40 (/usr/lib/llvm-15/bin/../include/c++/v1/__format/format_error.h:40)
[build] >>>               CMakeFiles/ClangTest.dir/src/main.cpp.o:(std::__1::__throw_format_error[abi:v15000](char const*))

On which system are you? I think it might not work yet on Windows, because there the experimental library isn’t built. (I might be wrong though)

Ubuntu 22.04 and I installed LLVM from:

https://apt.llvm.org/

To install all apt.llvm.org packages at once:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh all

or

sudo ./llvm.sh all

I wanted to test the progress. I can’t use std::format in production until it is supported by Xcode and gcc anyway. I use fmt.

Ooh, you statically link against libc++. You probably just have to add -lc++experimental.

Thank you! For the record this works:

target_compile_features (${PROJECT_NAME}
  PRIVATE
    cxx_std_23
)

target_compile_options (${PROJECT_NAME}
  PRIVATE
    $<$<CXX_COMPILER_ID:GNU>:-fcoroutines>
    $<$<CXX_COMPILER_ID:Clang>:-stdlib=libc++ -fexperimental-library>
    $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-W -Wall -Werror -Wpedantic>
)
target_link_options (${PROJECT_NAME}
  PRIVATE
    $<$<CXX_COMPILER_ID:Clang>:-fuse-ld=lld -static -lc++ -lc++experimental>
)

Is this information accurate: Using libc++ — libc++ 16.0.0git documentation

On compilers that do not support the -fexperimental-library flag, users can define the _LIBCPP_ENABLE_EXPERIMENTAL macro and manually link against the appropriate static library (usually shipped as libc++experimental.a) to get access to experimental library features.

Should be.