Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -242,6 +242,7 @@ option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY "Build libc++ with an externalized threading library. This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) +option(LIBCXX_BAREMETAL "Build libc++ for baremetal targets." OFF) # Misc options ---------------------------------------------------------------- # FIXME: Turn -pedantic back ON. It is currently off because it warns @@ -708,6 +709,7 @@ config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) +config_define_if(LIBCXX_BAREMETAL _LIBCPP_BAREMETAL) if (LIBCXX_ABI_DEFINES) set(abi_defines) Index: include/atomic =================================================================== --- include/atomic +++ include/atomic @@ -550,7 +550,7 @@ #pragma GCC system_header #endif -#ifdef _LIBCPP_HAS_NO_THREADS +#if defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_BAREMETAL) #error is not supported on this single threaded system #endif #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) Index: test/libcxx/atomic_baremetal.sh.cpp =================================================================== --- /dev/null +++ test/libcxx/atomic_baremetal.sh.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Test that we can include with no threads while targeting baremetal. + +// RUN: %build -D_LIBCPP_HAS_NO_THREADS -D_LIBCPP_BAREMETAL +// RUN: %run + +#include + +int main() +{ +}