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
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ http_archive(
"@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
"@carbon//bazel/llvm_project:0003_Comment_out_unloaded_proto_library_dependencies.patch",
"@carbon//bazel/llvm_project:0004_Introduce_basic_sources_exporting_for_libunwind.patch",
"@carbon//bazel/llvm_project:0005_Introduce_basic_sources_exporting_for_libcxx_and_libcxxabi.patch",
"@carbon//bazel/llvm_project:0006_Add_a_filegroup_containing__all__sources_to_the_libc_build_rules.patch",
"@carbon//bazel/llvm_project:0007_Remove_target_compatibility_restrictions_for_float128.patch",
],
strip_prefix = "llvm-project-{0}".format(llvm_project_version),
urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
Expand Down
7 changes: 5 additions & 2 deletions bazel/check_deps/check_non_test_cc_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@
# Other packages in the LLVM project shouldn't be accidentally used
# in Carbon. We can expand the above list if use cases emerge.
if package not in (
"llvm",
"lld",
"clang",
"clang-tools-extra/clangd",
"libc",
"libcxx",
"libcxxabi",
"libunwind",
"lld",
"llvm",
# While this is in a `third_party` directory, its code is documented
# as part of LLVM and for use in compiler-rt.
"third-party/siphash",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Commit ID: e4ff7299fe7e35e70ba79f5d8e2c58658cfba678
Change ID: mstnwoqruyypnoouksnyqssllrsozpos
Bookmarks: bz-libcxx bz-libcxx@git bz-libcxx@origin
Author : Chandler Carruth <[email protected]> (2025-09-25 22:55:26)
Committer: Chandler Carruth <[email protected]> (2025-11-22 09:23:52)

Introduce basic sources exporting for libcxx and libcxxabi

This exports the source files directly so that they can be used to build
a libcxx runtime library on demand.

diff --git a/utils/bazel/llvm-project-overlay/libcxx/BUILD.bazel b/utils/bazel/llvm-project-overlay/libcxx/BUILD.bazel
new file mode 100644
index 0000000000..a81a64c649
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libcxx/BUILD.bazel
@@ -0,0 +1,49 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+licenses(["notice"])
+
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+exports_files(["include/__config_site.in"])
+
+exports_files(["vendor/llvm/default_assertion_handler.in"])
+
+filegroup(
+ name = "libcxx_hdrs",
+ srcs = glob(
+ [
+ # Top level includes and those in `experimental` and `ext` sometimes
+ # have no extension.
+ "include/*",
+ "include/experimental/*",
+ "include/ext/*",
+
+ # Implementation detail headers all use `.h` extensions
+ "include/**/*.h",
+ ],
+ exclude = [
+ # Omit CMake and CMake-configured files that get caught by the
+ # extension-less patterns.
+ "**/*.in",
+ "**/CMakeLists.txt",
+
+ # Omit C++03 compatibility headers as current users don't need them.
+ "include/__cxx03/**",
+ ],
+ ),
+)
+
+filegroup(
+ name = "libcxx_srcs",
+ srcs = glob(
+ [
+ "src/**/*.cpp",
+ "src/**/*.h",
+ "src/**/*.ipp",
+ ],
+ ),
+)
diff --git a/utils/bazel/llvm-project-overlay/libcxxabi/BUILD.bazel b/utils/bazel/llvm-project-overlay/libcxxabi/BUILD.bazel
new file mode 100644
index 0000000000..cf491e4e46
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libcxxabi/BUILD.bazel
@@ -0,0 +1,24 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+licenses(["notice"])
+
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+filegroup(
+ name = "libcxxabi_hdrs",
+ srcs = glob(["include/*.h"]),
+)
+
+filegroup(
+ name = "libcxxabi_srcs",
+ srcs = glob([
+ "src/**/*.cpp",
+ "src/**/*.def",
+ "src/**/*.inc",
+ "src/**/*.h",
+ ]),
+)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Commit ID: e524424ed32e945bdced8c19ca480f461d04397a
Change ID: lslousqwyovpkqlxvyrzmmypxkxxulwn
Bookmarks: push-lslousqwyovp push-lslousqwyovp@git push-lslousqwyovp@origin
Author : Chandler Carruth <[email protected]> (2025-11-20 03:05:36)
Committer: Chandler Carruth <[email protected]> (2025-11-22 09:23:52)

Add a filegroup containing _all_ sources to the libc build rules

These rules already expose a filegroup containing the _dependencies_,
but that misses the source files directly in the top level library.

Without this filegroup, there isn't a way to access the source files
used by libcxx when building it, etc.

diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index 0f2965369c..c871334dd9 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -247,6 +247,12 @@
**kwargs
)

+ _libc_srcs_filegroup(
+ name = name + "_hdrs",
+ libs = [":" + name],
+ enforce_headers_only = True,
+ )
+
def libc_generated_header(name, hdr, yaml_template, other_srcs = []):
"""Generates a libc header file from YAML template.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Commit ID: 94325bae07213d2dd8263945f5362720dee7bcb9
Change ID: kskkxwvnyqwuzkswkuxpnmyovqxoypnz
Bookmarks: push-kskkxwvnyqwu push-kskkxwvnyqwu@git push-kskkxwvnyqwu@origin
Author : Chandler Carruth <[email protected]> (2025-11-24 07:26:06)
Committer: Chandler Carruth <[email protected]> (2025-11-24 07:40:58)

Remove target compatibility restrictions for float128

The restrictions here aren't nearly as much about the OS as the compiler
and architecture, but the Bazel restriction was OS-based. Everything
seems to work well on even Arm64 macOS, and I would expect most BSDs and
other OSes to work well with Clang's support on x86-64.

The source code here already handles detecting when there is compiler
support for the type. And the users of this don't `select` or do
anything else to conditionally include the header, so it seems better to
not restrict access to the header from the build system, and instead
continue making the source code compatible or a no-op on relevant
configurations.

diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index bd48222856..e3962d9b5f 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -171,11 +171,6 @@
libc_support_library(
name = "llvm_libc_types_float128",
hdrs = ["include/llvm-libc-types/float128.h"],
- target_compatible_with = select({
- "@platforms//os:linux": [],
- "@platforms//os:windows": [],
- "//conditions:default": ["@platforms//:incompatible"],
- }),
deps = [":llvm_libc_macros_float_macros"],
)

22 changes: 17 additions & 5 deletions toolchain/base/runtime_sources.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ BUILTINS_FILEGROUPS = {
}

RUNTIMES_FILEGROUPS = {
"libunwind_srcs": "@llvm-project//libunwind:libunwind_srcs",
"libcxx": "@llvm-project//libcxx:libcxx_srcs",
"libcxxabi": "@llvm-project//libcxxabi:libcxxabi_srcs",
"libunwind": "@llvm-project//libunwind:libunwind_srcs",
}

_TEMPLATE = """
Expand Down Expand Up @@ -89,8 +91,16 @@ inline constexpr llvm::StringLiteral BuiltinsI386Srcs[] = {{
{i386_srcs}
}};
constexpr inline llvm::StringLiteral LibcxxSrcs[] = {{
{libcxx}
}};
constexpr inline llvm::StringLiteral LibcxxabiSrcs[] = {{
{libcxxabi}
}};
constexpr inline llvm::StringLiteral LibunwindSrcs[] = {{
{libunwind_srcs}
{libunwind}
}};
}} // namespace Carbon::RuntimeSources
Expand Down Expand Up @@ -118,14 +128,14 @@ def _get_path(file_attr, to_path_fn):

return '"{0}"'.format(to_path_fn(files[0]))

def _get_paths(files_attr, to_path_fn):
def _get_paths(files_attr, to_path_fn, prefix = ""):
files = []
for src in files_attr:
files.extend(src[DefaultInfo].files.to_list())
files.extend(src[DefaultInfo].default_runfiles.files.to_list())

return "\n".join([
' "{0}",'.format(to_path_fn(f))
' "{0}{1}",'.format(prefix, to_path_fn(f))
for f in files
])

Expand All @@ -138,7 +148,9 @@ def _generate_runtime_sources_h_rule(ctx):
k: _get_paths(getattr(ctx.attr, "_" + k), _builtins_path)
for k in BUILTINS_FILEGROUPS.keys()
} | {
k: _get_paths(getattr(ctx.attr, "_" + k), _runtimes_path)
# Other runtimes are installed under separate directories named the same
# as their key.
k: _get_paths(getattr(ctx.attr, "_" + k), _runtimes_path, k + "/")
for k in RUNTIMES_FILEGROUPS.keys()
})))
return [DefaultInfo(files = depset([h_file]))]
Expand Down
2 changes: 1 addition & 1 deletion toolchain/driver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ cc_test(

cc_test(
name = "clang_runtimes_test",
size = "small",
size = "medium",
srcs = ["clang_runtimes_test.cpp"],
data = ["//toolchain/install:install_data"],
deps = [
Expand Down
4 changes: 4 additions & 0 deletions toolchain/driver/build_runtimes_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ auto BuildRuntimesSubcommand::RunInternal(DriverEnv& driver_env)
ClangArchiveRuntimesBuilder<Runtimes::LibUnwind> lib_unwind_builder(
&runner, driver_env.thread_pool, llvm::Triple(features.target),
&runtimes);
ClangArchiveRuntimesBuilder<Runtimes::Libcxx> libcxx_builder(
&runner, driver_env.thread_pool, llvm::Triple(features.target),
&runtimes);

CARBON_RETURN_IF_ERROR(std::move(resource_dir_builder).Wait());
CARBON_RETURN_IF_ERROR(std::move(lib_unwind_builder).Wait());
CARBON_RETURN_IF_ERROR(std::move(libcxx_builder).Wait());

return runtimes.base_path();
}
Expand Down
Loading
Loading