Skip to content

Commit 4b077ed

Browse files
authored
[bazel] Add support for building lldb (llvm#87589)
This adds build configuration for building LLDB on macOS and Linux. It uses a default subset of features that should work out of the box with macOS + Ubuntu. It is notably missing python support right now, although some of the scaffolding is there, because of the complexity of linking a python dylib, especially if you plan to distribute the resulting liblldb.so. Most of this build file is pretty simple, one of the unfortunate patterns I had to use was to split the header and sources cc_library targets to break circular dependencies.
1 parent 75e7e7d commit 4b077ed

File tree

5 files changed

+3289
-3
lines changed

5 files changed

+3289
-3
lines changed

utils/bazel/.bazelrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99
# Prevent invalid caching if input files are modified during a build.
1010
build --experimental_guard_against_concurrent_changes
1111

12+
# Automatically enable --config=(linux|macos|windows) based on the host
13+
build --enable_platform_specific_config
14+
1215
# In opt mode, bazel by default builds both PIC and non-PIC object files for
1316
# tests vs binaries. We don't need this feature and it slows down opt builds
1417
# considerably.
15-
build --force_pic
18+
# TODO: Remove platform specifics we're on bazel 7.x https://github.com/bazelbuild/bazel/issues/12439
19+
# Apple platforms always enable pic so this flag is unnecessary anyways
20+
build:linux --force_pic
21+
build:windows --force_pic
1622

1723
# Shared objects take up more space. With fast linkers and binaries that aren't
1824
# super large, the benefits of shared objects are minimal.
@@ -34,6 +40,9 @@ build --incompatible_no_implicit_file_export
3440
# eventually become the default
3541
common --incompatible_disallow_empty_glob
3642

43+
# TODO: Remove once we move to bazel 7.x
44+
build --experimental_cc_shared_library
45+
3746
###############################################################################
3847
# Options to select different strategies for linking potential dependent
3948
# libraries. The default leaves it disabled.

utils/bazel/configure.bzl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
"""Helper macros to configure the LLVM overlay project."""
66

7-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
8-
97
# Directory of overlay files relative to WORKSPACE
108
DEFAULT_OVERLAY_PATH = "llvm-project-overlay"
119

@@ -77,6 +75,7 @@ def _extract_cmake_settings(repository_ctx, llvm_cmake):
7775
"LLVM_VERSION_MAJOR": None,
7876
"LLVM_VERSION_MINOR": None,
7977
"LLVM_VERSION_PATCH": None,
78+
"LLVM_VERSION_SUFFIX": None,
8079
}
8180

8281
# It would be easier to use external commands like sed(1) and python.
@@ -126,6 +125,13 @@ def _extract_cmake_settings(repository_ctx, llvm_cmake):
126125
c["LLVM_VERSION_PATCH"],
127126
)
128127

128+
c["PACKAGE_VERSION"] = "{}.{}.{}{}".format(
129+
c["LLVM_VERSION_MAJOR"],
130+
c["LLVM_VERSION_MINOR"],
131+
c["LLVM_VERSION_PATCH"],
132+
c["LLVM_VERSION_SUFFIX"],
133+
)
134+
129135
return c
130136

131137
def _write_dict_to_file(repository_ctx, filepath, header, vars):

0 commit comments

Comments
 (0)