[bazel] Set up windows specific cmake defines for lldb bazel build and config for LZMA (#205823)

Adds an @platforms//os:windows branch to the ConfigHeader
expand_template OS select(), alongside the
existing macos/linux branches. On Windows the POSIX-oriented features
are disabled (HAVE_PTSNAME_R,
LLDB_ENABLE_POSIX, LLDB_ENABLE_TERMIOS → 0) and the platform-detection
macros (HAVE_LIBCOMPRESSION,
HAVE_*_PROCESS_VM_READV, HAVE_PPOLL, HAVE_SYS_EVENT_H,
LLDB_ENABLE_LIBXML2, LLDB_HAVE_EL_RFUNC_T) are
set to their Windows values. This complements the recently added Windows
process plugin (#203146) so a
Windows-configured lldb gets a correct Config.h. Python stays disabled
on Windows (base default
  LLDB_ENABLE_PYTHON 0).

Continuing to work backwards from Meta's internally working buck2 build
that is translated from this bazel. This lacked windows select entirely,
so porting back what we ended up needing. There are still some changes
needed on the build targets, but leave those to a follow up diff as I
would hope build signals should be clean with this?
https://github.com/llvm/llvm-project/pull/201173 originally started full
windows support and there were more changes to get it working on a
remote build in

https://github.com/hermeticbuild/hermetic-llvm/pull/582/changes#diff-da3f010352329507a9e1e3f1dc911ae4ba69ba9747ce15e5eb76fbefe5f829b3.
If we look at
3rd_party/llvm-project/22.x/patches/lldb-windows-config-header.patch in
the previous patch, it lines up with what we have here.


Meta does package LZMA support into our windows build, so switching to a
config to control that.
This commit is contained in:
David Young 2026-07-22 17:16:19 -04:00 committed by GitHub
parent 8eb0419275
commit 2bc3ca68d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@build_bazel_apple_support//rules:apple_genrule.bzl", "apple_genrule")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library", "objc_library")
@ -70,6 +70,20 @@ selects.config_setting_group(
],
)
string_flag(
name = "lzma",
build_setting_default = "disable",
values = [
"disable",
"system",
],
)
config_setting(
name = "system_lzma_enabled",
flag_values = {":lzma": "system"},
)
_VERSION_SUBSTITUTIONS = {
"@LLDB_VERSION@": PACKAGE_VERSION,
"@LLDB_VERSION_MAJOR@": LLVM_VERSION_MAJOR,
@ -117,9 +131,6 @@ expand_template(
"#cmakedefine01 HAVE_PTSNAME_R": "#define HAVE_PTSNAME_R 1",
"#cmakedefine01 LLDB_ENABLE_TERMIOS": "#define LLDB_ENABLE_TERMIOS 1",
# TODO: Add LZMA support by including the library in bazel
"#cmakedefine01 LLDB_ENABLE_LZMA": "#define LLDB_ENABLE_LZMA 0",
# TODO: lua support
"#cmakedefine01 LLDB_ENABLE_LUA": "#define LLDB_ENABLE_LUA 0",
@ -173,6 +184,23 @@ expand_template(
"#cmakedefine01 LLDB_ENABLE_LIBXML2": "#define LLDB_ENABLE_LIBXML2 0",
"#cmakedefine01 LLDB_HAVE_EL_RFUNC_T": "#define LLDB_HAVE_EL_RFUNC_T 1",
},
"@platforms//os:windows": {
# Self-contained dist: liblldb resolves a relative LLDB_PYTHON_HOME
# against its own dir when LLDB_EMBED_PYTHON_HOME=1. Inert until
# Python is enabled, but kept so the Windows config matches the MSDK build.
"#cmakedefine LLDB_PYTHON_HOME R\"(${LLDB_PYTHON_HOME})\"": "#define LLDB_PYTHON_HOME \"../python\"",
"#cmakedefine01 HAVE_LIBCOMPRESSION": "#define HAVE_LIBCOMPRESSION 0",
"#cmakedefine01 HAVE_NR_PROCESS_VM_READV": "#define HAVE_NR_PROCESS_VM_READV 0",
"#cmakedefine01 HAVE_PPOLL": "#define HAVE_PPOLL 0",
"#cmakedefine01 HAVE_PROCESS_VM_READV": "#define HAVE_PROCESS_VM_READV 0",
"#cmakedefine01 HAVE_PTSNAME_R": "#define HAVE_PTSNAME_R 0",
"#cmakedefine01 HAVE_SYS_EVENT_H": "#define HAVE_SYS_EVENT_H 0",
"#cmakedefine01 LLDB_EMBED_PYTHON_HOME": "#define LLDB_EMBED_PYTHON_HOME 1",
"#cmakedefine01 LLDB_ENABLE_LIBXML2": "#define LLDB_ENABLE_LIBXML2 0",
"#cmakedefine01 LLDB_ENABLE_POSIX": "#define LLDB_ENABLE_POSIX 0",
"#cmakedefine01 LLDB_ENABLE_TERMIOS": "#define LLDB_ENABLE_TERMIOS 0",
"#cmakedefine01 LLDB_HAVE_EL_RFUNC_T": "#define LLDB_HAVE_EL_RFUNC_T 0",
},
}) | select({
":curses_enabled": {
"#cmakedefine01 LLDB_ENABLE_CURSES": "#define LLDB_ENABLE_CURSES 1",
@ -189,6 +217,13 @@ expand_template(
"#cmakedefine01 LLDB_EDITLINE_USE_WCHAR": "#define LLDB_EDITLINE_USE_WCHAR 0",
"#cmakedefine01 LLDB_ENABLE_LIBEDIT": "#define LLDB_ENABLE_LIBEDIT 0",
},
}) | select({
":system_lzma_enabled": {
"#cmakedefine01 LLDB_ENABLE_LZMA": "#define LLDB_ENABLE_LZMA 1",
},
"//conditions:default": {
"#cmakedefine01 LLDB_ENABLE_LZMA": "#define LLDB_ENABLE_LZMA 0",
},
}),
template = "include/lldb/Host/Config.h.cmake",
)
@ -633,6 +668,11 @@ cc_library(
"-lbsd",
],
"//conditions:default": [],
}) + select({
":system_lzma_enabled": [
"-llzma",
],
"//conditions:default": [],
}),
deps = [
":Headers",