Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build CXXFLAGS not appropriately manipulated when user CXXFLAGS are present #1563

Open
ajakk opened this issue Nov 25, 2023 · 0 comments
Open

Comments

@ajakk
Copy link
Contributor

ajakk commented Nov 25, 2023

I've added a small patch to my tree to help demonstrate the issue:

$ gd
diff --git a/build/flavour-unittest.mk b/build/flavour-unittest.mk
index c6f479876..71b9f657c 100644
--- a/build/flavour-unittest.mk
+++ b/build/flavour-unittest.mk
@@ -2,7 +2,9 @@
 # Build executable that runs unit tests.

 # Debug flags.
+$(info B CXXFLAGS: $(CXXFLAGS))
 CXXFLAGS+=-O3 -g -DUNITTEST -IContrib/catch2 -fsanitize=address
+$(info C CXXFLAGS: $(CXXFLAGS))

 # Strip executable?
 OPENMSX_STRIP:=false
diff --git a/build/main.mk b/build/main.mk
index 3b7ba5889..d6c9cd02d 100644
--- a/build/main.mk
+++ b/build/main.mk
@@ -187,7 +187,9 @@ TARGET_FLAGS+=$(shell $(PYTHON) build/cpu2flags.py $(OPENMSX_TARGET_CPU))
 # ========

 # Load flavour specific settings.
+$(info A CXXFLAGS: $(CXXFLAGS))
 include build/flavour-$(OPENMSX_FLAVOUR).mk
+$(info D CXXFLAGS: $(CXXFLAGS))

 UNITTEST?=false

@@ -442,6 +444,7 @@ config:
        @echo "  Platform: $(PLATFORM)"
        @echo "  Flavour:  $(OPENMSX_FLAVOUR)"
        @echo "  Compiler: $(CXX)"
+       @echo "  CXXFLAGS: $(CXXFLAGS)"
        @echo "  Subset:   $(if $(OPENMSX_SUBSET),$(OPENMSX_SUBSET)*,full build)"
 endif

A raw unittest invocation yields:

~/git/openMSX $ make OPENMSX_FLAVOUR=unittest
Using Python: python3
A CXXFLAGS:
B CXXFLAGS:
C CXXFLAGS: -O3 -g -DUNITTEST -IContrib/catch2 -fsanitize=address
D CXXFLAGS: -O3 -g -DUNITTEST -IContrib/catch2 -fsanitize=address
Build configuration:
  Platform: x86_64-linux
  Flavour:  unittest
  Compiler: x86_64-pc-linux-gnu-g++
  CXXFLAGS: -O3 -g -DUNITTEST -IContrib/catch2 -fsanitize=address
  Subset:   full build

But doing the same with CXXFLAGS specified from the caller yields a build environment where all CXXFLAGS are set to the caller's:

~/git/openMSX $ make CXXFLAGS="user flags" OPENMSX_FLAVOUR=unittest
Using Python: python3
A CXXFLAGS: user flags
B CXXFLAGS: user flags
C CXXFLAGS: user flags
D CXXFLAGS: user flags
Build configuration:
  Platform: x86_64-linux
  Flavour:  unittest
  Compiler: x86_64-pc-linux-gnu-g++
  CXXFLAGS: user flags
  Subset:   full build

This doesn't only affect the unittest build, but it does affect it somewhat acutely because it ends up overwriting the -DUNITTEST setting, which breaks some tests.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Nov 25, 2023
Reported apparent CXXFLAGS handling regression below. Working around it
with sed, as is already done with LDFLAGS. Add python3_12.

See-Also: openMSX/openMSX#1563
Signed-off-by: John Helmert III <ajak@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant