+From 44652d6c7fe9c61ac417db9dd05ec27e3c6e20f9 Mon Sep 17 00:00:00 2001
+From: Stefan Hajnoczi <stefanha@redhat.com>
+Date: Mon, 12 Dec 2022 14:58:07 -0500
+Subject: [PATCH] cargo-build.sh: inherit $RUSTFLAGS
+
+When a packaging system like rpm invokes "meson build" in meson 0.64.0
+or later, it can use buildtype "plain" to control compiler flags itself
+via the CFLAGS, CXXFLAGS, and, in our case, RUSTFLAGS environment
+variables.
+
+Don't clobber RUSTFLAGS in src/cargo-build.sh. Simply append our own
+options to RUSTFLAGS. That way src/cargo-build.sh still controls
+compiler options when necessary, but inherits them from the build
+environment (especially in the buildtype "plain" case).
+
+See https://bugzilla.redhat.com/show_bug.cgi?id=2124697#c67 for Fedora
+packaging discussion around this topic.
+
+Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
+---
+ src/cargo-build.sh | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/cargo-build.sh b/src/cargo-build.sh
+index 9879d44..d4785ce 100755
+--- a/src/cargo-build.sh
++++ b/src/cargo-build.sh
+@@ -50,10 +50,10 @@ then
+ fi
+
+ if [[ "${profile}" == "debug" ]] && command -v cargo-clippy >/dev/null; then
+- ( set -x && RUSTFLAGS="${rustflags[*]}" cargo clippy "${args[@]}" --color always \
++ ( set -x && RUSTFLAGS="$RUSTFLAGS ${rustflags[*]}" cargo clippy "${args[@]}" --color always \
+ --locked --all-features --all-targets --workspace -- --deny warnings )
+ fi
+
+-( set -x && RUSTFLAGS="${rustflags[*]}" cargo build "${args[@]}" --color always \
++( set -x && RUSTFLAGS="$RUSTFLAGS ${rustflags[*]}" cargo build "${args[@]}" --color always \
+ --locked )
+ cp "src/target/${profile}/libblkio.so" "src/libblkio.so.${version}"
+--
+GitLab
+