Skip to content

[clang] -ibuiltininc does not re-add builtin include paths if -nostdinc is specified #165790

@smallp-o-p

Description

@smallp-o-p

Link to CLI reference

-ibuiltininc
Enable builtin #include directories even when -nostdinc is used before or after -ibuiltininc. Using -nobuiltininc after the option disables it

Current behavior:

willtv@BLADEBLADEBLADE:~/foo$ clang-21 -ibuiltininc -nostdinc -v ./foo.c // ... clang-21: warning: argument unused during compilation: '-ibuiltininc' [-Wunused-command-line-argument] "/usr/lib/llvm-21/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name foo.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/willtv/foo -v -fcoverage-compilation-dir=/home/willtv/foo -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-21/lib/clang/21 -fdeprecated-macro -ferror-limit 19 -fmessage-length=80 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/foo-290858.o -x c++ ./foo.c clang -cc1 version 21.1.5 based upon LLVM 21.1.5 default target x86_64-pc-linux-gnu #include "..." search starts here: End of search list. ./foo.c:1:10: fatal error: 'stdatomic.h' file not found 1 | #include <stdatomic.h> | ^~~~~~~~~~~~~ 1 error generated. 

Example program:

#include <stdatomic.h> #include <stddef.h> #include <stdio.h> int main() { printf("Hello world!\n"); return 0; } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions