Skip to content

Commit 07504af

Browse files
authored
[libc] Stop depending on .cpp files in libcxx_shared_headers library. (#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.
1 parent 749535b commit 07504af

File tree

5 files changed

+8
-28
lines changed

5 files changed

+8
-28
lines changed

libc/src/__support/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ add_header_library(
165165
DEPENDS
166166
.ctype_utils
167167
.str_to_num_result
168-
libc.src.errno.errno
168+
libc.hdr.errno_macros
169169
libc.src.__support.CPP.limits
170170
libc.src.__support.CPP.type_traits
171171
libc.src.__support.common
@@ -217,6 +217,7 @@ add_header_library(
217217
.str_to_integer
218218
.str_to_num_result
219219
.uint128
220+
libc.hdr.errno_macros
220221
libc.src.__support.common
221222
libc.src.__support.CPP.bit
222223
libc.src.__support.CPP.limits
@@ -226,7 +227,6 @@ add_header_library(
226227
libc.src.__support.macros.config
227228
libc.src.__support.macros.null_check
228229
libc.src.__support.macros.optimization
229-
libc.src.errno.errno
230230
)
231231

232232
add_header_library(

libc/src/__support/libc_assert.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
1010
#define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H
1111

12-
#include "src/__support/macros/config.h"
1312
#if defined(LIBC_COPT_USE_C_ASSERT) || !defined(LIBC_FULL_BUILD)
1413

1514
// The build is configured to just use the public <assert.h> API
@@ -25,6 +24,7 @@
2524
#include "src/__support/OSUtil/io.h"
2625
#include "src/__support/integer_to_string.h"
2726
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
27+
#include "src/__support/macros/config.h"
2828
#include "src/__support/macros/optimization.h" // For LIBC_UNLIKELY
2929

3030
namespace LIBC_NAMESPACE_DECL {

libc/src/__support/str_to_float.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
1616
#define LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H
1717

18+
#include "hdr/errno_macros.h" // For ERANGE
1819
#include "src/__support/CPP/bit.h"
1920
#include "src/__support/CPP/limits.h"
2021
#include "src/__support/CPP/optional.h"
@@ -31,7 +32,6 @@
3132
#include "src/__support/str_to_integer.h"
3233
#include "src/__support/str_to_num_result.h"
3334
#include "src/__support/uint128.h"
34-
#include "src/errno/libc_errno.h" // For ERANGE
3535

3636
#include <stdint.h>
3737

libc/src/__support/str_to_integer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
1616
#define LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H
1717

18+
#include "hdr/errno_macros.h" // For ERANGE
1819
#include "src/__support/CPP/limits.h"
1920
#include "src/__support/CPP/type_traits.h"
2021
#include "src/__support/CPP/type_traits/make_unsigned.h"
@@ -24,7 +25,6 @@
2425
#include "src/__support/macros/config.h"
2526
#include "src/__support/str_to_num_result.h"
2627
#include "src/__support/uint128.h"
27-
#include "src/errno/libc_errno.h" // For ERANGE
2828

2929
namespace LIBC_NAMESPACE_DECL {
3030
namespace internal {

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

+3-23
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,6 @@ libc_support_library(
841841
libc_support_library(
842842
name = "__support_libc_assert",
843843
hdrs = ["src/__support/libc_assert.h"],
844-
deps = [
845-
":__support_integer_to_string",
846-
":__support_macros_attributes",
847-
":__support_osutil_exit",
848-
":__support_osutil_io",
849-
],
850844
)
851845

852846
libc_support_library(
@@ -868,7 +862,7 @@ libc_support_library(
868862
":__support_ctype_utils",
869863
":__support_str_to_num_result",
870864
":__support_uint128",
871-
":errno",
865+
":hdr_errno_macros",
872866
],
873867
)
874868

@@ -892,7 +886,7 @@ libc_support_library(
892886
":__support_str_to_integer",
893887
":__support_str_to_num_result",
894888
":__support_uint128",
895-
":errno",
889+
":hdr_errno_macros",
896890
],
897891
)
898892

@@ -1590,21 +1584,6 @@ libc_support_library(
15901584

15911585
########################## externally shared targets ###########################
15921586

1593-
# TODO: Remove this once downstream users are migrated to libcxx_shared_headers.
1594-
libc_support_library(
1595-
name = "libc_external_common",
1596-
hdrs = glob(
1597-
["shared/*.h"],
1598-
exclude = ["shared/rpc_server.h"],
1599-
),
1600-
deps = [
1601-
":__support_common",
1602-
":__support_fputil_fp_bits",
1603-
":__support_str_to_float",
1604-
":__support_str_to_integer",
1605-
],
1606-
)
1607-
16081587
libc_header_library(
16091588
name = "libcxx_shared_headers",
16101589
hdrs = [
@@ -1911,6 +1890,7 @@ libc_support_library(
19111890
":__support_fputil_fma",
19121891
":__support_fputil_multiply_add",
19131892
":__support_fputil_polyeval",
1893+
":__support_integer_literals",
19141894
],
19151895
)
19161896

0 commit comments

Comments
 (0)