[bazel] Add support for building lldb (#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.
diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc
index 1d7cf4a..5a6d188 100644
--- a/utils/bazel/.bazelrc
+++ b/utils/bazel/.bazelrc
@@ -9,10 +9,16 @@
# Prevent invalid caching if input files are modified during a build.
build --experimental_guard_against_concurrent_changes
+# Automatically enable --config=(linux|macos|windows) based on the host
+build --enable_platform_specific_config
+
# In opt mode, bazel by default builds both PIC and non-PIC object files for
# tests vs binaries. We don't need this feature and it slows down opt builds
# considerably.
-build --force_pic
+# TODO: Remove platform specifics we're on bazel 7.x https://github.com/bazelbuild/bazel/issues/12439
+# Apple platforms always enable pic so this flag is unnecessary anyways
+build:linux --force_pic
+build:windows --force_pic
# Shared objects take up more space. With fast linkers and binaries that aren't
# super large, the benefits of shared objects are minimal.
@@ -34,6 +40,9 @@
# eventually become the default
common --incompatible_disallow_empty_glob
+# TODO: Remove once we move to bazel 7.x
+build --experimental_cc_shared_library
+
###############################################################################
# Options to select different strategies for linking potential dependent
# libraries. The default leaves it disabled.