[clang] [Docs] Document freestanding requirements (PR #132232)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 26 11:31:10 PDT 2025


================
@@ -1073,6 +1073,28 @@ inputs. Here is some example of ``$``-prefixed options:
 Language and Target-Independent Features
 ========================================
 
+Freestanding Builds
+-------------------
+Passing the ``-ffreestanding`` flag causes Clang to build for a freestanding
+(rather than a hosted) environment. The flag has the following effects:
+
+* the ``__STDC_HOSTED__`` predefined macro will expand to ``0``,
+* builtin functions are disabled (``-fno-builtins``),
+* unwind tables are disabled (``fno-asynchronous-unwind-tables -fno-unwind-tables``), and
+* allows ``main`` to be used as a regular symbol.
+
+A freestanding environment is not one which has no C standard library support.
----------------
jyknight wrote:

I summarized the functionality required from a conforming freestanding implementation in a [previous comment](https://github.com/llvm/llvm-project/pull/132232#issuecomment-2741829501) on this PR.

I think we should also assume that future C standards may further increase the set of freestanding functions, towards inclusion of any function which doesn't require a runtime environment (e.g. memory allocator, system calls, or other global state).

https://github.com/llvm/llvm-project/pull/132232


More information about the cfe-commits mailing list