[libcxx-commits] [PATCH] D65348: enable <atomic> header on systems without thread-support

Yves Delley via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 28 00:48:37 PDT 2019


burnpanck added a comment.

My reasoning is the following: If `_LIBCPP_ATOMIC_ONLY_USE_BUILTINS` were only implied by `_LIBCPP_FREESTANDING` but not by `_LIBCPP_HAS_NO_THREADS`, the following paradoxical situation would appear for platforms without threads:

- libc++ *with* `-ffreestanding` would be a conforming freestanding implementation, but not a conforming hosted implementation (no threads)
- libc++ *without* `-ffreestanding` would still not be a conforming hosted implementation, but now it wouldn't even be a conforming freestanding implementation (because atomics are now missing).

Thus, the flag `-ffreestanding`, whose purpose is to *lower* the conformance level actually leads to a *higher* conformance level than without! The standard requires atomics in all conforming cases, whereas it would allow to disable threads under `-ffreestanding` (but it doesn't require it).

To me, `-ffreestanding` currently is ill-specified and has no good use. As far as I understand, the requirements for freestanding implementations are strictly smaller than for hosted implementations, but allowing implementation-defined extension. A conforming freestanding implementation is allowed to be a conforming hosted implementation, but it is not required to be. Thus, it is not clear what `-ffreestanding` even should do. It could be understood that *lack of `-ffreestanding`* requests a fully conforming hosted implementation; in that case, libc++ should choke on any platform that does not support threads unless `-ffreestanding` is given.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65348/new/

https://reviews.llvm.org/D65348





More information about the libcxx-commits mailing list