[libc-commits] [libc] [libc] force GCC limits.h to not include_next limits.h (PR #79211)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Tue Jan 23 15:22:16 PST 2024
nickdesaulniers wrote:
> Where is include_next that you're referring to?
Perhaps you were referring to:
https://github.com/llvm/llvm-project/blob/a16f81f5e3313e88f96de35e5edfe8bee463d308/clang/lib/Headers/limits.h#L21
Which indeed does pull in `<limits.h>` via an `include_next` if `__STDC_HOSTED__`. It then steamrolls these definitions via a large series of `#undefs`.
It seems that we also set `-ffreestanding` for fullbuild mode.
https://github.com/llvm/llvm-project/blob/a16f81f5e3313e88f96de35e5edfe8bee463d308/libc/cmake/modules/LLVMLibCObjectRules.cmake#L33-L35
> The idea was that we can't control GCC, so we'd do it in a header.
That's another approach we could take, which #78887 very nearly does, except:
1. it still uses `include_next` to include...who knows what (include_next depends on the compiler search path at compile time)...
2. it doesn't remove existing users of `<limits.h>`
Personally, I have a weak preference for "relying on the compiler (and it's resource dir)" a la this PR. But I could be convinced to not use ANY external dependency and just define these ourselves.
---
FWIW, clang's preprocessor also generates some of these defines. Example:
https://github.com/llvm/llvm-project/blob/a16f81f5e3313e88f96de35e5edfe8bee463d308/clang/lib/Frontend/InitPreprocessor.cpp#L1014-L1071
(besides the header file I linked to above)
https://github.com/llvm/llvm-project/pull/79211
More information about the libc-commits
mailing list