-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc] Stop depending on .cpp files libcxx_shared_headers library. #133999
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fix two instances of libcxx_shared_headers depending on .cpp files (in Bazel build): * Don't depend on exit syscall in LIBC_ASSERT implementation. This dependency is not used, since LIBC_ASSERT always uses system <assert.h> in the overlay mode, which is the only mode supported by Bazel. * Don't depend on libc_errno in str-to-float and str-to-integer conversions. We only need the ERANGE value, which can be obtained from the proxy header instead.
@llvm/pr-subscribers-libc Author: Alexey Samsonov (vonosmas) ChangesFix two instances of libcxx_shared_headers depending on .cpp files (in Bazel build):
Full diff: https://github.com/llvm/llvm-project/pull/133999.diff 5 Files Affected:
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 17f03a6b6c4a0..f92499fdbf451 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -165,7 +165,7 @@ add_header_library(
DEPENDS
.ctype_utils
.str_to_num_result
- libc.src.errno.errno
+ libc.hdr.errno_macros
libc.src.__support.CPP.limits
libc.src.__support.CPP.type_traits
libc.src.__support.common
@@ -217,6 +217,7 @@ add_header_library(
.str_to_integer
.str_to_num_result
.uint128
+ libc.hdr.errno_macros
libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.limits
@@ -226,7 +227,6 @@ add_header_library(
libc.src.__support.macros.config
libc.src.__support.macros.null_check
libc.src.__support.macros.optimization
- libc.src.errno.errno
)
add_header_library(
diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index 3db179ff67212..ada1795ccb80a 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
#define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
-#include "src/__support/macros/config.h"
#if defined(LIBC_COPT_USE_C_ASSERT) || !defined(LIBC_FULL_BUILD)
// The build is configured to just use the public <assert.h> API
@@ -25,6 +24,7 @@
#include "src/__support/OSUtil/io.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
+#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // For LIBC_UNLIKELY
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h
index 48c88309c58e9..0748e1cb8a8b4 100644
--- a/libc/src/__support/str_to_float.h
+++ b/libc/src/__support/str_to_float.h
@@ -15,6 +15,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
#define LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
+#include "hdr/errno_macros.h" // For ERANGE
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/optional.h"
@@ -31,7 +32,6 @@
#include "src/__support/str_to_integer.h"
#include "src/__support/str_to_num_result.h"
#include "src/__support/uint128.h"
-#include "src/errno/libc_errno.h" // For ERANGE
#include <stdint.h>
diff --git a/libc/src/__support/str_to_integer.h b/libc/src/__support/str_to_integer.h
index 9212ad25d0820..76a99a8948941 100644
--- a/libc/src/__support/str_to_integer.h
+++ b/libc/src/__support/str_to_integer.h
@@ -15,6 +15,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
#define LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
+#include "hdr/errno_macros.h" // For ERANGE
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/CPP/type_traits/make_unsigned.h"
@@ -24,7 +25,6 @@
#include "src/__support/macros/config.h"
#include "src/__support/str_to_num_result.h"
#include "src/__support/uint128.h"
-#include "src/errno/libc_errno.h" // For ERANGE
namespace LIBC_NAMESPACE_DECL {
namespace internal {
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 77aa75362c71d..4d264b955cf66 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -841,12 +841,6 @@ libc_support_library(
libc_support_library(
name = "__support_libc_assert",
hdrs = ["src/__support/libc_assert.h"],
- deps = [
- ":__support_integer_to_string",
- ":__support_macros_attributes",
- ":__support_osutil_exit",
- ":__support_osutil_io",
- ],
)
libc_support_library(
@@ -868,7 +862,7 @@ libc_support_library(
":__support_ctype_utils",
":__support_str_to_num_result",
":__support_uint128",
- ":errno",
+ ":hdr_errno_macros",
],
)
@@ -892,7 +886,7 @@ libc_support_library(
":__support_str_to_integer",
":__support_str_to_num_result",
":__support_uint128",
- ":errno",
+ ":hdr_errno_macros",
],
)
@@ -1590,21 +1584,6 @@ libc_support_library(
########################## externally shared targets ###########################
-# TODO: Remove this once downstream users are migrated to libcxx_shared_headers.
-libc_support_library(
- name = "libc_external_common",
- hdrs = glob(
- ["shared/*.h"],
- exclude = ["shared/rpc_server.h"],
- ),
- deps = [
- ":__support_common",
- ":__support_fputil_fp_bits",
- ":__support_str_to_float",
- ":__support_str_to_integer",
- ],
-)
-
libc_header_library(
name = "libcxx_shared_headers",
hdrs = [
@@ -1911,6 +1890,7 @@ libc_support_library(
":__support_fputil_fma",
":__support_fputil_multiply_add",
":__support_fputil_polyeval",
+ ":__support_integer_literals",
],
)
|
jhuber6
approved these changes
Apr 1, 2025
lntue
approved these changes
Apr 1, 2025
michaelrj-google
approved these changes
Apr 1, 2025
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, thanks for the cleanup
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
Apr 2, 2025
…llvm#133999) Fix two instances of libcxx_shared_headers depending on .cpp files (in Bazel build): * Don't depend on exit syscall in LIBC_ASSERT implementation. This dependency is not used, since LIBC_ASSERT always uses system <assert.h> in the overlay mode, which is the only mode supported by Bazel. * Don't depend on libc_errno in str-to-float and str-to-integer conversions. We only need the ERANGE value, which can be obtained from the proxy header instead.
aheejin
added a commit
to aheejin/emscripten
that referenced
this pull request
May 15, 2025
aheejin
added a commit
to aheejin/emscripten
that referenced
this pull request
May 16, 2025
LLVM 20 release contains a bug that it one of the headers in `libc/src/__support` directory includes a header from `libc/src/errno`, which is not one of the header directories that are meant to be included: https://github.com/llvm/llvm-project/blob/ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e/libc/src/__support/str_to_float.h#L34 I was told (llvm/llvm-project#91651 (comment)) this was a bug that was fixed in llvm/llvm-project#133999. Whether this fix will be backported to later version of LLVM 20 release is unclear. To avoid importing files from `libc/src`, this applies the fix here as well.
aheejin
added a commit
to aheejin/emscripten
that referenced
this pull request
May 16, 2025
LLVM 20 release contains a bug that it one of the headers in `libc/src/__support` directory includes a header from `libc/src/errno`, which is not one of the header directories that are meant to be included: https://github.com/llvm/llvm-project/blob/ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e/libc/src/__support/str_to_float.h#L34 I was told (llvm/llvm-project#91651 (comment)) this was a bug that was fixed in llvm/llvm-project#133999. Whether this fix will be backported to later version of LLVM 20 release is unclear. To avoid importing files from `libc/src`, this applies the fix here as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix two instances of libcxx_shared_headers depending on .cpp files (in Bazel build):