Linking errors with std::expected

Hello, I am having problems linking some test programs using std::expected. I am using LLVM 19.1.4 on macOS (homebrew) and when I link my library to some test code that does not explicitly use std::expected I get the following link errors.

Undefined symbols for architecture arm64:
  "std::__1::bad_expected_access<void>::what() const", referenced from:
      vtable for std::__1::bad_expected_access<dz::ErrorType> in tuple.test.cc.o
  "typeinfo for std::__1::bad_expected_access<void>", referenced from:
      typeinfo for std::__1::bad_expected_access<dz::ErrorType> in libdz.a[5](tuple.cc.o)
  "vtable for std::__1::bad_expected_access<void>", referenced from:
      std::__1::bad_expected_access<void>::bad_expected_access[abi:ne190104]() in tuple.test.cc.o
   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

Even when I declare a dummy variable std::bad_expected_access<dz::ErrorType> x{dz::ErrorType::None}; I get the same errors.

Do I need to declare something for the program to link or for std::bad_expected_access<void> to generate its vtable? std::bad_expected_access<void> has a protected constructor, can’t directly instantiate it.

These symbols should be in the dylib, so you’re probably not linking against the correct one assuming homebrew ships one. If homebrew doesn’t ship one it’s their bug that they don’t enable the availability markups for apple platforms. If the markups are enabled the symbols get emitted implicitly for now, since apple platforms don’t ship the symbols for expected yet.

This worked, if I directly put the correct dylib /opt/homebrew/Cellar/llvm/19.1.4/lib/c++/libc++.1.0.dylib into the link command it links and runs. I need to work out why the build system is not using the correct dylib.

Thanks.