rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/char/rust_example fails to load
@ 2021-03-22  0:13 Joshua Abraham
  2021-03-22  1:01 ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Joshua Abraham @ 2021-03-22  0:13 UTC (permalink / raw)
  To: ojeda, alex.gaynor, rust-for-linux, linux-kernel

I am building Rust-for-Linux at commit
e9b9c0ef1e7040a3c3dc2232d5fd64999eba61a0 with "make CC=clang-11" and
the built kernel fails to load rust_example.ko with the following
error:

[ 1653.507602] module: rust_example: Unknown rela relocation: 9

Looking at elf.h shows this relocation is type GOTPCREL:
#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */

Sure enough rust_example.ko contains a few of these entries, and no
other kernel module does:
000000000a51 008800000009 R_X86_64_GOTPCREL 0000000000000000
_RNvXsb_NtCshGpAVYOtgW - 4
000000000f15  008700000009 R_X86_64_GOTPCREL 0000000000000000
_RNvXs2_NtNtNtCshGpAVY - 4
000000001307 005300000009 R_X86_64_GOTPCREL 0000000000000000
_RNvXs6_NtNtNtCshGpAVY - 4

I assume that this is an issue with my rust toolchain, however I'm
reporting it here since it might be helpful to update documentation or
(unlikely) add support for this relocation type in the kernel.

Host/environment info:
$ uname -a
Linux pop-os 5.8.0-7642-generic #47~1614007149~20.04~82fb226-Ubuntu
SMP Tue Feb 23 02:56:27 UTC
$ rustup show active-toolchain
nightly-x86_64-unknown-linux-gnu (default)
$ rustc --version
rustc 1.52.0-nightly (61edfd591 2021-03-20)
$ clang-11 --version
Ubuntu clang version 11.0.0-2~ubuntu20.04.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


-- 
Respectfully,
Josh Abraham

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load
  2021-03-22  0:13 drivers/char/rust_example fails to load Joshua Abraham
@ 2021-03-22  1:01 ` Miguel Ojeda
  2021-03-22  2:53   ` Joshua Abraham
  0 siblings, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-22  1:01 UTC (permalink / raw)
  To: Joshua Abraham; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, linux-kernel

Hi Joshua,

On Mon, Mar 22, 2021 at 1:13 AM Joshua Abraham <j.abraham1776@gmail.com> wrote:
>
> $ rustc --version
> rustc 1.52.0-nightly (61edfd591 2021-03-20)

Please give a go to the nightly from a month ago, i.e. 2021-02-20.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load
  2021-03-22  1:01 ` Miguel Ojeda
@ 2021-03-22  2:53   ` Joshua Abraham
  2021-03-22  6:53     ` drivers/char/rust_example fails to load 2021-03-20 builds Geert Stappers
  2021-03-22 12:20     ` drivers/char/rust_example fails to load Miguel Ojeda
  0 siblings, 2 replies; 7+ messages in thread
From: Joshua Abraham @ 2021-03-22  2:53 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, linux-kernel

Hey Miguel,

> Please give a go to the nightly from a month ago, i.e. 2021-02-20.

Cheers, using rustc 1.52.0-nightly (9b471a3f5 2021-02-19) fixed the
issue. Interesting that the newer nightly compiler creates these new
relocations for the code!

-- 
Respectfully,
Josh Abraham

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load 2021-03-20 builds
  2021-03-22  2:53   ` Joshua Abraham
@ 2021-03-22  6:53     ` Geert Stappers
  2021-03-22  8:22       ` Adam Bratschi-Kaye
  2021-03-22 12:20     ` drivers/char/rust_example fails to load Miguel Ojeda
  1 sibling, 1 reply; 7+ messages in thread
From: Geert Stappers @ 2021-03-22  6:53 UTC (permalink / raw)
  To: Joshua Abraham, Miguel Ojeda, Miguel Ojeda, Alex Gaynor,
	rust-for-linux, linux-kernel

On Sun, Mar 21, 2021 at 09:53:27PM -0500, Joshua Abraham wrote:
> Hey Miguel,
> 
> > Please give a go to the nightly from a month ago, i.e. 2021-02-20.
> 
> Cheers, using rustc 1.52.0-nightly (9b471a3f5 2021-02-19) fixed the issue.

How to tell "use older parts in toolchain"?
Yeah, probably a Rust newbie question, still a sincere question.
Was a older version installed? How to tell `rustup` to keep old
versions? Was done with a cargo.toml entry? Or with file
`rust-toolchain`?  Please tell   (Please spoon feed me ;-)


> Interesting that the newer nightly compiler creates these new
> relocations for the code!

Not each change is an improvement.  Hopefully came the change with a
flag to modify the new default behaviour.



Groeten
Geert Stappers
-- 
Silence is hard to parse

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load 2021-03-20 builds
  2021-03-22  6:53     ` drivers/char/rust_example fails to load 2021-03-20 builds Geert Stappers
@ 2021-03-22  8:22       ` Adam Bratschi-Kaye
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Bratschi-Kaye @ 2021-03-22  8:22 UTC (permalink / raw)
  To: Geert Stappers
  Cc: Joshua Abraham, Miguel Ojeda, Miguel Ojeda, Alex Gaynor,
	rust-for-linux, linux-kernel

> How to tell "use older parts in toolchain"?
> Yeah, probably a Rust newbie question, still a sincere question.
> Was a older version installed? How to tell `rustup` to keep old
> versions? Was done with a cargo.toml entry? Or with file
> `rust-toolchain`?  Please tell   (Please spoon feed me ;-)

Using `rust-toolchain.toml` should work.
Another option would be to override the default version for the given
directory with
`rustup override set nightly-2021-02-20`.

You could also set the global default `rustc` to a specific nightly release:
`rustup default nightly-2021-02-20`.

More info here: https://rust-lang.github.io/rustup/overrides.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load
  2021-03-22  2:53   ` Joshua Abraham
  2021-03-22  6:53     ` drivers/char/rust_example fails to load 2021-03-20 builds Geert Stappers
@ 2021-03-22 12:20     ` Miguel Ojeda
  2021-03-23  1:24       ` Miguel Ojeda
  1 sibling, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-22 12:20 UTC (permalink / raw)
  To: Joshua Abraham; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, linux-kernel

Hi Joshua,

On Mon, Mar 22, 2021 at 3:53 AM Joshua Abraham <j.abraham1776@gmail.com> wrote:
>
> Cheers, using rustc 1.52.0-nightly (9b471a3f5 2021-02-19) fixed the
> issue. Interesting that the newer nightly compiler creates these new
> relocations for the code!

Thanks a lot for the report and for confirming that worked for you!

I'll take a look at fixing those soon.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: drivers/char/rust_example fails to load
  2021-03-22 12:20     ` drivers/char/rust_example fails to load Miguel Ojeda
@ 2021-03-23  1:24       ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-23  1:24 UTC (permalink / raw)
  To: Joshua Abraham; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, linux-kernel

On Mon, Mar 22, 2021 at 1:20 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> I'll take a look at fixing those soon.

For those that may read this or run into the same issue: this started
with the LLVM 12 upgrade in rustc nightlies. Therefore, please avoid
the very latest nightlies (>= nightly-2021-03-05) until [1] is
resolved.

To automatically setup a known-to-work nightly for Rust for Linux (the
one we use the most in the CI), run:

    rustup default nightly-2021-02-20

[1] https://github.com/Rust-for-Linux/linux/issues/135

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-23  1:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22  0:13 drivers/char/rust_example fails to load Joshua Abraham
2021-03-22  1:01 ` Miguel Ojeda
2021-03-22  2:53   ` Joshua Abraham
2021-03-22  6:53     ` drivers/char/rust_example fails to load 2021-03-20 builds Geert Stappers
2021-03-22  8:22       ` Adam Bratschi-Kaye
2021-03-22 12:20     ` drivers/char/rust_example fails to load Miguel Ojeda
2021-03-23  1:24       ` Miguel Ojeda

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).