[clang] clang/limits.h: Avoid including limits.h twice (PR #120526)

YunQiang Su via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 17:32:39 PST 2025


wzssyqa wrote:

> I'm confused why this is necessary, we already work around glibc's quirk here:
> 
> https://github.com/llvm/llvm-project/blob/a15fedc399d5d1aa07c14531e5cd8d3efc583600/clang/lib/Headers/limits.h#L18
> 
> 
> which should then hit glibc's header guard here:
> https://sourceware.org/git/?p=glibc.git;a=blob;f=include/limits.h#l122

There are two problems:
* it makes the unittests of glibc unhappy when I am using clang to build glibc.
* If we build glibc on an none-glibc system, such as x86_64-linux-musl.
  - `#include </absolute/path/limits.h>`   import `/usr/lib/llvm-19/lib/clang/19/include/limits.h`
  - `/usr/lib/llvm-19/lib/clang/19/include/limits.h`   import `/usr/include/limits.h`
  - `/usr/include/limits.h` is from musl, which is not protected and it define duplicated macro with `</absolute/path/limits.h>`


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


More information about the cfe-commits mailing list