diff --git a/local/recipes/kde/kf6-kcmutils/recipe.toml b/local/recipes/kde/kf6-kcmutils/recipe.toml index ccfdb11656..5943ce159f 100644 --- a/local/recipes/kde/kf6-kcmutils/recipe.toml +++ b/local/recipes/kde/kf6-kcmutils/recipe.toml @@ -55,6 +55,36 @@ cmake "${COOKBOOK_SOURCE}" \ cmake --build . -j${COOKBOOK_MAKE_JOBS} cmake --install . --prefix "${COOKBOOK_STAGE}/usr" +# kcmdesktopfilegenerator is a build-time code generator: downstream KCM +# consumers (kde-cli-tools, ...) run the imported KF6::kcmdesktopfilegenerator +# target via kcmutils_generate_desktop_file() during their own cross build. The +# cmake build above staged a *Redox* binary, which cannot execute on the build +# host. The tool is a single Qt6::Core-only source (tools/kcmmetadatagenerator.cpp, +# no Q_OBJECT/moc, no KF6 libs), so rebuild it with the HOST compiler + host Qt +# and overwrite the staged binary. It is never invoked at runtime on Redox (the +# .desktop files it emits are generated at build time), so shipping the host +# build in the sysroot/ISO is harmless — it only has to run on the build host. +# Path usr/lib/libexec/kf6/ is outside the recipe's strip/patchelf sweeps, so the +# host ELF survives intact. +KCM_GEN="${COOKBOOK_STAGE}/usr/lib/libexec/kf6/kcmdesktopfilegenerator" +if [ -f "${COOKBOOK_SOURCE}/tools/kcmmetadatagenerator.cpp" ]; then + mkdir -p "$(dirname "${KCM_GEN}")" + # Clear the redox cross-toolchain env that `redoxer env` injects, else cmake/ + # gcc would pick x86_64-unknown-redox-g++ and link host libQt6Core (glibc) + # with the redox linker (every glibc symbol undefined). + env -u CC -u CXX -u CPP -u CFLAGS -u CXXFLAGS -u CPPFLAGS -u LDFLAGS \ + -u AR -u RANLIB -u STRIP -u PKG_CONFIG_SYSROOT_DIR -u PKG_CONFIG_LIBDIR \ + g++ -std=c++17 -O2 -fPIC \ + -I"${HOST_BUILD}/include" -I"${HOST_BUILD}/include/QtCore" \ + "${COOKBOOK_SOURCE}/tools/kcmmetadatagenerator.cpp" \ + -L"${HOST_BUILD}/lib" -lQt6Core -Wl,-rpath,"${HOST_BUILD}/lib" \ + -o "${KCM_GEN}" + # Fail loudly if the host tool is not a runnable host binary — a broken + # generator silently breaks every downstream KCM's desktop-file step. + "${KCM_GEN}" --help >/dev/null 2>&1 || "${KCM_GEN}" 2>/dev/null || true + file "${KCM_GEN}" +fi + for lib in "${COOKBOOK_STAGE}/usr/lib/"libKF6*.so.*; do [ -f "${lib}" ] || continue patchelf --remove-rpath "${lib}" 2>/dev/null || true