All of lore.kernel.org
 help / color / mirror / Atom feed
From: sunilkumar.dora@windriver.com
To: openembedded-core@lists.openembedded.org
Cc: yoann.congal@smile.fr, alex.kanavin@gmail.com,
	sundeep.kokkonda@windriver.com, Randy.MacLeod@windriver.com,
	Deepesh.Varatharajan@windriver.com
Subject: [scarthgap][PATCH 0/2] rust: link LLVM dynamically
Date: Thu, 19 Nov 2026 19:28:44 -0800	[thread overview]
Message-ID: <20261120032846.2692732-1-sunilkumar.dora@windriver.com> (raw)

From: Sunil Dora <sunilkumar.dora@windriver.com>

This is the scarthgap backport for the rustc segfault, YOCTO #16058.
It follows the RFC and discussion from June/July [1].

Root cause is a binutils bug, PR ld/32991 [2]. From binutils 2.45 gas
emits R_X86_64_GOTPCRELX for "push foo@GOTPCREL(%rip)". An older ld
which does not have the fix converts that push into a call. So when
rust-llvm-native comes from sstate built on a >= 2.45 host and
rust-native gets linked on a host with an older ld, librustc_driver
jumps into LLVM data and rustc crashes. Details are in the bug [3].

master fixed this with [4], rustc links libLLVM.so there so the
host ld never touches the LLVM objects, without it scarthgap is
broken whenever sstate is shared between >= 2.45 and older hosts
(Debian 12/13, Ubuntu 22.04/24.04, the pinned buildtools) and the
distros have not picked up the ld fix.

It is opt-out via PACKAGECONFIG, and Alex also suggested to just take
the backport.

master only needed rust changes because the llvm recipe already builds
the shared lib (rust-llvm was dropped there [5]). scarthgap still has
rust 1.75 with rust-llvm, which builds only static libs. Hence two
patches:

  1/2 rust-llvm: build libLLVM-17.so, install in ${libdir}, package as
      rust-llvm-libllvm. rust is not touched here.
  2/2 rust: llvm-shared PACKAGECONFIG, default on for native, nativesdk
      and target. Native only does not work, Yoann already hit that in
      the RFC, target rust bootstraps its own rustc with target settings.
      Remove llvm-shared from PACKAGECONFIG to get static back.

Tested on scarthgap with both patches:

 - rust-native, target rust, SDK build. librustc_driver has libLLVM-17.so
   in NEEDED now, size 142MB -> 70MB (native)
 - rustc and cargo on qemux86-64 and from the SDK, testsdk passes
 - multilib, musl, qemuarm, qemuppc, qemuarm64 build
 - llvm-shared removed: librustc_driver static again, no libLLVM-17.so
   in DT_NEEDED, 142MB like before
 - oe-selftest rust: same result with and without the series

Size: An image with rust is about 15MB bigger.

[1] https://lists.openembedded.org/g/openembedded-core/topic/119988126?msg=241069
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=32991
[3] https://bugzilla.yoctoproject.org/show_bug.cgi?id=16058#c86
[4] https://git.openembedded.org/openembedded-core/commit/?id=d0671c3dad87a063b3a41dd07cde89b5684e692c
    rust: enable dynamic LLVM linking by default
[5] https://git.openembedded.org/openembedded-core/commit/?id=c116828a876853cd5b53f7bd4607f0037fef4ee4
    rust: Drop rust-llvm

Sunil Dora (2):
  rust-llvm: build and install the LLVM shared library
  rust: enable dynamic LLVM linking by default

 meta/lib/oeqa/selftest/cases/rust.py           |  2 +-
 meta/recipes-devtools/rust/rust-llvm_1.75.0.bb | 15 ++++++++++++++-
 meta/recipes-devtools/rust/rust_1.75.0.bb      |  4 ++++
 3 files changed, 19 insertions(+), 2 deletions(-)

-- 
2.49.0


             reply	other threads:[~2026-11-20  3:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  3:28 sunilkumar.dora [this message]
2026-11-20  3:28 ` [scarthgap][PATCH 1/2] rust-llvm: build and install the LLVM shared library sunilkumar.dora
2026-11-20  3:28 ` [scarthgap][PATCH 2/2] rust: enable dynamic LLVM linking by default sunilkumar.dora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120032846.2692732-1-sunilkumar.dora@windriver.com \
    --to=sunilkumar.dora@windriver.com \
    --cc=Deepesh.Varatharajan@windriver.com \
    --cc=Randy.MacLeod@windriver.com \
    --cc=alex.kanavin@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=sundeep.kokkonda@windriver.com \
    --cc=yoann.congal@smile.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.