From e73caaf78fed16fe6bcff67d06f57cdab7ad6f4f Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 25 Jun 2026 12:31:16 -0700 Subject: [PATCH] crash-cross-canadian: fix build, including on clang based SDKs The cross-canadian variant did not build. Several issues: 1. DEPENDS used :append on top of crash.inc's target DEPENDS. cross-canadian does not remap DEPENDS to nativesdk, so the target zlib/readline/ncurses/ gmp/mpfr stayed in the dependency set and staged a real target usr/lib into the recipe sysroot, clashing with the nativesdk toolchain (clang-glue provides usr/lib as a symlink) during do_prepare_recipe_sysroot. Override DEPENDS with the nativesdk set instead (matching gdb-cross-canadian) and add the -native build tools the build needs. 2. do_compile hardcoded ${HOST_PREFIX}gcc, which does not exist on clang based SDKs (TOOLCHAIN = "clang"), giving "C compiler cannot create executables". Use the toolchain-aware ${CC}/${CXX} like the other variants. 3. crash's gdb merge re-enters the top-level crash Makefile from gdb's link rule ("make -C ../.. ... library") without passing the compiler, so crash's own objects fell back to the Makefile default $(CROSS_COMPILE)gcc and failed to find a compiler on clang SDKs. Forward CC/CXX through that recursion in the bundled gdb-16.2.patch; this is harmless where ${cross}-gcc exists. Verified by building crash, crash-native, crash-cross and crash-cross-canadian-x86-64 for a clang based SDK (qemux86-64). Signed-off-by: Khem Raj --- .../crash/crash-cross-canadian_9.0.2.bb | 19 ++++++++++++++----- meta-oe/recipes-kernel/crash/crash.inc | 7 +++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/meta-oe/recipes-kernel/crash/crash-cross-canadian_9.0.2.bb b/meta-oe/recipes-kernel/crash/crash-cross-canadian_9.0.2.bb index 1a62441c05..924e3ccfc0 100644 --- a/meta-oe/recipes-kernel/crash/crash-cross-canadian_9.0.2.bb +++ b/meta-oe/recipes-kernel/crash/crash-cross-canadian_9.0.2.bb @@ -6,18 +6,25 @@ BPN = "crash" require crash.inc -DEPENDS:append = " \ +# cross-canadian.bbclass does not remap DEPENDS to their nativesdk variants, so +# override (rather than append to) the target DEPENDS pulled in from crash.inc. +# Leaving the target zlib/readline/ncurses/gmp/mpfr in place would stage a real +# target usr/lib into the recipe sysroot and clash with the nativesdk toolchain +# (e.g. clang-glue, which provides usr/lib as a symlink) during +# do_prepare_recipe_sysroot. +DEPENDS = " \ nativesdk-ncurses \ nativesdk-expat \ nativesdk-gettext \ nativesdk-gmp \ nativesdk-mpfr \ - nativesdk-readline \ nativesdk-zlib \ virtual/nativesdk-cross-cc \ virtual/nativesdk-cross-binutils \ - virtual/nativesdk-compilerlibs \ virtual/nativesdk-libc \ + coreutils-native \ + bison-native \ + flex-native \ " RDEPENDS:${PN} = "nativesdk-liblzma" @@ -43,9 +50,11 @@ EXTRA_OEMAKE:class-cross-canadian = ' \ ac_cv_header_sys_procfs_h=yes" \ ' -# Force the SDK cross-compiler during the command execution phase +# Build with the SDK cross-compiler. Use the toolchain-aware ${CC}/${CXX} +# rather than a hardcoded ${HOST_PREFIX}gcc so this also works for clang based +# SDKs (TOOLCHAIN = "clang"), which provide no ...-gcc. do_compile() { - oe_runmake ${EXTRA_OEMAKE} CC="${HOST_PREFIX}gcc ${HOST_CC_ARCH}" CXX="${HOST_PREFIX}g++ ${HOST_CC_ARCH}" RECIPE_SYSROOT=${RECIPE_SYSROOT} + oe_runmake ${EXTRA_OEMAKE} CC="${CC}" CXX="${CXX}" RECIPE_SYSROOT=${RECIPE_SYSROOT} } # To ship crash into your sdk, you should create/update a packagegroup-cross-canadian.bbappend and diff --git a/meta-oe/recipes-kernel/crash/crash.inc b/meta-oe/recipes-kernel/crash/crash.inc index 57a6c23bc4..dd231134b2 100644 --- a/meta-oe/recipes-kernel/crash/crash.inc +++ b/meta-oe/recipes-kernel/crash/crash.inc @@ -99,6 +99,13 @@ do_compile:prepend() { sed -i -e 's/#define TARGET_CFLAGS_MIPS_ON_X86_64.*/#define TARGET_CFLAGS_MIPS_ON_X86_64\t\"TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64\"/g' ${S}/configure.c sed -i 's/>/>/g' ${S}/Makefile + # The crash gdb merge step re-enters the top-level crash Makefile from gdb's + # link rule ("make -C ../.. ... library") without passing the compiler, so + # crash's own objects fall back to the Makefile default $(CROSS_COMPILE)gcc. + # That only happens to work when a ${cross}-gcc exists; on clang toolchains + # (and any gcc-less SDK) it fails. Forward CC/CXX through that recursion. + sed -i 's|GDB_FLAGS=-DGDB_16_2 library|GDB_FLAGS=-DGDB_16_2 CC="$(CC)" CXX="$(CXX)" library|' ${S}/gdb-16.2.patch + # 5. Return to the active workspace build root to merge downstream additions cd ${B} bbnote "Applying the native upstream crash integration patch onto the GDB source tree..."