Setting _LIBCPP_HAS_NO_THREADS is needed when building libcxxabi without threads in standalone mode. This is useful when target WASM. Otherwise, you get an error like "No thread API" when building libcxxabi.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rGda104444fafb: [libc++] Allow building without threads in standalone builds
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Why is this necessary? I just grepped the libc++abi sources, and I see no only two references to _LIBCPP_HAS_NO_THREADS, and they're both in comments (which should be fixed, btw, but that's neither here nor there).
libcxx headers are included by libcxxabi via LIBCXXABI_LIBCXX_INCLUDES. For instance "src/include/atomic_support.h" includes "__config" header here:
https://github.com/llvm-mirror/libcxxabi/blob/master/src/include/atomic_support.h#L16
The fact that we have to add this manually is unfortunate.
Better solution: define a CMake target representing the libc++ headers which has the right defines as part of its INTERFACE, and then have libc++abi link to these headers. Then have cxx_shared/cxx_static link to the headers AND to cxxabi_<shared|static>. Will refactor eventually, one thing at a time.