Skip to content

Commit f0b752e

Browse files
authored
[libc][bazel] Stop creatng "public" library targets in libc_function. (#132995)
All downstream users are migrated, so we no longer need to produce "public"/"release" cc_library target for each libc_function macro invocation. Instead, we only create internal target (for testing), and some filegroups, which will be picked up by the libc_release_library invocation. This allows us to get rid of "weak" argument to libc_function - this decision is also postponed to libc_release_library configuration. Fixes #130327.
1 parent 9606159 commit f0b752e

File tree

2 files changed

+5
-46
lines changed

2 files changed

+5
-46
lines changed

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ libc_support_library(
13191319
"src/__support/OSUtil/linux/aarch64/syscall.h",
13201320
"src/__support/OSUtil/linux/x86_64/syscall.h",
13211321
],
1322-
"@platforms//os:windows": [],
1322+
"@platforms//os:windows": [],
13231323
}),
13241324
deps = [
13251325
":__support_common",
@@ -1361,7 +1361,7 @@ libc_support_library(
13611361
textual_hdrs = select({
13621362
"@platforms//os:macos": ["src/__support/OSUtil/darwin/io.h"],
13631363
"@platforms//os:linux": ["src/__support/OSUtil/linux/io.h"],
1364-
"@platforms//os:windows": ["src/__support/OSUtil/windows/io.h"],
1364+
"@platforms//os:windows": ["src/__support/OSUtil/windows/io.h"],
13651365
}),
13661366
deps = [
13671367
":__support_common",
@@ -1885,8 +1885,8 @@ libc_support_library(
18851885
name = "inv_trigf_utils",
18861886
srcs = ["src/math/generic/inv_trigf_utils.cpp"],
18871887
hdrs = [
1888-
"src/math/generic/inv_trigf_utils.h",
18891888
"src/math/generic/atan_utils.h",
1889+
"src/math/generic/inv_trigf_utils.h",
18901890
],
18911891
deps = [
18921892
":__support_common",
@@ -4186,7 +4186,6 @@ libc_function(
41864186
name = "memcpy",
41874187
srcs = ["src/string/memcpy.cpp"],
41884188
hdrs = ["src/string/memcpy.h"],
4189-
weak = True,
41904189
deps = [
41914190
":__support_common",
41924191
":string_memory_utils",
@@ -4197,7 +4196,6 @@ libc_function(
41974196
name = "memset",
41984197
srcs = ["src/string/memset.cpp"],
41994198
hdrs = ["src/string/memset.h"],
4200-
weak = True,
42014199
deps = [
42024200
":__support_common",
42034201
":string_memory_utils",
@@ -4208,7 +4206,6 @@ libc_function(
42084206
name = "memmove",
42094207
srcs = ["src/string/memmove.cpp"],
42104208
hdrs = ["src/string/memmove.h"],
4211-
weak = True,
42124209
deps = [
42134210
":__support_common",
42144211
":string_memory_utils",
@@ -4219,7 +4216,6 @@ libc_function(
42194216
name = "mempcpy",
42204217
srcs = ["src/string/mempcpy.cpp"],
42214218
hdrs = ["src/string/mempcpy.h"],
4222-
weak = True,
42234219
deps = [
42244220
":__support_common",
42254221
":string_memory_utils",
@@ -4240,7 +4236,6 @@ libc_function(
42404236
name = "memcmp",
42414237
srcs = ["src/string/memcmp.cpp"],
42424238
hdrs = ["src/string/memcmp.h"],
4243-
weak = True,
42444239
deps = [
42454240
":__support_common",
42464241
":__support_integer_operations",
@@ -4252,7 +4247,6 @@ libc_function(
42524247
name = "bcmp",
42534248
srcs = ["src/strings/bcmp.cpp"],
42544249
hdrs = ["src/strings/bcmp.h"],
4255-
weak = True,
42564250
deps = [
42574251
":__support_common",
42584252
":string_memory_utils",
@@ -4263,7 +4257,6 @@ libc_function(
42634257
name = "bzero",
42644258
srcs = ["src/strings/bzero.cpp"],
42654259
hdrs = ["src/strings/bzero.h"],
4266-
weak = True,
42674260
deps = [
42684261
":__support_common",
42694262
":string_memory_utils",
@@ -4749,7 +4742,6 @@ libc_function(
47494742
name = "read",
47504743
srcs = ["src/unistd/linux/read.cpp"],
47514744
hdrs = ["src/unistd/read.h"],
4752-
weak = True,
47534745
deps = [
47544746
":__support_common",
47554747
":__support_macros_sanitizer",
@@ -4898,7 +4890,6 @@ libc_function(
48984890
name = "write",
48994891
srcs = ["src/unistd/linux/write.cpp"],
49004892
hdrs = ["src/unistd/write.h"],
4901-
weak = True,
49024893
deps = [
49034894
":__support_common",
49044895
":__support_osutil_syscall",
@@ -5359,7 +5350,6 @@ libc_function(
53595350
name = "socket",
53605351
srcs = ["src/sys/socket/linux/socket.cpp"],
53615352
hdrs = ["src/sys/socket/socket.h"],
5362-
weak = True,
53635353
deps = [
53645354
":__support_common",
53655355
":__support_osutil_syscall",
@@ -5371,7 +5361,6 @@ libc_function(
53715361
name = "socketpair",
53725362
srcs = ["src/sys/socket/linux/socketpair.cpp"],
53735363
hdrs = ["src/sys/socket/socketpair.h"],
5374-
weak = True,
53755364
deps = [
53765365
":__support_common",
53775366
":__support_osutil_syscall",
@@ -5383,7 +5372,6 @@ libc_function(
53835372
name = "send",
53845373
srcs = ["src/sys/socket/linux/send.cpp"],
53855374
hdrs = ["src/sys/socket/send.h"],
5386-
weak = True,
53875375
deps = [
53885376
":__support_common",
53895377
":__support_osutil_syscall",
@@ -5398,7 +5386,6 @@ libc_function(
53985386
name = "sendto",
53995387
srcs = ["src/sys/socket/linux/sendto.cpp"],
54005388
hdrs = ["src/sys/socket/sendto.h"],
5401-
weak = True,
54025389
deps = [
54035390
":__support_common",
54045391
":__support_osutil_syscall",
@@ -5413,7 +5400,6 @@ libc_function(
54135400
name = "sendmsg",
54145401
srcs = ["src/sys/socket/linux/sendmsg.cpp"],
54155402
hdrs = ["src/sys/socket/sendmsg.h"],
5416-
weak = True,
54175403
deps = [
54185404
":__support_common",
54195405
":__support_osutil_syscall",
@@ -5427,7 +5413,6 @@ libc_function(
54275413
name = "recv",
54285414
srcs = ["src/sys/socket/linux/recv.cpp"],
54295415
hdrs = ["src/sys/socket/recv.h"],
5430-
weak = True,
54315416
deps = [
54325417
":__support_common",
54335418
":__support_osutil_syscall",
@@ -5442,7 +5427,6 @@ libc_function(
54425427
name = "recvfrom",
54435428
srcs = ["src/sys/socket/linux/recvfrom.cpp"],
54445429
hdrs = ["src/sys/socket/recvfrom.h"],
5445-
weak = True,
54465430
deps = [
54475431
":__support_common",
54485432
":__support_osutil_syscall",
@@ -5457,7 +5441,6 @@ libc_function(
54575441
name = "recvmsg",
54585442
srcs = ["src/sys/socket/linux/recvmsg.cpp"],
54595443
hdrs = ["src/sys/socket/recvmsg.h"],
5460-
weak = True,
54615444
deps = [
54625445
":__support_common",
54635446
":__support_osutil_syscall",
@@ -5477,7 +5460,6 @@ libc_function(
54775460
"@platforms//os:linux": [],
54785461
"//conditions:default": ["@platforms//:incompatible"],
54795462
}),
5480-
weak = True,
54815463
deps = [
54825464
":__support_osutil_syscall",
54835465
":errno",
@@ -5492,7 +5474,6 @@ libc_function(
54925474
"@platforms//os:linux": [],
54935475
"//conditions:default": ["@platforms//:incompatible"],
54945476
}),
5495-
weak = True,
54965477
deps = [
54975478
":__support_osutil_syscall",
54985479
":errno",
@@ -5507,7 +5488,6 @@ libc_function(
55075488
"@platforms//os:linux": [],
55085489
"//conditions:default": ["@platforms//:incompatible"],
55095490
}),
5510-
weak = True,
55115491
deps = [
55125492
":__support_osutil_syscall",
55135493
":errno",
@@ -5524,7 +5504,6 @@ libc_function(
55245504
"@platforms//os:linux": [],
55255505
"//conditions:default": ["@platforms//:incompatible"],
55265506
}),
5527-
weak = True,
55285507
deps = [
55295508
":__support_macros_sanitizer",
55305509
":__support_osutil_syscall",
@@ -5544,7 +5523,6 @@ libc_function(
55445523
"@platforms//os:linux": [],
55455524
"//conditions:default": ["@platforms//:incompatible"],
55465525
}),
5547-
weak = True,
55485526
deps = [
55495527
":__support_macros_sanitizer",
55505528
":__support_osutil_syscall",
@@ -5564,7 +5542,6 @@ libc_function(
55645542
"@platforms//os:linux": [],
55655543
"//conditions:default": ["@platforms//:incompatible"],
55665544
}),
5567-
weak = True,
55685545
deps = [
55695546
":__support_macros_sanitizer",
55705547
":__support_osutil_syscall",

utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ def _libc_library_filegroups(
7777
# and ensure the consistent and tightly controlled set of flags
7878
# (see libc_common_copts and libc_release_copts above) is used to build
7979
# libc code both for tests and for release configuration.
80-
target_compatible_with = None, # @unused
81-
weak = False): # @unused
80+
target_compatible_with = None): # @unused
8281
"""Internal macro to collect sources and headers required to build a library.
8382
"""
8483

@@ -101,10 +100,7 @@ def libc_support_library(name, **kwargs):
101100
_libc_library(name = name, **kwargs)
102101
_libc_library_filegroups(name = name, is_function = False, **kwargs)
103102

104-
def libc_function(
105-
name,
106-
weak = False,
107-
**kwargs):
103+
def libc_function(name, **kwargs):
108104
"""Add target for a libc function.
109105
110106
This macro creates an internal cc_library that can be used to test this
@@ -114,7 +110,6 @@ def libc_function(
114110
Args:
115111
name: Target name. It is normally the name of the function this target is
116112
for.
117-
weak: Make the symbol corresponding to the libc function "weak".
118113
**kwargs: Other attributes relevant for a cc_library. For example, deps.
119114
"""
120115

@@ -128,19 +123,6 @@ def libc_function(
128123

129124
_libc_library_filegroups(name = name, is_function = True, **kwargs)
130125

131-
# TODO(PR #130327): Remove this after downstream uses are migrated to libc_release_library.
132-
# This second target is the llvm libc C function with default visibility.
133-
func_attrs = [
134-
"LLVM_LIBC_FUNCTION_ATTR_" + name + "='LLVM_LIBC_EMPTY, [[gnu::weak]]'",
135-
] if weak else []
136-
137-
_libc_library(
138-
name = name,
139-
copts = libc_release_copts(),
140-
local_defines = func_attrs,
141-
**kwargs
142-
)
143-
144126
def libc_release_library(
145127
name,
146128
libc_functions,

0 commit comments

Comments
 (0)