Skip to content

Conversation

@vonosmas
Copy link
Contributor

See https://bazel.build/docs/bazel-and-cpp#toolchain-features for why this feature is recommended for C++ projects.
215dbcb added the necessary default Bazel flag to make this feature functional. It can be enabled on a per-project basis. Do this now for llvm-libc.

After enabling this feature, Blaze tries to parse headers from all header-only libraries, even if the headers are not explicitly used in tests, which allows to detect the issues early on.

Fix a couple of -Wunused-function warnings by marking the static functions as constexpr or inline.

See https://bazel.build/docs/bazel-and-cpp#toolchain-features for why
this feature is recommended for C++ projects.
215dbcb added the necessary default
Bazel flag to make this feature functional. It can be enabled on a
per-project basis. Do this now for llvm-libc.

After enabling this feature, Blaze tries to parse headers from all
header-only libraries, even if the headers are not explicitly used in
tests, which allows to detect the issues early on.

Fix a couple of -Wunused-function warnings by marking the static
functions as constexpr or inline.
@llvmbot llvmbot added libc bazel "Peripheral" support tier build system: utils/bazel labels Jul 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 24, 2025

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Changes

See https://bazel.build/docs/bazel-and-cpp#toolchain-features for why this feature is recommended for C++ projects.
215dbcb added the necessary default Bazel flag to make this feature functional. It can be enabled on a per-project basis. Do this now for llvm-libc.

After enabling this feature, Blaze tries to parse headers from all header-only libraries, even if the headers are not explicitly used in tests, which allows to detect the issues early on.

Fix a couple of -Wunused-function warnings by marking the static functions as constexpr or inline.


Full diff: https://github.com/llvm/llvm-project/pull/150538.diff

3 Files Affected:

  • (modified) libc/src/__support/math/exp.h (+1-1)
  • (modified) libc/src/math/generic/range_reduction_double_common.h (+1-1)
  • (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+1)
diff --git a/libc/src/__support/math/exp.h b/libc/src/__support/math/exp.h
index ff59ff79e3381..1b704117f3814 100644
--- a/libc/src/__support/math/exp.h
+++ b/libc/src/__support/math/exp.h
@@ -234,7 +234,7 @@ static double set_exceptional(double x) {
 
 namespace math {
 
-static double exp(double x) {
+static constexpr double exp(double x) {
   using FPBits = typename fputil::FPBits<double>;
   FPBits xbits(x);
 
diff --git a/libc/src/math/generic/range_reduction_double_common.h b/libc/src/math/generic/range_reduction_double_common.h
index f3dcdb937333c..a93ee25201813 100644
--- a/libc/src/math/generic/range_reduction_double_common.h
+++ b/libc/src/math/generic/range_reduction_double_common.h
@@ -278,7 +278,7 @@ struct LargeRangeReduction {
 };
 
 #ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-static Float128 range_reduction_small_f128(double x) {
+LIBC_INLINE static Float128 range_reduction_small_f128(double x) {
   constexpr Float128 PI_OVER_128_F128 = {
       Sign::POS, -133, 0xc90f'daa2'2168'c234'c4c6'628b'80dc'1cd1_u128};
   constexpr double ONE_TWENTY_EIGHT_OVER_PI_D = 0x1.45f306dc9c883p5;
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 38df25f58e4bf..7eaa45396be71 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -19,6 +19,7 @@ load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64")
 package(
     default_visibility = ["//visibility:public"],
     features = [
+        "parse_headers",
         "-use_header_modules",
         "-layering_check",
     ],

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one change

Copy link
Collaborator

@rupprecht rupprecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only complaint is that this should be enabled for all projects :)

But we can go w/ just libc for now, as an experiment. Let us know if you run into anything, and later we can enable it w/ build --features=parse_headers in .bazelrc.

@vonosmas vonosmas merged commit dc58a08 into llvm:main Jul 25, 2025
17 of 22 checks passed
@vonosmas vonosmas deleted the libc-bazel branch July 25, 2025 14:47
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
See https://bazel.build/docs/bazel-and-cpp#toolchain-features for why
this feature is recommended for C++ projects.
215dbcb added the necessary default
Bazel flag to make this feature functional. It can be enabled on a
per-project basis. Do this now for llvm-libc.

After enabling this feature, Blaze tries to parse headers from all
header-only libraries, even if the headers are not explicitly used in
tests, which allows to detect the issues early on.

Fix a couple of -Wunused-function warnings by marking the static
functions as constexpr or inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bazel "Peripheral" support tier build system: utils/bazel libc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants