diff mbox series

[meta-darwin,1/3] lldb: build nativesdk-lldb with clang for the macOS SDK

Message ID 20261203133818.967228-1-ecordonnier@snap.com
State New
Headers show
Series [meta-darwin,1/3] lldb: build nativesdk-lldb with clang for the macOS SDK | expand

Commit Message

Etienne Cordonnier Dec. 3, 2026, 1:38 p.m. UTC
From: Etienne Cordonnier <ecordonnier@snap.com>

lldb's macOS host support is Objective-C++, which the Darwin cross-GCC
cannot compile. Select the clang toolchain for the nativesdk variant when
SDK_OS is darwin, and keep the default SDK toolchain otherwise so that the
Linux SDK still uses GCC.

The previous PREFERRED_TOOLCHAIN_SDK in the bbappend had no effect: it is
only a global default consumed by "TOOLCHAIN ??= ${PREFERRED_TOOLCHAIN}" in
base.bbclass, and the distro sets TOOLCHAIN = "gcc".

Set TOOLCHAIN with a pn- override instead. base.bbclass expands
"inherit toolchain/${TOOLCHAIN}" at finalize time, before the BBCLASSEXTEND
variant has inherited nativesdk: TARGET_OS is still the target's, so
darwin21 and class-nativesdk are not in OVERRIDES yet, and PN is still
bitbake's temporary "lldb-nativesdk", not "nativesdk-lldb". The override is
therefore keyed on the temporary PN and the darwin check reads SDK_OS, a
global variable that is already set.

Tested: macOS NDK nativesdk-clang and nativesdk-lldb build, with
x86_64-snapndk-darwin21-clang++ compiling the .mm files; bitbake -e of the
Linux NDK nativesdk-lldb still selects toolchain-gcc.

AI-Generated: Claude Sonnet 5.5

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 recipes-devtools/clang/lldb_%.bbappend | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/recipes-devtools/clang/lldb_%.bbappend b/recipes-devtools/clang/lldb_%.bbappend
index 39734d8..7fe8cb3 100644
--- a/recipes-devtools/clang/lldb_%.bbappend
+++ b/recipes-devtools/clang/lldb_%.bbappend
@@ -57,9 +57,9 @@  INSANE_SKIP:${PN}:class-nativesdk:darwin21 += " file-rdeps"
 EXTRA_PYTHON_DEPENDS:class-nativesdk:darwin21 = ""
 
 # lldb's macOS host support is Objective-C++ (Host.mm etc.), which the Darwin
-# cross-GCC can't compile. Build with the clang-crosssdk compiler instead, with
-# the same toolchain-clang adjustments as the nativesdk-clang bbappend.
-PREFERRED_TOOLCHAIN_SDK = "clang"
+# cross-GCC can't compile. Build it with the clang-crosssdk compiler, with the
+# same toolchain-clang adjustments as the nativesdk-clang bbappend.
+TOOLCHAIN:pn-lldb-nativesdk = "${@'clang' if d.getVar('SDK_OS').startswith('darwin') else d.getVar('PREFERRED_TOOLCHAIN_SDK')}"
 
 COMPILER_RT:class-nativesdk:toolchain-clang:runtime-llvm:darwin21 = ""
 LIBCPLUSPLUS:class-nativesdk:toolchain-clang:darwin21 = " -stdlib=libstdc++"