Error trying to build and use latest C++

I checked out the latest LLVM from git, and I built clang and libc++. Now I try to use a new feature like std::format, and I get this error below. What am I missing? (I’m on macOS 13.1)

main.cc:

#include <iostream>
#include <format>
int main() {
    int x = 10;
    auto str = std::format("Hello {}", x);
    std::cout << str << std::endl;
}

In the shell:

> llvm-project/build/bin/clang++ -isysroot `xcrun -sdk macosx --show-sdk-path` main.cc -fexperimental-library -std=c++2b
ld: library not found for -lc++experimental
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

I think I built this experimental library. (?)

ls -l ~/Dev/llvm-project/build/lib/libc++*             
-rwxr-xr-x  1 rob  staff  1076256 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++.1.0.dylib
lrwxr-xr-x  1 rob  staff       16 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++.1.dylib -> libc++.1.0.dylib
-rw-r--r--  1 rob  staff  1498016 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++.a
lrwxr-xr-x  1 rob  staff       14 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++.dylib -> libc++.1.dylib
-rwxr-xr-x  1 rob  staff   303968 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++abi.1.0.dylib
lrwxr-xr-x  1 rob  staff       19 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++abi.1.dylib -> libc++abi.1.0.dylib
-rw-r--r--  1 rob  staff   397688 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++abi.a
lrwxr-xr-x  1 rob  staff       17 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++abi.dylib -> libc++abi.1.dylib
-rw-r--r--  1 rob  staff     9432 Jan 22 21:12 /Dev/llvm-project/build/lib/libc++experimental.a

It suggests using -v, so here is what that shows.

"/usr/bin/ld" -demangle -lto_library /Dev/llvm-project/build/lib/libLTO.dylib -no_deduplicate 
   -dynamic -arch x86_64 -platform_version macos 13.0.0 13.1 
   -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk 
   -o a.out /var/folders/zm/mzv_wcgn0gn4xcj3z6vl4_cm0000gn/T/main-3fd4fa.o 
   -lc++ -lc++experimental -lSystem

See this discussion:

There is a secret flag.

I am already using -fexperimental-library, but it’s scrolled offscreen in my question.

If I add a -L /Dev/llvm-project/build/lib, then it compiles and crashes at runtime.

The runtime crash is below. I guess I need a way to tell it to use the new libc++, not the system one.

% ./a.out 
dyld[99664]: Symbol not found: __ZNSt3__18to_charsEPcS0_d
  Referenced from: <FB7ED4E5-CE11-39B0-8DD4-7D0917313A75> /Users/rob/Workspace/a.out
  Expected in:     <5C425EA0-066D-38B9-9DB4-8D3885D78B6B> /usr/lib/libc++.1.dylib