Skip to content

Commit 28c7dba

Browse files
ojedaintel-lab-lkp
authored andcommitted
rust: warn about bindgen versions 0.66.0 and 0.66.1
`bindgen` versions 0.66.0 and 0.66.1 panic due to C string literals with NUL characters [1]: panicked at .cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.0/codegen/mod.rs:717:71: called `Result::unwrap()` on an `Err` value: FromBytesWithNulError { kind: InteriorNul(4) } Thus, in preparation for supporting several `bindgen` versions, add a version check to warn the user about it. We could make it an error, but 1) it is going to fail anyway later in the build, 2) we would disable `RUST` automatically, which is also painful, 3) someone could be using a patched `bindgen` at that version, 4) the interior NUL may go away in the headers (however unlikely). Thus just warn about it so that users know why it is failing. In addition, add a test for the new case. Link: rust-lang/rust-bindgen#2567 [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent eceec84 commit 28c7dba

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

scripts/rust_is_available.sh

+8
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ if [ "$rust_bindings_generator_cversion" -gt "$rust_bindings_generator_min_cvers
165165
echo >&2 "***"
166166
warning=1
167167
fi
168+
if [ "$rust_bindings_generator_cversion" -eq 6600 ] || [ "$rust_bindings_generator_cversion" -eq 6601 ]; then
169+
echo >&2 "***"
170+
echo >&2 "*** Rust bindings generator '$BINDGEN' versions 0.66.0 and 0.66.1 may not"
171+
echo >&2 "*** work due to a bug (https://github.com/rust-lang/rust-bindgen/pull/2567)."
172+
echo >&2 "*** Your version: $rust_bindings_generator_version"
173+
echo >&2 "***"
174+
warning=1
175+
fi
168176

169177
# Check that the `libclang` used by the Rust bindings generator is suitable.
170178
#

scripts/rust_is_available_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ def test_bindgen_new_version(self):
226226
result = self.run_script(self.Expected.SUCCESS_WITH_WARNINGS, { "BINDGEN": bindgen })
227227
self.assertIn(f"Rust bindings generator '{bindgen}' is too new. This may or may not work.", result.stderr)
228228

229+
def test_bindgen_bad_version_0_66_0_and_0_66_1(self):
230+
for version in ("0.66.0", "0.66.1"):
231+
with self.subTest(version=version):
232+
bindgen = self.generate_bindgen_version(f"bindgen {version}")
233+
result = self.run_script(self.Expected.SUCCESS_WITH_WARNINGS, { "BINDGEN": bindgen })
234+
self.assertIn(f"Rust bindings generator '{bindgen}' versions 0.66.0 and 0.66.1 may not", result.stderr)
235+
229236
def test_bindgen_libclang_failure(self):
230237
for env in (
231238
{ "LLVM_CONFIG_PATH": self.missing },

0 commit comments

Comments
 (0)