Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ load("@rules_python//python:defs.bzl", "py_binary")
load(
":libc_build_rules.bzl",
"libc_function",
"libc_header_library",
"libc_math_function",
"libc_support_library",
)
Expand Down Expand Up @@ -1589,6 +1590,7 @@ 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(
Expand All @@ -1603,6 +1605,21 @@ libc_support_library(
],
)

libc_header_library(
name = "libcxx_shared_headers",
hdrs = [
"shared/fp_bits.h",
"shared/str_to_float.h",
"shared/str_to_integer.h",
],
deps = [
":__support_common",
":__support_fputil_fp_bits",
":__support_str_to_float",
":__support_str_to_integer",
],
)

############################### errno ########################################

libc_support_library(
Expand Down
36 changes: 36 additions & 0 deletions utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,42 @@ def libc_release_library(
**kwargs
)

def libc_header_library(name, hdrs, deps = [], **kwargs):
"""Creates a header-only library to share libc functionality.

Args:
name: Name of the cc_library target.
hdrs: List of headers to be shared.
deps: The list of libc_support_library dependencies if any.
**kwargs: All other attributes relevant for the cc_library rule.
"""

# Combine sources from dependencies to create a single cc_library target.
native.filegroup(
name = name + "_hdr_deps",
srcs = [dep + "_srcs" for dep in deps],
)
native.cc_library(
name = name + "_textual_hdr_library",
textual_hdrs = [dep + "_textual_hdrs" for dep in deps],
)
native.cc_library(
name = name,
# Technically speaking, we should put _hdr_deps in srcs, as they are
# not a part of this cc_library interface. However, we keep it here to
# workaround the presence of .cpp files in _hdr_deps - we need to
# fix that and enforce their absence, since libc_header_library
# should be header-only and not produce any object files.
# See PR #133126 which tracks it.
hdrs = hdrs + [":" + name + "_hdr_deps"],
deps = [":" + name + "_textual_hdr_library"],
# copts don't really matter, since it's a header-only library, but we
# need proper -I flags for header validation, which are specified in
# libc_common_copts().
copts = libc_common_copts(),
**kwargs
)

def libc_math_function(
name,
additional_deps = None):
Expand Down