Commit 9eb7e20e authored by Miguel Ojeda's avatar Miguel Ojeda

kbuild: rust_is_available: fix confusion when a version appears in the path

`bindgen`'s output for `libclang`'s version check contains paths, which
in turn may contain strings that look like version numbers [1][2]:

    .../6.1.0-dev/.../rust_is_available_bindgen_libclang.h:2:9: warning: clang version 11.1.0  [-W#pragma-messages], err: false

which the script will pick up as the version instead of the latter.

It is also the case that versions may appear after the actual version
(e.g. distribution's version text), which was the reason behind `head` [3]:

    .../rust-is-available-bindgen-libclang.h:2:9: warning: clang version 13.0.0 (Fedora 13.0.0-3.fc35) [-W#pragma-messages], err: false

Thus instead ask for a match after the `clang version` string.
Reported-by: default avatarJordan Isaacs <mail@jdisaacs.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/942 [1]
Reported-by: default avatar"Ethan D. Twardy" <ethan.twardy@gmail.com>
Closes: https://lore.kernel.org/rust-for-linux/20230528131802.6390-2-ethan.twardy@gmail.com/ [2]
Reported-by: default avatarTiago Lam <tiagolam@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/pull/789 [3]
Fixes: 78521f33 ("scripts: add `rust_is_available.sh`")
Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: default avatarEthan Twardy <ethan.twardy@gmail.com>
Tested-by: default avatarEthan Twardy <ethan.twardy@gmail.com>
Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20230616001631.463536-8-ojeda@kernel.orgSigned-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent e90db552
...@@ -157,9 +157,7 @@ fi ...@@ -157,9 +157,7 @@ fi
# of the `libclang` found by the Rust bindings generator is suitable. # of the `libclang` found by the Rust bindings generator is suitable.
bindgen_libclang_version=$( \ bindgen_libclang_version=$( \
echo "$bindgen_libclang_output" \ echo "$bindgen_libclang_output" \
| grep -F 'clang version ' \ | sed -nE 's:.*clang version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+' \
| head -n 1 \
) )
bindgen_libclang_min_version=$($min_tool_version llvm) bindgen_libclang_min_version=$($min_tool_version llvm)
bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version) bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment