-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc][bazel] Enable parse_headers feature for llvm-libc. #150538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
@llvm/pr-subscribers-libc Author: Alexey Samsonov (vonosmas) ChangesSee https://bazel.build/docs/bazel-and-cpp#toolchain-features for why this feature is recommended for C++ projects. 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:
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",
],
|
michaelrj-google
left a comment
There was a problem hiding this 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
rupprecht
left a comment
There was a problem hiding this 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.
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.