Skip to contentSkip to conversation

Build system can't detect rustc

DISCUSSION Sumera Priyadarsini 4 participants 12 messages Mar 15, 2021 – Mar 17, 2021 Rust

lore
Share & tools
lore
#0 lore raw

Hi all,

I was trying to build the rust-for-linux as per the instructions here
(https://github.com/Rust-for-Linux/linux/blob/rust/Documentation/rust/quick-start.rst)
but CONFIG_RUST doesn't show up in General setup menu when I try to setup the config file with make nconfig. Since it says the build system is supposed to be able to locate rustc, I am guessing make is unable to find rustc.

Could you point me to where make is trying to find rust or how I can try fixing this? Is there anything else I might have missed out on? I have the latest rust nightly installed.

Cheers,
Sumera

#1 lore raw
Quoted 9 lines · Sumera Priyadarsini

Hi all,

I was trying to build the rust-for-linux as per the instructions here
(https://github.com/Rust-for-Linux/linux/blob/rust/Documentation/rust/quick-start.rst)
but CONFIG_RUST doesn't show up in General setup menu when I try to setup the config file with make nconfig. Since it says the build system is supposed to be able to locate rustc, I am guessing make is unable to find rustc.

Quoted 3 lines

Could you point me to where make is trying to find rust or how I can try fixing this?
Is there anything else I might have missed out on?

State which Linux kernel source tree you are using.

The reply that is expect is a git clone URL and git branch name.

Quoted 1 line

I have the latest rust nightly installed.

Tell more about where it is installed.

The reply that is expect is a Linux distro name plus version.

Regards
Geert Stappers
First posting on this mailinglist.
Completely fine with other replies as expected.
Did not a "reply to all", did a "reply to list".

Signature · 1 line
Silence is hard to parse
#2 lore raw
In reply to Sumera Priyadarsini

Hi Sumera,

Quoted 4 lines · Sumera Priyadarsini

Could you point me to where make is trying to find rust or how I can try fixing this? Is there anything else I might have missed out on? I have the latest rust nightly installed.

By default, it will call rustc as-is, so make sure it is on your $PATH:

    $ which rustc
    /some/path/bin/rustc

Another reason could be that you are using the master branch instead of the rust branch.

HTH,

Cheers,
Miguel

#3 lore raw
Quoted 12 lines · Miguel Ojeda

Hi Sumera,

Quoted 4 lines · Sumera Priyadarsini

Could you point me to where make is trying to find rust or how I can try fixing this? Is there anything else I might have missed out on? I have the latest rust nightly installed.

By default, it will call rustc as-is, so make sure it is on your $PATH:

Quoted 8 lines
    $ which rustc
    /some/path/bin/rustc

Another reason could be that you are using the master branch instead of the rust branch.

HTH,

Hi Miguel,

This definitely helped- I was using the master branch earlier. Can I make a PR to add this to the documentation on rust/quick-start page?

I did run into some other errors while building though:

```
error: unknown argument: '-mindirect-branch=thunk-extern', err: true
error: unknown argument: '-mindirect-branch-register', err: true
error: unsupported option '-mrecord-mcount' for target
'x86_64-pc-linux-gnu', err: true
thread 'main' panicked at 'Unable to generate bindings: ()'
```

The full logs are here: https://paste.ubuntu.com/p/xqd4pMBdrb/

Since a few places online suggested the error might be related to gcc and clang, I tried compiling with clang versions 9.0 /10.0 /11.0 and gcc versions 8 /9 / 10 but the error persists. I am not sure how to proceed here :/

Thanks,
Sumera

Quoted 2 lines

Cheers,
Miguel

#4 lore raw
Quoted 5 lines · Sumera Priyadarsini

Hi Miguel,

This definitely helped- I was using the master branch earlier. Can I make a PR to add this to the documentation on rust/quick-start page?

I didn't put it there since, if we manage to get this mainlined, then we would be in the master branch already. :-)

However, you can send the PR to add a line to the README.md file, which is only intended for GitHub!

Quoted 2 lines

gcc versions 8 /9 / 10 but the error persists. I am not sure how to proceed here :/

This happens when bindgen (which uses Clang internally) gets GCC parameters, but that should not happen and is a bug when it does. Which kernel config are you using? defconfig for x86_64?

To progress, please try a Clang build (pass CC=clang or LLVM=1 to make), which is much more likely to work (GCC builds rely on a hack to make bindgen work), or use one of the kernel configs inside .github/workflows/ which are known to build since we check them in the CI.

HTH,

Cheers,
Miguel

#5 lore raw

HI

I had similar issue even with LLVM=1 or CC=clang enabled.

[kaviraj@kavi-desktop-manjaro linux-rs]$ export LLVM=1 [kaviraj@kavi-desktop-manjaro linux-rs]$ make
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool

  CHK     include/generated/compile.h
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  LD      vmlinux.o

MODPOST vmlinux.symvers
MODINFO modules.builtin.modinfo
GEN modules.builtin
LD .tmp_vmlinux.kallsyms1
ld.lld: error: Unexpected GOT entries detected! ld.lld: error: Unexpected GOT entries detected! ld.lld: error: Unexpected GOT entries detected!
make: *** [Makefile:1274: vmlinux] Error 1

The thing that worked for me is to cp .github/workflows/kernel-x86_64-release.config .config and build again.

Although it would be nice to find out what is causing this when we generate config from make menuconfig (even after following the Quickstart guide)

Thanks
Kaviraj

Quoted 33 lines · Miguel Ojeda
Quoted 5 lines · Sumera Priyadarsini

Hi Miguel,

This definitely helped- I was using the master branch earlier. Can I make a PR to add this to the documentation on rust/quick-start page?

I didn't put it there since, if we manage to get this mainlined, then we would be in the master branch already. :-)

However, you can send the PR to add a line to the README.md file, which is only intended for GitHub!

Quoted 2 lines

gcc versions 8 /9 / 10 but the error persists. I am not sure how to proceed here :/

This happens when bindgen (which uses Clang internally) gets GCC parameters, but that should not happen and is a bug when it does. Which kernel config are you using? defconfig for x86_64?

To progress, please try a Clang build (pass CC=clang or LLVM=1 to make), which is much more likely to work (GCC builds rely on a hack to make bindgen work), or use one of the kernel configs inside .github/workflows/ which are known to build since we check them in the CI.

HTH,

Cheers,
Miguel

#6 lore raw
Quoted 4 lines · Kaviraj Kanagaraj

The thing that worked for me is to cp .github/workflows/kernel-x86_64-release.config .config and build again.

Although it would be nice to find out what is causing this when we generate config from make menuconfig (even after following the Quickstart guide)

Yes, soon we will need to sort out any issues from {def,allyes,allmod}configs, start running them in the CI, plus run some randconfigs etc. as usual.

For the moment, please run the included configs if you run into trouble. :-)

Cheers,
Miguel

#7 lore raw
In reply to Miguel Ojeda
Quoted 15 lines · Miguel Ojeda
Quoted 5 lines · Sumera Priyadarsini

Hi Miguel,

This definitely helped- I was using the master branch earlier. Can I make a PR to add this to the documentation on rust/quick-start page?

I didn't put it there since, if we manage to get this mainlined, then we would be in the master branch already. :-)

However, you can send the PR to add a line to the README.md file, which is only intended for GitHub!

Quoted 6 lines
Quoted 2 lines

gcc versions 8 /9 / 10 but the error persists. I am not sure how to proceed here :/

This happens when bindgen (which uses Clang internally) gets GCC parameters, but that should not happen and is a bug when it does. Which kernel config are you using? defconfig for x86_64?

Hi,

Specifying clang did work, thanks! I used "make nconfig" but I am guessing it would be the same as what 'defconfig' would have given. Here is a paste if you want to take a look:
https://paste.ubuntu.com/p/dMb3bb34Qf/

Quoted 9 lines

To progress, please try a Clang build (pass CC=clang or LLVM=1 to make), which is much more likely to work (GCC builds rely on a hack to make bindgen work), or use one of the kernel configs inside .github/workflows/ which are known to build since we check them in the CI.

HTH,

Thanks,
Sumera

Quoted 2 lines

Cheers,
Miguel

#8 lore raw
Quoted 5 lines · Sumera Priyadarsini

Specifying clang did work, thanks! I used "make nconfig" but I am guessing it would be the same as what 'defconfig' would have given. Here is a paste if you want to take a look:
https://paste.ubuntu.com/p/dMb3bb34Qf/

Please note that menuconfig (and similar commands) should be run with CC=clang as well, so that configuration is done properly for Clang.

It would be great if you can confirm make nconfig CC=clang would have worked for you (to start from scratch, including removing the configuration, use make mrproper).

Thanks!

Cheers,
Miguel

#9 lore raw
Quoted 9 lines · Miguel Ojeda
Quoted 5 lines · Sumera Priyadarsini

Specifying clang did work, thanks! I used "make nconfig" but I am guessing it would be the same as what 'defconfig' would have given. Here is a paste if you want to take a look:
https://paste.ubuntu.com/p/dMb3bb34Qf/

Quoted 7 lines

Please note that menuconfig (and similar commands) should be run with CC=clang as well, so that configuration is done properly for Clang.

It would be great if you can confirm make nconfig CC=clang would have worked for you (to start from scratch, including removing the configuration, use make mrproper).

Sorry, I missed out on this- yes, I did specify CC=clang with 'make nconfig' as well.
Without that, 'make -j4 CC=clang' started asking for config options as expected XD

Thanks for all the help :)

Cheers,
Sumera

Quoted 5 lines

Thanks!

Cheers,
Miguel

#10 lore raw
In reply to Sumera Priyadarsini
Quoted 8 lines · Sumera Priyadarsini
```
error: unknown argument: '-mindirect-branch=thunk-extern', err: true
error: unknown argument: '-mindirect-branch-register', err: true
error: unsupported option '-mrecord-mcount' for target
'x86_64-pc-linux-gnu', err: true
thread 'main' panicked at 'Unable to generate bindings: ()'
```

Reproduced with defconfig, building with GCC. I'm sending the fix.

Thanks for the report!

Cheers,
Miguel