From a7de03068d24cfaa1dfb4687051c96782c6f4b97 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 30 Sep 2022 11:31:34 +0200 Subject: [PATCH] rpmbuild: Don't use default compiler flags set by rpmbuild Latest rpmbuild has an enhanced set of macros which define different compiler flags inside the build environment. Their defaults, however, may impact the overall SPDK build (and its submodules) in a bit unpredictable manner. With that in mind, make sure that defaults are not use and only flags specified by the user are kept in use. Signed-off-by: Michal Berger Change-Id: Ie3a3123011a43be78f20f805ea6f8cad6571beec Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14802 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Konrad Sztyber Reviewed-by: Krzysztof Karas --- rpmbuild/rpm.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rpmbuild/rpm.sh b/rpmbuild/rpm.sh index 10e2b1b1c..3773c5e99 100755 --- a/rpmbuild/rpm.sh +++ b/rpmbuild/rpm.sh @@ -133,6 +133,23 @@ build_macros() { macros+=(-D "build_requirements 1") macros+=(-D "build_requirements_list $build_requirements") fi + + build_macros_flags +} + +build_macros_flags() { + local flags flag + + flags=(CFLAGS CXXFLAGS LDFLAGS) + + for flag in "${flags[@]}"; do + # If we are running in the environment where the flag is set, don't touch it - + # rpmbuild will use it as is during the build. If it's not set, make sure the + # rpmbuild won't set its defaults which may affect the build in an unpredictable + # manner. + [[ -n ${!flag} ]] && continue + macros+=(-D "build_${flag,,} %{nil}") + done } gen_spec() {