From 75be93453fa27d355c187f1eeddfe8a8870abed0 Mon Sep 17 00:00:00 2001 From: Parker Timmerman Date: Sun, 14 Jul 2024 23:59:02 -0400 Subject: [PATCH 1/2] include libunwind with the toolchain * add rules_foreign_cc 0.9.0 * add cmake(...) rule to BUILD.llvm-raw that builds libunwind * include libunwind.a in the disk --- BUILD | 1 + BUILD.llvm-raw | 23 +++++++++++++++++++++++ MODULE.bazel.lock | 19 +++++++++++++++++++ WORKSPACE | 11 +++++++++++ 4 files changed, 54 insertions(+) diff --git a/BUILD b/BUILD index 9cd9963e..09f849c2 100644 --- a/BUILD +++ b/BUILD @@ -55,6 +55,7 @@ DIST_FLAVORS = { ":bins" + suffix, "//:builtin_headers_pkg_files", "@llvm-raw//:libcxx_include", + "@llvm-raw//:unwind", ], empty_files = props.get("extra_empty_files", []), extension = ".tar.xz", diff --git a/BUILD.llvm-raw b/BUILD.llvm-raw index 6be9018c..32428ba0 100644 --- a/BUILD.llvm-raw +++ b/BUILD.llvm-raw @@ -1,5 +1,6 @@ package(default_visibility = ["//visibility:public"]) +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("@bazel_skylib//rules:copy_file.bzl", "copy_file") @@ -46,3 +47,25 @@ pkg_files( strip_prefix = "libcxx/include", prefix = "include/c++/v1", ) + +filegroup( + name = "llvm_srcs", + srcs = glob(["**"]), +) + +cmake( + name = "unwind", + lib_source = ":llvm_srcs", + working_directory = "llvm", + build_args = ["-j10"], + generate_args = [ + "-DCMAKE_BUILD_TYPE=Debug", + "-DLLVM_ENABLE_RUNTIMES=libunwind", + ], + postfix_script = """\ +cp ${BUILD_TMPDIR}/lib/libunwind.a ${INSTALLDIR}/lib + """, + targets = ["unwind"], + out_static_libs = ["libunwind.a"], + install = False, +) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index d0570c51..1a88eb7c 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1734,6 +1734,25 @@ ] } }, + "@@bazel_tools//tools/osx:xcode_configure.bzl%xcode_configure_extension": { + "general": { + "bzlTransitiveDigest": "Qh2bWTU6QW6wkrd87qrU4YeY+SG37Nvw3A0PR4Y0L2Y=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_xcode": { + "bzlFile": "@@bazel_tools//tools/osx:xcode_configure.bzl", + "ruleClassName": "xcode_autoconf", + "attributes": { + "name": "bazel_tools~xcode_configure_extension~local_config_xcode", + "xcode_locator": "@bazel_tools//tools/osx:xcode_locator.m", + "remote_xcode": "" + } + } + }, + "recordedRepoMappingEntries": [] + } + }, "@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { "general": { "bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=", diff --git a/WORKSPACE b/WORKSPACE index a487a500..58f21382 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,6 +16,17 @@ http_archive( ], ) +FOREIGN_CC_VERSION = "0.9.0" + +http_archive( + name = "rules_foreign_cc", + sha256 = "", + strip_prefix = "rules_foreign_cc-{version}".format(version = FOREIGN_CC_VERSION), + url = "https://github.com/bazelbuild/rules_foreign_cc/archive/{version}.tar.gz".format(version = FOREIGN_CC_VERSION), +) +load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") +rules_foreign_cc_dependencies() + LLVM_COMMIT = "26a1d6601d727a96f4301d0d8647b5a42760ae0c" # 18.1.2 http_archive( From 584b3b325622266e95818152d5bd28d8dadffd4c Mon Sep 17 00:00:00 2001 From: Parker Timmerman Date: Mon, 15 Jul 2024 00:04:36 -0400 Subject: [PATCH 2/2] configure for Release mode --- BUILD.llvm-raw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.llvm-raw b/BUILD.llvm-raw index 32428ba0..4926f601 100644 --- a/BUILD.llvm-raw +++ b/BUILD.llvm-raw @@ -59,7 +59,7 @@ cmake( working_directory = "llvm", build_args = ["-j10"], generate_args = [ - "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_BUILD_TYPE=Release", "-DLLVM_ENABLE_RUNTIMES=libunwind", ], postfix_script = """\