NEW SRU rustc linux kernel requirements

Bug #1993183 reported by Dimitri John Ledkov
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
rust-bindgen-0.56 (Ubuntu)
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned
Lunar
Fix Released
Undecided
Unassigned
rustc-1.62 (Ubuntu)
Fix Released
Critical
Unassigned
Jammy
Fix Released
Undecided
Unassigned
Lunar
Fix Released
Critical
Unassigned

Bug Description

linux kernel is adding rustc requirements.

ideally we need a compatible version of rustc in $devel release, and last $lts, due to backporting of $devel kernels to latest $lts at point releases.

Attempting the rust build in jammy today results in the following checks failing:

sh ./scripts/rust_is_available.sh -v
***
*** Rust compiler '/usr/bin/rustc' is too old.
*** Your version: 1.61.0
*** Minimum version: 1.62.0
***
***
*** Rust bindings generator 'bindgen' is too new. This may or may not work.
*** Your version: 0.59.1
*** Expected version: 0.56.0
***

Please update rustc to 1.62.0 in LL devel release and Jammy.

Separately I will look if upstream kernel can upgrade to a newer bindgen, or if we need to request a historical bindgen packaging as bindgen-0.56 or some such.

Revision history for this message
Simon Chopin (schopin) wrote :

Dimitri, do you know if upstream's rustc requirements are just 1.62, or 1.62 and above? I'm guessing they're using unstable features in the code, so they might be picky with the exact compiler version. If so, we'll need to get moving on branching out rustc into rustc-1.N packages :/

Changed in rustc (Ubuntu):
importance: Undecided → High
status: New → Incomplete
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 1993183] Re: rustc linux kernel requirements

On Tue, 18 Oct 2022 at 03:55, Simon Chopin <email address hidden>
wrote:

> Dimitri, do you know if upstream's rustc requirements are just 1.62, or
> 1.62 and above?

My understanding is that each kernel version will require a specific rustc
version. So...

> I'm guessing they're using unstable features in the
> code, so they might be picky with the exact compiler version. If so,
> we'll need to get moving on branching out rustc into rustc-1.N packages
> :/
>

... yes we will.

Revision history for this message
Andrea Righi (arighi) wrote : Re: rustc linux kernel requirements

FYI, these are the unstable features required by the kernel for now: https://github.com/Rust-for-Linux/linux/issues/2

I've done some tests with rust 1.64 and simple module examples are still working fine, but to be 100% safe we would need to provide exactly the same version that the kernel is recommending (`./scripts/min-tool-version.sh rustc` from the linux source dir).

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

will it be available soon, at least from any ppa?

We are already packaging 6.1 kernel in PPAs as an unstable kernel, and would like to enable rust examples in it.

Could we please have 1.62 anywhere please?

Olivier Gayot (ogayot)
tags: added: foundations-triage-discuss
Revision history for this message
Simon Chopin (schopin) wrote :

I'll try to put together a straight merge from Debian for rustc 1.62 this week in a PPA, but no promises. If I don't manage it, it'll have to wait for a couple of weeks unless someone else from Foundations picks it up.

Simon Chopin (schopin)
Changed in rustc (Ubuntu):
status: Incomplete → Triaged
tags: added: foundations-todo
removed: foundations-triage-discuss
Revision history for this message
Simon Chopin (schopin) wrote :

@xnox could you give this a try?

https://launchpad.net/~schopin/+archive/ubuntu/versioned-rustc

Use /usr/bin/rustc-1.62 or /usr/lib/rust-1.62/bin/rustc, at your convenience.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

the kernel FTBFS with rustc-1.64 for now.

In addition to rustc we also need a fixed version bindgen, is that going to be prepared as well?

The above is working for us, as is.

Changed in rustc (Ubuntu):
importance: High → Critical
Revision history for this message
Andrea Righi (arighi) wrote :

Would it be possible to include rust-src that is also required by linux (usually I'm doing `rustup component add rust-src` manually to add that, not sure what's the equivalent to include this stuff in this package).

Moreover, we may also need a special bindgen-0.56.0 since we're already at 0.60.1 in lunar that is already too new for the kernel.

And thanks for doing this!

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

@arighyi i believe build-depends on rust-1.62-src should be equivalent to `component add rust-src`.

affects: rustc (Ubuntu) → rustc-1.62 (Ubuntu)
Revision history for this message
Andrea Righi (arighi) wrote :

@xnox ohhh, I didn't notice rust-1.62-src was there, yeah that's great, I just verified that it is equivalent, even if the kernel check is complaining a bit:

ubuntu@lunar$ make RUSTC=rustc-1.62 BINDGEN=bindgen-0.56 rustavailable
***
*** Rust compiler 'rustc-1.62' is too new. This may or may not work.
*** Your version: 1.62.1
*** Expected version: 1.62.0
***
***
*** Source code for the 'core' standard library could not be found
*** at '/usr/lib/rust-1.62/lib/rustlib/src/rust/library/core/src/lib.rs'.
***
make: *** [Makefile:1833: rustavailable] Error 1

So I had to manually fix this doing:

 $ sudo mkdir /usr/lib/rust-1.62/lib/rustlib/src
 $ sudo ln -s /usr/src/rustc-1.62.1/ /usr/lib/rust-1.62/lib/rustlib/src/rust

Also, as you can see from the output above, the kernel is also complaining about using rustc being 1.62.1 and it's expecting 1.62.0. I'll test a full build to see if anything breaks.

Revision history for this message
Andrea Righi (arighi) wrote :

With all of the above in place everything looks good, yay!

I tested my small hello world Rust module with the recompiled Rust-enabled kernel:

08:18 ubuntu@lunar$ make RUSTC=rustc-1.62 BINDGEN=bindgen-0.56 RUSTFMT=rustfmt-1.62 KDIR=/home/ubuntu/linux
make -C /home/ubuntu/linux M=/tmp/hello modules
make[1]: Entering directory '/home/ubuntu/linux'
  RUSTC [M] /tmp/hello/hello_rust.o
  MODPOST /tmp/hello/Module.symvers
  LD [M] /tmp/hello/hello_rust.ko
make[1]: Leaving directory '/home/ubuntu/linux'
6.2.0-rc6-kc /tmp/hello (master)
08:18 ubuntu@lunar$ sudo insmod hello_rust.ko
[ 138.106010] rust_minimal: Hello from Rust
6.2.0-rc6-kc /tmp/hello (master)
08:18 ubuntu@lunar$ sudo rmmod hello_rust
[ 144.318111] rust_minimal: Goodbye from Rust
6.2.0-rc6-kc /tmp/hello (master)

Revision history for this message
Andrea Righi (arighi) wrote :

To summarize, with bindgen-0.56 provided by @xnox (ppa:xnox/nonvirt) and this rust-1.62 everything looks good, except for this minor issue:

*** Source code for the 'core' standard library could not be found
*** at '/usr/lib/rust-1.62/lib/rustlib/src/rust/library/core/src/lib.rs'.

If we can somehow automatically symlink /usr/lib/rust-1.62/lib/rustlib/src/rust -> /usr/src/rustc-1.62.1 we are golden and we can start releasing a Rust-enabled Ubuntu kernel.

Revision history for this message
Andrea Righi (arighi) wrote :

Actually looking more at what the kernel is doing we can override the rust src path passing `RUST_LIB_SRC=/usr/src/rustc-1.62.1/library` to the kernel make and everything looks ok.

So ignore comment #12.

Revision history for this message
Simon Chopin (schopin) wrote :

To verify this, I used the following shell code with the attached tarball, which contains 3 Rust programs each using features introduced in 1.61, 1.62 and 1.63 respectively:

tar -xaf programs.tar.xz && cd programs
rustc-1.62 61.rs || echo "error: couldn't compile a 1.61 compatible program"
rustc-1.62 62.rs || echo "error: couldn't compile a 1.62 compatible program"
! rustc-1.62 63.rs 2> /dev/null || echo "error: shouldn't be able to compile a 1.63 compatible program"

This works as expected on a fresh Jammy container.

Changed in rust-bindgen-0.56 (Ubuntu Lunar):
status: New → Fix Released
no longer affects: rust-bindgen (Ubuntu Jammy)
no longer affects: rust-bindgen (Ubuntu Lunar)
no longer affects: rust-bindgen (Ubuntu)
Changed in rustc-1.62 (Ubuntu Lunar):
status: Triaged → Fix Released
Changed in rustc-1.62 (Ubuntu Jammy):
status: New → Fix Released
Changed in rust-bindgen-0.56 (Ubuntu Jammy):
status: New → In Progress
summary: - rustc linux kernel requirements
+ NEW SRU rustc linux kernel requirements
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Dimitri, or anyone else affected,

Accepted rust-bindgen-0.56 into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/rust-bindgen-0.56/0.56.0-0ubuntu1~22.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in rust-bindgen-0.56 (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
TuxInvader (tuxinvader) wrote :

Hi all,

I would like to confirm that I can build the mainline kernel on jammy with the rust/bindgen packages in the proposed repository. However the kernel seems to have rust disabled due to incompatible configuration options (CONFIG_MODVERSIONS, CONFIG_DEBUG_INFO_BTF, and CONFIG_HAVE_GCC_PLUGINS).

If I patch debian.master/config/annotations (see attached) to disable those options, and enable RUST and the RUST sample code, then the build fails with:

***
*** Rust compiler 'rustc-1.62' is too new. This may or may not work.
*** Your version: 1.62.1
*** Expected version: 1.62.0
***
  BINDGEN rust/bindings/bindings_generated.rs
  BINDGEN rust/bindings/bindings_helpers_generated.rs
  UPD rust/target.json
  RUSTC L rust/core.o
error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang', err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/main.rs:54:36
stack backtrace:
   0: 0x55dafce519ec - <unknown>
   1: 0x55dafce6ceae - <unknown>
   2: 0x55dafce315f1 - <unknown>
   3: 0x55dafce35ff5 - <unknown>
   4: 0x55dafce35c7a - <unknown>
   5: 0x55dafce364fc - <unknown>
   6: 0x55dafce525a7 - <unknown>
   7: 0x55dafce51c84 - <unknown>
   8: 0x55dafce361c2 - <unknown>
   9: 0x55dafcc5abd3 - <unknown>
  10: 0x55dafcc5acb3 - <unknown>
  11: 0x55dafcc799ec - <unknown>
  12: 0x55dafcc65854 - <unknown>
  13: 0x55dafcc7ad03 - <unknown>
  14: 0x55dafcc65d49 - <unknown>
  15: 0x55dafce30f81 - <unknown>
  16: 0x55dafcc65b08 - <unknown>
  17: 0x7ff26d448d90 - <unknown>
  18: 0x7ff26d448e40 - __libc_start_main
  19: 0x55dafcc5ae25 - <unknown>
  20: 0x0 - <unknown>
make[3]: *** [/home/source/rust/Makefile:310: rust/bindings/bindings_helpers_generated.rs] Error 1
make[3]: *** Deleting file 'rust/bindings/bindings_helpers_generated.rs'
make[3]: *** Waiting for unfinished jobs....

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Which kernel are you using and which configs are you using?

We have patches our lunar v6.2 kernel, and submitted fixes upstream to make the kernel compatible with regular configs and rust at the same time.

Can you please try building lunar v6.2 kernel and if that works better? If yes, please check if you can cherry pick our fixes into mainline kernel to resolve the issue.

Revision history for this message
TuxInvader (tuxinvader) wrote :

I'm using the Ubuntu mainline kernel tag `cod/mainline/v6.2.11` - is there a better tag to use for testing?

Thanks

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

cod/mainline/v6.2.11 is not good enough, as the fixes we did are upstreamed in much later vanilla builds.

Of the v6.2 based kernels it's best to use our Lunar kernel https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/lunar from master branch, i.e. tags of the form Ubuntu-6.2.0-21.21 (or any later ones that will come after it)

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

rust-bindgen-.56 0.56.0-0ubuntu1~22.04.1 on jammy successfully builds rust with hwe-6.2 kernel (although it by default has rust turned off)

tags: added: foundations-done verification-done verification-done-jammy
removed: foundations-todo verification-needed verification-needed-jammy
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package rust-bindgen-0.56 - 0.56.0-0ubuntu1~22.04.1

---------------
rust-bindgen-0.56 (0.56.0-0ubuntu1~22.04.1) jammy; urgency=medium

  * No-change backport to jammy.

rust-bindgen-0.56 (0.56.0-0ubuntu1) lunar; urgency=medium

  * Package bindgen 0.56.0 from crates.io using debcargo 2.5.0 LP:
    #1993183
  * Drop unused vendored sources
  * Update debian/copyright

 -- Dimitri John Ledkov <email address hidden> Thu, 02 Mar 2023 00:57:43 +0000

Changed in rust-bindgen-0.56 (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Robie Basak (racb) wrote : Update Released

The verification of the Stable Release Update for rust-bindgen-0.56 has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
TuxInvader (tuxinvader) wrote :

Hi all,

It looks like the recent kernels 6.5.3 onwards now require rustc-1.68. Any plans for that to be backported to jammy?

Thanks

Revision history for this message
TuxInvader (tuxinvader) wrote :
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-azure-6.5/6.5.0-1007.7~22.04.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-jammy-linux-azure-6.5' to 'verification-done-jammy-linux-azure-6.5'. If the problem still exists, change the tag 'verification-needed-jammy-linux-azure-6.5' to 'verification-failed-jammy-linux-azure-6.5'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-jammy-linux-azure-6.5-v2 verification-needed-jammy-linux-azure-6.5
removed: verification-done
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote :

This bug is awaiting verification that the linux-aws-6.5/6.5.0-1008.8~22.04.1 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-jammy-linux-aws-6.5' to 'verification-done-jammy-linux-aws-6.5'. If the problem still exists, change the tag 'verification-needed-jammy-linux-aws-6.5' to 'verification-failed-jammy-linux-aws-6.5'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: kernel-spammed-jammy-linux-aws-6.5-v2 verification-needed-jammy-linux-aws-6.5
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.