Skip to content

Error building libcxx with recent LLVM due to -mthread-model posix default #173

@sunfishcode

Description

@sunfishcode
In file included from wasi-sdk/src/llvm-project/libcxx/src/barrier.cpp:9:
wasi-sdk/build/libcxx/include/c++/v1/__config:1195:2: error: _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
#error _LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
 ^

This appears to be related to how https://reviews.llvm.org/D58742 changed the configuration of clang to use -mthread-model posix by default, which now leads clang to predefine __STDCPP_THREADS__. That is then incompatible with our configuring libcxx with _LIBCPP_HAS_NO_THREADS, since libcxx doesn't like those two both being defined at the same time. But _LIBCPP_HAS_NO_THREADS is necessary here to avoid libcxx using features not supported by all relevant engines—atomics.

@tlively This now seems to be a case where defaulting to -mthread-model single would actually have the behavior we want here, and there aren't any other obvious options.

How difficult would it be to switch the clang wasm32 target back to -mthread-model single by default?

Alternatively, should we use custom target checks in libcxx to tell it that it's ok to disable threads support even if __STDCPP_THREADS__ is defined? Or, should we add custom checks to clang to avoid definint __STDCPP_THREADS__?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions