From e7f77af2253d2ddc75cf8f7cd1515a58b8971e3e Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Wed, 8 Apr 2026 15:51:02 +0000 Subject: rubyv2.bbclass: strip native RPATHs from gem shared objects Ruby gem native extensions embed the build-time sysroot RPATH in their .so files, which fails the rpaths QA check. Use chrpath to strip these after install. Signed-off-by: Bruce Ashfield --- classes/rubyv2.bbclass | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'classes/rubyv2.bbclass') diff --git a/classes/rubyv2.bbclass b/classes/rubyv2.bbclass index 1dfb047..12720c9 100644 --- a/classes/rubyv2.bbclass +++ b/classes/rubyv2.bbclass @@ -99,7 +99,7 @@ do_gem_unpack() { gem unpack -V ${GEM_FILE} } -DEPENDS:append = " ruby-native ${EXTRA_DEPENDS}" +DEPENDS:append = " ruby-native chrpath-native ${EXTRA_DEPENDS}" DEPENDS:append:class-target = " ruby ruby-native ${EXTRA_DEPENDS}" python () { @@ -235,6 +235,8 @@ rubyv2_do_compile() { } python do_rubyv2_fix_libs() { + import subprocess + # as ruby dynloader expects the shared .so files # without extension we will create symlinks to the # properly versioned file @@ -248,6 +250,19 @@ python do_rubyv2_fix_libs() { except: pass _filename, _ = os.path.splitext(_filename) + + # Strip native sysroot RPATHs from installed shared objects + for root, dirs, files in os.walk(d.expand("${GEM_HOME}")): + for f in files: + if f.endswith(".so"): + fpath = os.path.join(root, f) + if os.path.islink(fpath): + continue + try: + subprocess.check_call(["chrpath", "-d", fpath], + stderr=subprocess.DEVNULL) + except (subprocess.CalledProcessError, FileNotFoundError): + pass } RUBY_INSTALL_EXTRA_FLAGS ?= "" -- cgit v1.2.3-54-g00ecf