rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Getting Rust to work
@ 2021-03-21 19:37 Pavel Machek
  2021-03-21 20:03 ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2021-03-21 19:37 UTC (permalink / raw)
  To: ojeda, alex.gaynor, rust-for-linux, kernel list

[-- Attachment #1: Type: text/plain, Size: 2735 bytes --]

Hi!

First try was on x86-32. It took me a whlie to figure out the problem,
hence the diff below.

Next I was not sure what to do with rustup. I'm not sure if advice
below is good.

Then I got failure because libclang (?) was not installed. I installed
it. But I guess that should be mentioned in docs as dependency.

With CONFIG_RUST unset, kernel builds for me. With CONFIG_RUST=y +
RUST_EXAMPLE=y... I get errors:

  RUSTC L rust/core.o
  BINDGEN rust/bindings_generated.rs
error: unknown argument: '-fmacro-prefix-map=./='
error: unknown warning option '-Wno-frame-address'; did you mean '-Wno-address'? [-Wunknown-warning-option]
./arch/x86/include/asm/bitops.h:138:9: error: 'asm goto' constructs are not supported yet
./arch/x86/include/asm/bitops.h:162:9: error: 'asm goto' constructs are not supported yet
./arch/x86/include/asm/bitops.h:201:9: error: 'asm goto' constructs are not supported yet
./include/linux/list.h:282:9: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
./include/linux/list.h:318:27: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
./include/linux/list.h:821:10: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
./include/linux/list.h:830:10: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
./arch/x86/include/asm/atomic.h:83:9: error: 'asm goto' constructs are not supported yet
./arch/x86/include/asm/atomic.h:123:9: error: 'asm goto' constructs are not supported yet
./arch/x86/include/asm/atomic.h:137:9: error: 'asm goto' constructs are not supported yet
./arch/x86/include/asm/atomic.h:152:9: error: 'asm goto' constructs are not supported yet

$ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
$ rustc --version
rustc 1.52.0-nightly (61edfd591 2021-03-20)

Ideas?

Best regards,
								Pavel



diff --git a/Documentation/rust/quick-start.rst b/Documentation/rust/quick-start.rst
index 33b5cd33ecc5..d034369b3d43 100644
--- a/Documentation/rust/quick-start.rst
+++ b/Documentation/rust/quick-start.rst
@@ -16,6 +16,8 @@ Some of these requirements might be available from your Linux distribution
 under names like ``rustc``, ``rust-src``, ``rust-bindgen``, etc. However,
 at the time of writing, they are likely to not be recent enough.
 
+You need to have x86-64 or arm64 system.
+
 
 rustc
 *****
@@ -32,6 +34,8 @@ Otherwise, fetch a standalone installer or install ``rustup`` from:
 
     https://www.rust-lang.org
 
+    (if you have multiple toolchains, do rustup default nightly-i686-unknown-linux-gnu )
+
 
 Rust standard library source
 ****************************

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Getting Rust to work
  2021-03-21 19:37 Getting Rust to work Pavel Machek
@ 2021-03-21 20:03 ` Miguel Ojeda
  2021-03-21 20:56   ` Pavel Machek
  2021-03-22  2:34   ` Miguel Ojeda
  0 siblings, 2 replies; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-21 20:03 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

Hi Pavel,

On Sun, Mar 21, 2021 at 8:37 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> First try was on x86-32. It took me a whlie to figure out the problem,
> hence the diff below.

Thanks a lot for trying it out and for the feedback! :-)

The supported architectures are in
Documentation/rust/arch-support.rst, so we should link to that.

x86 32-bit and other architectures should eventually work -- we need
to put some time into them and setting up a few things. For the moment
we focused on x86_64 and arm64.

> Then I got failure because libclang (?) was not installed. I installed
> it. But I guess that should be mentioned in docs as dependency.

Yeah, this is mentioned on the bindgen section in quick-start.rst, I
will try to improve make it more clear, perhaps I'll a section for
libclang itself.

> With CONFIG_RUST unset, kernel builds for me. With CONFIG_RUST=y +
> RUST_EXAMPLE=y... I get errors:

Typically it is due to a kernel option that enables some GCC flag that
libclang does not know about -- I have a hack in place to make it
work, but requires manual maintenance. Can you please attach your
kernel config?

Meanwhile, please try building with Clang or LLVM instead, the GCC
builds are very, very experimental. I'll make it even more explicit in
the quick-start.

Cheers,
Miguel

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

* Re: Getting Rust to work
  2021-03-21 20:03 ` Miguel Ojeda
@ 2021-03-21 20:56   ` Pavel Machek
  2021-03-21 21:26     ` Miguel Ojeda
  2021-03-21 21:58     ` Miguel Ojeda
  2021-03-22  2:34   ` Miguel Ojeda
  1 sibling, 2 replies; 7+ messages in thread
From: Pavel Machek @ 2021-03-21 20:56 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

[-- Attachment #1: Type: text/plain, Size: 1650 bytes --]

Hi!

> > First try was on x86-32. It took me a whlie to figure out the problem,
> > hence the diff below.
> 
> Thanks a lot for trying it out and for the feedback! :-)

Thanks for your work :-).

> The supported architectures are in
> Documentation/rust/arch-support.rst, so we should link to that.
> 
> x86 32-bit and other architectures should eventually work -- we need
> to put some time into them and setting up a few things. For the moment
> we focused on x86_64 and arm64.

Actually x86-32 would be useful for me. That's my test machine.

> > Then I got failure because libclang (?) was not installed. I installed
> > it. But I guess that should be mentioned in docs as dependency.
> 
> Yeah, this is mentioned on the bindgen section in quick-start.rst, I
> will try to improve make it more clear, perhaps I'll a section for
> libclang itself.

Aha, sorry, it is possible I was not careful enough reading the docs.

> > With CONFIG_RUST unset, kernel builds for me. With CONFIG_RUST=y +
> > RUST_EXAMPLE=y... I get errors:
> 
> Typically it is due to a kernel option that enables some GCC flag that
> libclang does not know about -- I have a hack in place to make it
> work, but requires manual maintenance. Can you please attach your
> kernel config?

Done, in a private message.

> Meanwhile, please try building with Clang or LLVM instead, the GCC
> builds are very, very experimental. I'll make it even more explicit in
> the quick-start.

I tried, but newest in my distribution is clang-7, and kernel needs
clang-10.

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Getting Rust to work
  2021-03-21 20:56   ` Pavel Machek
@ 2021-03-21 21:26     ` Miguel Ojeda
  2021-03-21 21:58     ` Miguel Ojeda
  1 sibling, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-21 21:26 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

On Sun, Mar 21, 2021 at 9:56 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> Thanks for your work :-).

You're welcome! We're trying our best :-)

> Actually x86-32 would be useful for me. That's my test machine.

Sorry... :-( x86 32-bits, ppc64el, s390x... are some of the ones we
will look into soon, but possibly after the RFC.

> I tried, but newest in my distribution is clang-7, and kernel needs
> clang-10.

If you are under Debian-like distributions, these apt repos are easy
to set up (we use them in the CI, in fact):

    https://apt.llvm.org/

Cheers,
Miguel

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

* Re: Getting Rust to work
  2021-03-21 20:56   ` Pavel Machek
  2021-03-21 21:26     ` Miguel Ojeda
@ 2021-03-21 21:58     ` Miguel Ojeda
  2021-03-21 22:05       ` Miguel Ojeda
  1 sibling, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-21 21:58 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

On Sun, Mar 21, 2021 at 9:56 PM Pavel Machek <pavel@ucw.cz> wrote:
>
> Done, in a private message.

I tried your config and it worked, so it looks like the problem is
your old libclang (7) does not recognize some of the flags. If you can
try a newer LLVM installation, it would be great to confirm it.

Nevertheless, thanks a lot for providing it -- it was useful to test it.

Cheers,
Miguel

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

* Re: Getting Rust to work
  2021-03-21 21:58     ` Miguel Ojeda
@ 2021-03-21 22:05       ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-21 22:05 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

On Sun, Mar 21, 2021 at 10:58 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> I tried your config and it worked, so it looks like the problem is
> your old libclang (7) does not recognize some of the flags. If you can
> try a newer LLVM installation, it would be great to confirm it.

Yeah, LLVM introduced asm goto in 9.0 [1], which makes sense if you
were running libclang-7.

[1] https://lists.llvm.org/pipermail/llvm-dev/2019-September/135304.html

Cheers,
Miguel

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

* Re: Getting Rust to work
  2021-03-21 20:03 ` Miguel Ojeda
  2021-03-21 20:56   ` Pavel Machek
@ 2021-03-22  2:34   ` Miguel Ojeda
  1 sibling, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2021-03-22  2:34 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Miguel Ojeda, Alex Gaynor, rust-for-linux, kernel list

On Sun, Mar 21, 2021 at 9:03 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> The supported architectures are in
> Documentation/rust/arch-support.rst, so we should link to that.
>
> Yeah, this is mentioned on the bindgen section in quick-start.rst, I
> will try to improve make it more clear, perhaps I'll a section for
> libclang itself.

Done, see if you like
https://github.com/Rust-for-Linux/linux/blob/rust/Documentation/rust/quick-start.rst
:-)

Cheers,
Miguel

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

end of thread, other threads:[~2021-03-22  2:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 19:37 Getting Rust to work Pavel Machek
2021-03-21 20:03 ` Miguel Ojeda
2021-03-21 20:56   ` Pavel Machek
2021-03-21 21:26     ` Miguel Ojeda
2021-03-21 21:58     ` Miguel Ojeda
2021-03-21 22:05       ` Miguel Ojeda
2021-03-22  2:34   ` 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).