[flang-commits] [flang] [llvm] [flang] Use backend fp128 support to determine REAL(16) availability (PR #221907)
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Fri Sep 25 04:57:19 PDT 2026
Meinersbur wrote:
### Here is the AI output (Gemini)
No major C/C++ compiler automatically probes or detects missing runtime libraries at link time to disable language features.
Compilers operate in distinct phases: parsing and lowering happen upfront, while symbol resolution happens later during linking. If you write throw MyException(), GCC or Clang will emit the AST nodes, generate call instructions to runtime helper symbols like __cxa_throw, and pass the resulting object file to the linker. The compiler does not inspect whether libstdc++.a or libgcc_s.so is missing; it assumes the target ecosystem is intact. If it isn't, the build fails at the link step.
However, compilers and toolchains manage runtime library limitations through targeted flag modes and freestanding target profiles:
### Embedded & Bare-Metal Compilers (Keil, IAR, Arm Compiler)
Toolchains targeted at microcontroller development (such as Keil MDK or IAR Embedded Workbench) often split their runtimes into modular tiers (e.g., MicroLIB vs. Standard C/C++ Library).
If you configure the IDE/compiler driver to use MicroLIB (a reduced-footprint C runtime), the driver automatically passes flags to the front-end that disable features requiring full OS/runtime support—such as standard C file I/O (fopen), heap allocation, or locale support—or raises compile-time errors if you attempt to use them.
### Standard-Enforced Freestanding Modes (-ffreestanding)
C and C++ standards explicitly distinguish between hosted environments (full standard library available) and freestanding environments (OS-less, bare-metal).
Passing -ffreestanding to GCC or Clang tells the compiler that standard runtime headers and OS services may not be available.
In C++23, ISO standardized Freestanding C++, which formally restricts or disables runtime-dependent language and library features (like exceptions, dynamic allocation, and RTTI) in favor of a minimal header subset (<cstddef>, <type_traits>, <atomic>, etc.).
### Explicit Opt-Out Flags (The Standard Way)
Because compilers do not auto-detect missing libraries, developers must manually notify the compiler front-end when targeting an environment that lacks runtime support. The front-end then adjusts its codegen or throws a compile-time error instead of letting the program reach an undefined symbol linker error:
Missing Runtime Feature | Compiler Flag | What the Front-End Changes
-- | -- | --
Missing Exception Runtime (libstdc++/libc++abi) | -fno-exceptions | Turns throw into a compile error; removes exception tables/personality routines (__gxx_personality_v0).
Missing RTTI (typeid, dynamic_cast) | -fno-rtti | Omits vtable type-info pointers and disables typeid/dynamic_cast at compile time.
Missing Threading Libraries (libpthread) | -fno-threadsafe-statics | Stops emitting calls to __cxa_guard_acquire / __cxa_guard_release for local statics.
Missing libatomic | Target CPU flags (e.g., -march=native) | Instructs the compiler to emit direct hardware instructions instead of falling back to __atomic_* library calls.
https://github.com/llvm/llvm-project/pull/221907
More information about the flang-commits
mailing list