Lines Matching +full:2 +full:-
2 # SPDX-License-Identifier: GPL-2.0
6 set -e
8 min_tool_version=$(dirname $0)/min-tool-version.sh
10 # Convert the version string x.y.z to a canonical up-to-7-digits form.
18 set -- $1
19 echo $((100000 * $1 + 100 * $2 + $3))
25 echo >&2 "***"
26 echo >&2 "*** Please see Documentation/rust/quick-start.rst for details"
27 echo >&2 "*** on how to set up the Rust support."
28 echo >&2 "***"
34 echo >&2 "***"
35 echo >&2 "*** This script is intended to be called from Kbuild."
36 echo >&2 "*** Please use the 'rustavailable' target to call it instead."
37 echo >&2 "*** Otherwise, the results may not be meaningful."
44 trap 'if [ $? -ne 0 ] || [ $warning -ne 0 ]; then print_docs_reference; fi' EXIT
47 if [ -z "${RUSTC+x}" ]; then
48 echo >&2 "***"
49 echo >&2 "*** Environment variable 'RUSTC' is not set."
53 if [ -z "${BINDGEN+x}" ]; then
54 echo >&2 "***"
55 echo >&2 "*** Environment variable 'BINDGEN' is not set."
59 if [ -z "${CC+x}" ]; then
60 echo >&2 "***"
61 echo >&2 "*** Environment variable 'CC' is not set."
66 if ! command -v "$RUSTC" >/dev/null; then
67 echo >&2 "***"
68 echo >&2 "*** Rust compiler '$RUSTC' could not be found."
69 echo >&2 "***"
74 if ! command -v "$BINDGEN" >/dev/null; then
75 echo >&2 "***"
76 echo >&2 "*** Rust bindings generator '$BINDGEN' could not be found."
77 echo >&2 "***"
83 # Non-stable and distributions' versions may have a version suffix, e.g. `-dev`.
85 LC_ALL=C "$RUSTC" --version 2>/dev/null
87 if [ -n "$rust_compiler_code" ]; then
88 echo >&2 "***"
89 echo >&2 "*** Running '$RUSTC' to check the Rust compiler version failed with"
90 echo >&2 "*** code $rust_compiler_code. See output and docs below for details:"
91 echo >&2 "***"
92 echo >&2 "$rust_compiler_output"
93 echo >&2 "***"
98 | sed -nE '1s:.*rustc ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
100 if [ -z "$rust_compiler_version" ]; then
101 echo >&2 "***"
102 echo >&2 "*** Running '$RUSTC' to check the Rust compiler version did not return"
103 echo >&2 "*** an expected output. See output and docs below for details:"
104 echo >&2 "***"
105 echo >&2 "$rust_compiler_output"
106 echo >&2 "***"
112 if [ "$rust_compiler_cversion" -lt "$rust_compiler_min_cversion" ]; then
113 echo >&2 "***"
114 echo >&2 "*** Rust compiler '$RUSTC' is too old."
115 echo >&2 "*** Your version: $rust_compiler_version"
116 echo >&2 "*** Minimum version: $rust_compiler_min_version"
117 echo >&2 "***"
123 # Non-stable and distributions' versions may have a version suffix, e.g. `-dev`.
125 # The dummy parameter `workaround-for-0.69.0` is required to support 0.69.0
126 # (https://github.com/rust-lang/rust-bindgen/pull/2678). It can be removed when
129 LC_ALL=C "$BINDGEN" --version workaround-for-0.69.0 2>/dev/null
131 if [ -n "$rust_bindings_generator_code" ]; then
132 echo >&2 "***"
133 echo >&2 "*** Running '$BINDGEN' to check the Rust bindings generator version failed with"
134 echo >&2 "*** code $rust_bindings_generator_code. See output and docs below for details:"
135 echo >&2 "***"
136 echo >&2 "$rust_bindings_generator_output"
137 echo >&2 "***"
142 | sed -nE '1s:.*bindgen ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
144 if [ -z "$rust_bindings_generator_version" ]; then
145 echo >&2 "***"
146 echo >&2 "*** Running '$BINDGEN' to check the bindings generator version did not return"
147 echo >&2 "*** an expected output. See output and docs below for details:"
148 echo >&2 "***"
149 echo >&2 "$rust_bindings_generator_output"
150 echo >&2 "***"
156 if [ "$rust_bindings_generator_cversion" -lt "$rust_bindings_generator_min_cversion" ]; then
157 echo >&2 "***"
158 echo >&2 "*** Rust bindings generator '$BINDGEN' is too old."
159 echo >&2 "*** Your version: $rust_bindings_generator_version"
160 echo >&2 "*** Minimum version: $rust_bindings_generator_min_version"
161 echo >&2 "***"
164 if [ "$rust_bindings_generator_cversion" -eq 6600 ] ||
165 [ "$rust_bindings_generator_cversion" -eq 6601 ]; then
168 echo >&2 "***"
169 echo >&2 "*** Rust bindings generator '$BINDGEN' versions 0.66.0 and 0.66.1 may not"
170 echo >&2 "*** work due to a bug (https://github.com/rust-lang/rust-bindgen/pull/2567),"
171 echo >&2 "*** unless patched (like Debian's)."
172 echo >&2 "*** Your version: $rust_bindings_generator_version"
173 echo >&2 "***"
184 LC_ALL=C "$BINDGEN" $(dirname $0)/rust_is_available_bindgen_libclang.h 2>&1 >/dev/null
186 if [ -n "$bindgen_libclang_code" ]; then
187 echo >&2 "***"
188 echo >&2 "*** Running '$BINDGEN' to check the libclang version (used by the Rust"
189 echo >&2 "*** bindings generator) failed with code $bindgen_libclang_code. This may be caused by"
190 echo >&2 "*** a failure to locate libclang. See output and docs below for details:"
191 echo >&2 "***"
192 echo >&2 "$bindgen_libclang_output"
193 echo >&2 "***"
204 | sed -nE 's:.*clang version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
206 if [ -z "$bindgen_libclang_version" ]; then
207 echo >&2 "***"
208 echo >&2 "*** Running '$BINDGEN' to check the libclang version (used by the Rust"
209 echo >&2 "*** bindings generator) did not return an expected output. See output"
210 echo >&2 "*** and docs below for details:"
211 echo >&2 "***"
212 echo >&2 "$bindgen_libclang_output"
213 echo >&2 "***"
219 if [ "$bindgen_libclang_cversion" -lt "$bindgen_libclang_min_cversion" ]; then
220 echo >&2 "***"
221 echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN') is too old."
222 echo >&2 "*** Your version: $bindgen_libclang_version"
223 echo >&2 "*** Minimum version: $bindgen_libclang_min_version"
224 echo >&2 "***"
232 # https://github.com/rust-lang/rust-bindgen/issues/2138.
233 cc_name=$($(dirname $0)/cc-version.sh $CC | cut -f1 -d' ')
236 LC_ALL=C $CC --version 2>/dev/null \
237 | sed -nE '1s:.*version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p'
240 echo >&2 "***"
241 echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN')"
242 echo >&2 "*** version does not match Clang's. This may be a problem."
243 echo >&2 "*** libclang version: $bindgen_libclang_version"
244 echo >&2 "*** Clang version: $clang_version"
245 echo >&2 "***"
252 # `$KRUSTFLAGS` is passed in case the user added `--sysroot`.
253 rustc_sysroot=$("$RUSTC" $KRUSTFLAGS --print sysroot)
254 rustc_src=${RUST_LIB_SRC:-"$rustc_sysroot/lib/rustlib/src/rust/library"}
256 if [ ! -e "$rustc_src_core" ]; then
257 echo >&2 "***"
258 echo >&2 "*** Source code for the 'core' standard library could not be found"
259 echo >&2 "*** at '$rustc_src_core'."
260 echo >&2 "***"