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 <michal.berger@intel.com>
Change-Id: Ie3a3123011a43be78f20f805ea6f8cad6571beec
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14802
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
This commit is contained in:
Michal Berger 2022-09-30 11:31:34 +02:00 committed by Tomasz Zawadzki
parent 23019242d7
commit a7de03068d

View File

@ -133,6 +133,23 @@ build_macros() {
macros+=(-D "build_requirements 1") macros+=(-D "build_requirements 1")
macros+=(-D "build_requirements_list $build_requirements") macros+=(-D "build_requirements_list $build_requirements")
fi 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() { gen_spec() {