Skip to content

[libc] Add proxy header hdr/float-macros.h #88433

Closed
@lntue

Description

@lntue

Context: #87017

Similar PR: #87598, #87863.

Add a proxy header for float.h so that our implementations and tests will work nicely for both overlay and full build modes.

  • Add libc/hdr/float_macros.h that will include the system <float.h> in overlay mode or include libc/include/llvm-libc-macros/float-macros.h in full build mode.
  • Add its corresponding cmake targets in libc/hdr/CMakeLists.txt.
  • Remove the #include_next <float.h> in libc/include/llvm-libc-macros/float-macros.h and all the diagnostic suppression around it.
  • Move the filling-in parts such as
#ifndef FLT_RADIX
#define FLT_RADIX __FLT_RADIX__
#endif // FLT_RADIX

to the proxy header libc/hdr/float_macros.h in the overlay mode, after including the system <float.h>.

  • Change macro definitions in the full build header libc/include/llvm-libc-macros/float-macros.h to something like:
#ifdef __FLT_RADIX__
#define FLT_RADIX __FLT_RADIX__
#else
#define FLT_RADIX 2
#endif // FLT_RADIX
  • Change all the usage of include/llvm-libc-macros/float-macros.h to hdr/float_macros.h, and update the CMake dependency accordingly.
  • Add their corresponding bazel targets in utils/bazel/llvm-project-overlay/libc/BUILD.bazel.
  • Update bazel dependencies.
  • Test in overlay mode:
from "llvm-project/build":
$ cmake ../llvm -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=libc
$ ninja libc
$ ninja check-libc
  • Test in full build mode:
from "llvm-project/build":
$ cmake ../llvm -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="llvm;clang;compiler-rt;libc" -DLLVM_LIBC_INCLUDE_SCUDO=ON -DLLVM_LIBC_FULL_BUILD=ON
$ ninja libc
$ ninja check-libc
  • Test bazel build:
from "llvm-project/utils/bazel/"
$ bazel clean
$ bazel build --config=generic_clang --features=layering_check @llvm-project//libc/...
$ bazel test --config=generic_clang --features=layering_check @llvm-project//libc/...

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributelibc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions