rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vincenzo Palazzo" <vincenzopalazzodev@gmail.com>
To: "Andrea Righi" <andrea.righi@canonical.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>
Cc: <rust-for-linux@vger.kernel.org>
Subject: Re: distribute linux-headers to build out-of-tree Rust modules
Date: Sun, 12 Mar 2023 14:39:20 +0100	[thread overview]
Message-ID: <CR4G3AY4U6IJ.2ZRJBDCGH9Z0Q@vincent-arch> (raw)
In-Reply-To: <ZAzedS9sx5l6gmzB@righiandr-XPS-13-7390>

On Sat Mar 11, 2023 at 9:03 PM CET, Andrea Righi wrote:
> On Sat, Mar 11, 2023 at 04:27:52PM +0000, Björn Roy Baron wrote:
> > On Saturday, March 11th, 2023 at 15:01, Andrea Righi <andrea.righi@canonical.com> wrote:
> > 
> > > Hello,
> > > 
> > > I'm trying to distribute a linux-headers package (deb) that would allow
> > > to build out-of-tree Rust modules.
> > > 
> > > Everything looks fine, except for the following error:
> > > 
> > > error[E0461]: couldn't find crate `core` with expected target triple target-10951614936105594995
> > > |
> > > = note: the following crate versions were found:
> > > crate `core`, target triple target-3759196539525232825: /usr/src/linux-headers-6.2.0-16-generic/rust/libcore.rmeta
> > > 
> > > All I need to do is to "refresh" the headers by running a
> > > "make modules_prepare" after installing my linux-headers package on my
> > > system and then everything works perfectly.
> > > 
> > > Is this because my system, where I try to build the out-of-tree module,
> > > has different toolchain versions (e.g., binutils) than the build host?
> > > 
> > > Any pointer/documentation to better understand how the target triple
> > > version is determined?
> > 
> > The target id for external targets should be determined based on the filename and the hash of the target specification json file since https://github.com/rust-lang/rust/pull/98225. That it happens to work with "make modules_prepare" may be that it recompiles all rust code for the new target triple and through luck it just so happens to have the exact same abi as the original. There is no guarantee that two compiled rust crates have the same abi unless they have the exact same contents. To debug why the target id changed could you try running the following rust program in both the linux source dir and the /usr/src/linux-headers-6.2.0-16-generic dir?
>

> $ pwd
> /usr/src/linux-headers-6.2.0-16-generic
> $ ./test
> 5559158138856098584
>
> $ pwd
> /home/ubuntu/src/linux
> $ ./test
> 5559158138856098584
>
> ^ Same hash, but at this point I think we already know that the problem
> is the patch above that I'm missing in rustc.

Maybe we should increase the compiler version required by rust in the
kernel?

Cheers!

Vincent.

  reply	other threads:[~2023-03-12 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-11 14:01 distribute linux-headers to build out-of-tree Rust modules Andrea Righi
2023-03-11 14:51 ` Geert Stappers
2023-03-11 16:27 ` Björn Roy Baron
2023-03-11 20:03   ` Andrea Righi
2023-03-12 13:39     ` Vincenzo Palazzo [this message]
2023-03-12 22:08       ` Andrea Righi
2023-03-13  1:35       ` Miguel Ojeda

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=CR4G3AY4U6IJ.2ZRJBDCGH9Z0Q@vincent-arch \
    --to=vincenzopalazzodev@gmail.com \
    --cc=andrea.righi@canonical.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).