llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* Rust for linux build error due to Clang (bindgen) version
@ 2023-07-04  8:58 Yuta Hayama
  2023-07-04 18:28 ` Miguel Ojeda
  0 siblings, 1 reply; 3+ messages in thread
From: Yuta Hayama @ 2023-07-04  8:58 UTC (permalink / raw)
  To: rust-for-linux, llvm; +Cc: linux-kernel, Yuta Hayama

Hi,

I am a beginner in Rust and LLVM, so sorry if this is a rudimentary question.
I tried to build with CONFIG_RUST=y on the torvalds/linux kernel and got the
following error:

$ LANG=C make O=../build_6.5rc_pre LLVM=1

... (snip)

  RUSTC L rust/core.o
  EXPORTS rust/exports_core_generated.h
  RUSTC P rust/libmacros.so
  BINDGEN rust/bindings/bindings_generated.rs
thread 'main' panicked at '"ftrace_branch_data_union_(anonymous_at_/home/lineo/kernel/git_kernel_org/torvalds_linux/linux/include/linux/compiler_types_h_146_2)" is not a valid Ident', /home/lineo/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.24/src/fallback.rs:693:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make[2]: *** [/home/lineo/kernel/git.kernel.org/torvalds.linux/linux/rust/Makefile:310: rust/bindings/bindings_generated.rs] Error 1
make[2]: *** Deleting file 'rust/bindings/bindings_generated.rs'
make[1]: *** [/home/lineo/kernel/git.kernel.org/torvalds.linux/linux/Makefile:1293: prepare] Error 2
make[1]: Leaving directory '/home/lineo/kernel/git.kernel.org/torvalds.linux/build_6.5rc_pre'
make: *** [Makefile:226: __sub-make] Error 2

The versions of the tools and other items used are as follows:

kernel:  torvalds/linux a1257b5e3b7f8a21faf462d0118067fe31e71ffb
rustc:   1.68.2
bindgen: 0.56.0
clang:   17.0.0


This issue seems similar to what is described at the following URL.
https://stackoverflow.com/questions/76443280/rust-bindgen-causes-a-is-not-a-valid-ident-error-on-build

If this explanation is correct, then a Clang earlier than 16 or bindgen 0.62.0
or later is needed to avoid this issue. And I searched the ML and found that
a patch to fix it already exists.
https://lore.kernel.org/rust-for-linux/20230612194311.24826-1-aakashsensharma@gmail.com/

But I think this patch is still in the rust-dev branch of the rust-for-linux
tree and has not been merged into the mainline. The current mainline kernel
seems to have a issue where if the Clang is too new (16 or later), the build
fails even though `make rustavailable` passes.

Does this mean we need something like max-tool-version.sh? But that might be
a bit silly... If such "error occurs because the tool is too new" is repeated
in the future, I feel that it is necessary to check not only the lower limit of
the tool version, but also the upper limit.


Regards,

Yuta Hayama

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

* Re: Rust for linux build error due to Clang (bindgen) version
  2023-07-04  8:58 Rust for linux build error due to Clang (bindgen) version Yuta Hayama
@ 2023-07-04 18:28 ` Miguel Ojeda
  2023-07-05  8:05   ` Yuta Hayama
  0 siblings, 1 reply; 3+ messages in thread
From: Miguel Ojeda @ 2023-07-04 18:28 UTC (permalink / raw)
  To: Yuta Hayama; +Cc: rust-for-linux, llvm, linux-kernel

On Tue, Jul 4, 2023 at 11:06 AM Yuta Hayama <hayama@lineo.co.jp> wrote:
>
> I am a beginner in Rust and LLVM, so sorry if this is a rudimentary question.

No need to apologize!

> But I think this patch is still in the rust-dev branch of the rust-for-linux
> tree and has not been merged into the mainline. The current mainline kernel
> seems to have a issue where if the Clang is too new (16 or later), the build
> fails even though `make rustavailable` passes.

The upgrade to `bindgen` will be merged after the merge window is over.

> Does this mean we need something like max-tool-version.sh? But that might be
> a bit silly... If such "error occurs because the tool is too new" is repeated
> in the future, I feel that it is necessary to check not only the lower limit of
> the tool version, but also the upper limit.

`make rustavailable` already warns for "too new" versions for `rustc`
and `bindgen`. We could add something like that (as error or warning)
for `libclang` too, but that particular issue goes away with the
upgrade in place, so (at least for mainline) it is OK.

Cheers,
Miguel

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

* Re: Rust for linux build error due to Clang (bindgen) version
  2023-07-04 18:28 ` Miguel Ojeda
@ 2023-07-05  8:05   ` Yuta Hayama
  0 siblings, 0 replies; 3+ messages in thread
From: Yuta Hayama @ 2023-07-05  8:05 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: rust-for-linux, llvm, linux-kernel, Yuta Hayama

Hi,

Thank you for your response!

On 2023/07/05 3:28, Miguel Ojeda wrote:
> On Tue, Jul 4, 2023 at 11:06 AM Yuta Hayama <hayama@lineo.co.jp> wrote:

>> Does this mean we need something like max-tool-version.sh? But that might be
>> a bit silly... If such "error occurs because the tool is too new" is repeated
>> in the future, I feel that it is necessary to check not only the lower limit of
>> the tool version, but also the upper limit.
> 
> `make rustavailable` already warns for "too new" versions for `rustc`
> and `bindgen`.

Yes, I checked this. What I was noticed is that these tools have the same
lower and upper limits for the required version. (so min-tool-version.sh
was sufficient.) Since there is a range between the lower and upper limits
for Clang, I thought that if we are going to do version checking, we need
to extend min-tool-version.sh or something related to it.

> We could add something like that (as error or warning)
> for `libclang` too, but that particular issue goes away with the
> upgrade in place, so (at least for mainline) it is OK.

I understand that at least this issue will be fixed in the near future (v6.6?).
I will wait and see for a while...


Regards,

Yuta Hayama

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

end of thread, other threads:[~2023-07-05  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04  8:58 Rust for linux build error due to Clang (bindgen) version Yuta Hayama
2023-07-04 18:28 ` Miguel Ojeda
2023-07-05  8:05   ` Yuta Hayama

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