llvm/rust: simplify llvm-config handling for target builds
PATCH 1/1 llvm/rust: simplify llvm-config handling for target builds
From: Deepesh Varatharajan <[email protected]>
Replace PATH-based llvm-config discovery with explicit sysroot-native resolution and simplify the target llvm-config wrapper to act as a pure pass-through while preserving Yocto alternate path handling.
The previous implementation relied on:
* which -a llvm-config | sed -n 2p
This depends on PATH ordering and assumes the desired native llvm-config is visible in the build environment. In cross-build configurations this is fragile and may resolve an unexpected instance or fail to locate the intended tool.
* echo $base_libdir | sed -n '/lib64/p'
This depends on build-time variable expansion and may select an incorrect library directory when the expected value is unavailable.
Update the wrapper to:
* Resolve llvm-config directly from known sysroot-native location.
* Detect libdir using filesystem inspection rather than variable parsing.
* Preserve YOCTO_ALTERNATE_EXE_PATH and YOCTO_ALTERNATE_LIBDIR handling.
* Delegate all arguments directly to the native llvm-config.
Remove the native llvm-config copy logic and lib/lib64 symlink workaround.
--- ...unwind.pc.in-and-llvm-config-scripts.patch | 52 +++---------------- meta/recipes-devtools/rust/rust_1.96.0.bb | 41 +-------------- 2 files changed, 9 insertions(+), 84 deletions(-)
meta/recipes-devtools/clang/clang/0026-llvm-Add-libunwind.pc.in-and-llvm-config-scripts.patch +8 -44
@@ -8,6 +8,7 @@ These are added by OE project Upstream-Status: Inappropriate [ OE-Specific ] Signed-off-by: Khem Raj <[email protected]> +Signed-off-by: Deepesh Varatharajan <[email protected]> --- libunwind/libunwind.pc.in | 9 ++++++ llvm/tools/llvm-config/llvm-config | 52 ++++++++++++++++++++++++++++++
@@ -35,56 +36,19 @@ new file mode 100644 index 000000000000..6a0dd54b8eab --- /dev/null +++ b/llvm/tools/llvm-config/llvm-config -@@ -0,0 +1,52 @@ +@@ -0,0 +1,15 @@ +#!/bin/bash +# -+# Wrapper script for llvm-config. Supplies the right environment variables -+# for the target and delegates to the native llvm-config for anything else. This -+# is needed because arguments like --ldflags, --cxxflags, etc. are set by the -+# native compile rather than the target compile. ++#The llvm-config wrapper will act as a pure pass-through to the native llvm-config ++#while preserving Yocto-specific environment variables used for alternate executable ++#and library path resolution. +# +SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" -+NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)" ++NEXT_LLVM_CONFIG="$(readlink -f "$SCRIPT_DIR/../../../../recipe-sysroot-native/usr/bin/llvm-config")" +export YOCTO_ALTERNATE_EXE_PATH="${YOCTO_ALTERNATE_EXE_PATH:="$(readlink -f "$SCRIPT_DIR/../llvm-config")"}" -+if [ -n "$( echo $base_libdir | sed -n '/lib64/p')" ]; then ++if [ -d "$(readlink -f "$SCRIPT_DIR/../../lib64")" ]; then + export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib64"}" +else + export YOCTO_ALTERNATE_LIBDIR="${YOCTO_ALTERNATE_LIBDIR:="/lib"}" +fi -+if [[ $# == 0 ]]; then -+ exec "$NEXT_LLVM_CONFIG" -+fi -+ -+remain="" -+output="" -+for arg in "$@"; do -+ case "$arg" in -+ --cppflags) -+ output="${output} ${CPPFLAGS}" -+ ;; -+ --cflags) -+ output="${output} ${CFLAGS}" -+ ;; -+ --cxxflags) -+ output="${output} ${CXXFLAGS}" -+ ;; -+ --ldflags) -+ output="${output} ${LDFLAGS}" -+ ;; -+ --shared-mode) -+ output="${output} shared" -+ ;; -+ --link-shared) -+ break -+ ;; -+ *) -+ remain="${remain} ${arg}" -+ ;; -+ esac -+done -+ -+if [ "${remain}" != "" ]; then -+ output="${output} "$("$NEXT_LLVM_CONFIG" ${remain}) -+fi -+ -+echo "${output}" ++exec "$NEXT_LLVM_CONFIG" "$@"
meta/recipes-devtools/rust/rust_1.96.0.bb +1 -40
59 lines not on this page · raw message
Signature · 1 line
2.49.0
Hi All,
Tested the patch with the following builds and all completed successfully:
rust
clang
mesa
--with multilibs enabled
The changes correctly resolve llvm-config from the native sysroot, eliminate the need for the previous llvm-config copy/symlink workarounds, and work correctly with multilib (lib64) configurations.
Regards,
Deepesh
Hi Deepesh,
Quoted 11 lines · Deepesh via lists.openembedded.org
Tested the patch with the following builds and all completed successfully:
rust
clang
mesa
--with multilibs enabledThe changes correctly resolve llvm-config from the native sysroot, eliminate the need for the previous llvm-config copy/symlink workarounds, and work correctly with multilib (lib64) configurations.
Did you test this on non-x86?
I ran this through the autobuilder and there was a lot of red:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/3956
much of which look related to this change :(
Cheers,
Richard
Quoted 14 lines · Richard Purdie
CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.Hi Deepesh,
Quoted 8 lines · Deepesh via lists.openembedded.org
Tested the patch with the following builds and all completed successfully:
rust
clang
mesa
--with multilibs enabled
Quoted 4 lines
Quoted 3 lines
The changes correctly resolve llvm-config from the native sysroot, eliminate the need for the previous llvm-config copy/symlink workarounds, and work correctly with multilib (lib64) configurations.
Did you test this on non-x86?
Hi Richard,
Yes, I did. The failures reported by the autobuilder are limited to the nativesdk builds. The target builds completed successfully across all architectures.
Quoted 6 lines
I ran this through the autobuilder and there was a lot of red:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/3956
much of which look related to this change :(
The failures were traced back to two tasks:
nativesdk-rust:do_compile
nativesdk-mesa:do_configure.
Both issues have now been addressed. I'll complete some additional testing and then send a V2.
Regards,
Deepesh
Quoted 4 lines
Cheers,
Richard