From 1a698c75ae5f47b4cc875170e6c3d30aac0a8a24 Mon Sep 17 00:00:00 2001 From: Matt Jolly Date: Fri, 28 Feb 2025 23:27:59 +1000 Subject: [PATCH] build: Rust: Bump minimum Meson and bindgen version Meson 1.7.0 is required to ensure that generated bindings are suitable for use with the selected Rust compiler. Bindgen is bumped to 0.71.1 which has more permissive handling of `--rust-target`, enabling (almost) any valid Rust version to be passed as a target; `-nightly` and `-beta*` suffixes are an exception to this. This behaviour is expected to improve further with later versions of Meson; upstream fixes have landed that: - pass a stripped version string to bindgen - additionally pass an appropriate `--rust-edition` if `rust_std` is set (or "nightly" if the compiler is `nightly`). Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12680 Bug: https://bugs.gentoo.org/946913 Signed-off-by: Matt Jolly Reviewed-by: Karol Herbst Part-of: --- .gitlab-ci/container/build-bindgen.sh | 2 +- .gitlab-ci/container/install-meson.sh | 4 ++-- .gitlab-ci/image-tags.yml | 8 ++++---- meson.build | 25 +++++++------------------ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci/container/build-bindgen.sh b/.gitlab-ci/container/build-bindgen.sh index 7b81e0b2d79..709a9352b07 100644 --- a/.gitlab-ci/container/build-bindgen.sh +++ b/.gitlab-ci/container/build-bindgen.sh @@ -8,7 +8,7 @@ uncollapsed_section_start bindgen "Building bindgen" -BINDGEN_VER=0.65.1 +BINDGEN_VER=0.71.1 CBINDGEN_VER=0.26.0 # bindgen diff --git a/.gitlab-ci/container/install-meson.sh b/.gitlab-ci/container/install-meson.sh index 3fb19a3db2a..aaca93768bd 100644 --- a/.gitlab-ci/container/install-meson.sh +++ b/.gitlab-ci/container/install-meson.sh @@ -8,5 +8,5 @@ rm -f /usr/lib/python3.*/EXTERNALLY-MANAGED -# We need at least 1.4.0 for rusticl -pip3 install 'meson==1.4.0' +# We need at least 1.7.0 for proper rust binding generation +pip3 install 'meson==1.7.0' diff --git a/.gitlab-ci/image-tags.yml b/.gitlab-ci/image-tags.yml index 4329cc8ed86..f332b39f362 100644 --- a/.gitlab-ci/image-tags.yml +++ b/.gitlab-ci/image-tags.yml @@ -19,20 +19,20 @@ include: - .gitlab-ci/conditional-build-image-tags.yml variables: - DEBIAN_BASE_TAG: "20250526-barermetal" + DEBIAN_BASE_TAG: "20250611-rust" - DEBIAN_BUILD_TAG: "20250515-aarch64" + DEBIAN_BUILD_TAG: "20250611-rust" DEBIAN_TEST_ANDROID_TAG: "20250611-angle-c3" DEBIAN_TEST_GL_TAG: "20250611-piglit-a0a" DEBIAN_TEST_VIDEO_TAG: "20250609-helper" DEBIAN_TEST_VK_TAG: "20250611-piglit-a0a" - ALPINE_X86_64_BUILD_TAG: "20250423-rootfs" + ALPINE_X86_64_BUILD_TAG: "20250611-rust" ALPINE_X86_64_LAVA_SSH_TAG: "20250423-rootfs" ALPINE_X86_64_LAVA_TRIGGER_TAG: "20250610-eval" - FEDORA_X86_64_BUILD_TAG: "20250423-rootfs" + FEDORA_X86_64_BUILD_TAG: "20250611-rust" KERNEL_TAG: "v6.14-mesa-0e36" KERNEL_REPO: "gfx-ci/linux" diff --git a/meson.build b/meson.build index 7462bba29e7..209f3fdb9b9 100644 --- a/meson.build +++ b/meson.build @@ -737,16 +737,9 @@ if with_gallium_rusticl endif if with_gallium_rusticl or with_nouveau_vk or with_tools.contains('etnaviv') - if with_gallium_rusticl - # uses rust.bindgen.output_inline_wrapper needing 1.4.0 - if meson.version().version_compare('< 1.4.0') - error('Rusticl requires meson 1.4.0 or newer') - endif - else - # see https://github.com/mesonbuild/meson/issues/12758 (backported to 1.3.2) - if meson.version().version_compare('< 1.3.2') - error('Mesa Rust support requires meson 1.3.2 or newer') - endif + # rust.bindgen() does not pass `--rust-target` to bindgen until 1.7.0. + if meson.version().version_compare('< 1.7.0') + error('Mesa Rust support requires Meson 1.7.0 or newer') endif add_languages('rust', required: true) @@ -757,15 +750,11 @@ if with_gallium_rusticl or with_nouveau_vk or with_tools.contains('etnaviv') error('Mesa requires Rust 1.78.0 or newer') endif + # bindgen 0.71 is the first version that knows about `editions` bindgen_version = find_program('bindgen').version() - if bindgen_version == 'unknown' - error('Failed to detect bindgen version. If you are using bindgen 0.69.0, ' + - 'please either update to 0.69.1 or downgrade to 0.68.1. ' + - 'You can install the latest version for your user with `cargo install bindgen-cli`.') - endif - - if bindgen_version.version_compare('< 0.65') - error('Mesa requires bindgen 0.65 or newer. ' + + # unknown covers buggy 0.69.0, 0.71.0 + if bindgen_version == 'unknown' or bindgen_version.version_compare('< 0.71.1') + error('Mesa requires bindgen 0.71.1 or newer. ' + 'If your distribution does not ship a recent enough version, ' + 'you can install the latest version for your user with `cargo install bindgen-cli`.') endif