Message ID | 20241027145636.416030-1-ojeda@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | kbuild: rust: avoid errors with old `rustc`s without LLVM patch version | expand |
On Sun, Oct 27, 2024 at 3:56 PM Miguel Ojeda <ojeda@kernel.org> wrote: > > Thus, instead, just make the match stricter. The fix was very quickly confirmed by Cameron in bugzilla -- thanks! Tested-by: Cameron MacPherson <cameron.macpherson@gmail.com> Cheers, Miguel
On Sun, Oct 27, 2024 at 3:56 PM Miguel Ojeda <ojeda@kernel.org> wrote: > > Thus, instead, just make the match stricter. Applied to `rust-fixes` early to start getting it in tomorrow's -next -- thanks! Cheers, Miguel
On Sun, Oct 27, 2024 at 03:56:36PM +0100, Miguel Ojeda wrote: > Some old versions of `rustc` did not report the LLVM version without > the patch version, e.g.: > > $ rustc --version --verbose > rustc 1.48.0 (7eac88abb 2020-11-16) > binary: rustc > commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4 > commit-date: 2020-11-16 > host: x86_64-unknown-linux-gnu > release: 1.48.0 > LLVM version: 11.0 > > Which would make the new `scripts/rustc-llvm-version.sh` fail and, > in turn, the build: > > $ make LLVM=1 > SYNC include/config/auto.conf.cmd > ./scripts/rustc-llvm-version.sh: 13: arithmetic expression: expecting primary: "10000 * 10 + 100 * 0 + " > init/Kconfig:83: syntax error > init/Kconfig:83: invalid statement > make[3]: *** [scripts/kconfig/Makefile:85: syncconfig] Error 1 > make[2]: *** [Makefile:679: syncconfig] Error 2 > make[1]: *** [/home/cam/linux/Makefile:780: include/config/auto.conf.cmd] Error 2 > make: *** [Makefile:224: __sub-make] Error 2 > > Since we do not need to support such binaries, we can avoid adding logic > for computing `rustc`'s LLVM version for those old binaries. > > Thus, instead, just make the match stricter. > > Other `rustc` binaries (even newer) did not report the LLVM version at > all, but that was fine, since it would not match "LLVM", e.g.: > > $ rustc --version --verbose > rustc 1.49.0 (e1884a8e3 2020-12-29) > binary: rustc > commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca > commit-date: 2020-12-29 > host: x86_64-unknown-linux-gnu > release: 1.49.0 > > Cc: Thorsten Leemhuis <regressions@leemhuis.info> > Cc: Gary Guo <gary@garyguo.net> > Reported-by: Cameron MacPherson <cameron.macpherson@gmail.com> > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219423 > Fixes: af0121c2d303 ("kbuild: rust: add `CONFIG_RUSTC_LLVM_VERSION`") > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> and it still works for me with rustc 1.82.0: Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> > --- > scripts/rustc-llvm-version.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/rustc-llvm-version.sh b/scripts/rustc-llvm-version.sh > index b6063cbe5bdc..a500d1ae3101 100755 > --- a/scripts/rustc-llvm-version.sh > +++ b/scripts/rustc-llvm-version.sh > @@ -13,7 +13,7 @@ get_canonical_version() > echo $((10000 * $1 + 100 * $2 + $3)) > } > > -if output=$("$@" --version --verbose 2>/dev/null | grep LLVM); then > +if output=$("$@" --version --verbose 2>/dev/null | grep -E 'LLVM.*[0-9]+\.[0-9]+\.[0-9]+'); then > set -- $output > get_canonical_version $3 > else > -- > 2.47.0 >
On Sun, Oct 27, 2024 at 11:25 PM Nathan Chancellor <nathan@kernel.org> wrote: > > and it still works for me with rustc 1.82.0: > > Reviewed-by: Nathan Chancellor <nathan@kernel.org> > Tested-by: Nathan Chancellor <nathan@kernel.org> Thanks for checking! I took the tags. Cheers, Miguel
diff --git a/scripts/rustc-llvm-version.sh b/scripts/rustc-llvm-version.sh index b6063cbe5bdc..a500d1ae3101 100755 --- a/scripts/rustc-llvm-version.sh +++ b/scripts/rustc-llvm-version.sh @@ -13,7 +13,7 @@ get_canonical_version() echo $((10000 * $1 + 100 * $2 + $3)) } -if output=$("$@" --version --verbose 2>/dev/null | grep LLVM); then +if output=$("$@" --version --verbose 2>/dev/null | grep -E 'LLVM.*[0-9]+\.[0-9]+\.[0-9]+'); then set -- $output get_canonical_version $3 else
Some old versions of `rustc` did not report the LLVM version without the patch version, e.g.: $ rustc --version --verbose rustc 1.48.0 (7eac88abb 2020-11-16) binary: rustc commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4 commit-date: 2020-11-16 host: x86_64-unknown-linux-gnu release: 1.48.0 LLVM version: 11.0 Which would make the new `scripts/rustc-llvm-version.sh` fail and, in turn, the build: $ make LLVM=1 SYNC include/config/auto.conf.cmd ./scripts/rustc-llvm-version.sh: 13: arithmetic expression: expecting primary: "10000 * 10 + 100 * 0 + " init/Kconfig:83: syntax error init/Kconfig:83: invalid statement make[3]: *** [scripts/kconfig/Makefile:85: syncconfig] Error 1 make[2]: *** [Makefile:679: syncconfig] Error 2 make[1]: *** [/home/cam/linux/Makefile:780: include/config/auto.conf.cmd] Error 2 make: *** [Makefile:224: __sub-make] Error 2 Since we do not need to support such binaries, we can avoid adding logic for computing `rustc`'s LLVM version for those old binaries. Thus, instead, just make the match stricter. Other `rustc` binaries (even newer) did not report the LLVM version at all, but that was fine, since it would not match "LLVM", e.g.: $ rustc --version --verbose rustc 1.49.0 (e1884a8e3 2020-12-29) binary: rustc commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca commit-date: 2020-12-29 host: x86_64-unknown-linux-gnu release: 1.49.0 Cc: Thorsten Leemhuis <regressions@leemhuis.info> Cc: Gary Guo <gary@garyguo.net> Reported-by: Cameron MacPherson <cameron.macpherson@gmail.com> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219423 Fixes: af0121c2d303 ("kbuild: rust: add `CONFIG_RUSTC_LLVM_VERSION`") Signed-off-by: Miguel Ojeda <ojeda@kernel.org> --- scripts/rustc-llvm-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)