This is an archive of the discontinued LLVM Phabricator instance.

Allow building without threads in standalone builds
ClosedPublic

Authored by matthewbauer on Apr 15 2019, 6:53 PM.

Details

Summary

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.

Diff Detail

Event Timeline

matthewbauer created this revision.Apr 15 2019, 6:53 PM

Can you please add context to the diff?

Added more context for CMakeLists.txt

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).

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

ldionne accepted this revision.Apr 16 2019, 2:49 PM

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.

This revision is now accepted and ready to land.Apr 16 2019, 2:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2020, 5:45 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript