libmakepkg: add extra buildflags only when buildflags is not disabled

Message ID 20220109024807.184112-1-allan@archlinux.org
State Accepted, archived
Headers show
Series libmakepkg: add extra buildflags only when buildflags is not disabled | expand

Commit Message

Allan McRae Jan. 9, 2022, 2:48 a.m. UTC
This means options=('!buildflags') will disable the addition of CFLAG
etc for LTO and debug building.

Signed-off-by: Allan McRae <allan@archlinux.org>
---

Question...  There seems to be a strong opinion that LTO should be disabled
by !buildflags as it is expected that option removes all buildflags.  Should
that apply to debug flags too?

 scripts/libmakepkg/buildenv/debugflags.sh.in | 2 +-
 scripts/libmakepkg/buildenv/lto.sh.in        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in
index 84ca7b71..1cb58613 100644
--- a/scripts/libmakepkg/buildenv/debugflags.sh.in
+++ b/scripts/libmakepkg/buildenv/debugflags.sh.in
@@ -29,7 +29,7 @@  source "$LIBRARY/util/option.sh"
 buildenv_functions+=('buildenv_debugflags')
 
 buildenv_debugflags() {
-	if check_option "debug" "y"; then
+	if check_option "debug" "y" && ! check_option "buildflags" "n"; then
 		DEBUG_CFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
 		DEBUG_CXXFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
 		DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
diff --git a/scripts/libmakepkg/buildenv/lto.sh.in b/scripts/libmakepkg/buildenv/lto.sh.in
index 081d5648..6e500eab 100644
--- a/scripts/libmakepkg/buildenv/lto.sh.in
+++ b/scripts/libmakepkg/buildenv/lto.sh.in
@@ -30,7 +30,7 @@  build_options+=('lto')
 buildenv_functions+=('buildenv_lto')
 
 buildenv_lto() {
-	if check_option "lto" "y"; then
+	if check_option "lto" "y" && ! check_option "buildflags" "n"; then
 		CFLAGS+=" -flto"
 		CXXFLAGS+=" -flto"
 		LDFLAGS+=" -flto"