On Dec 15, 2006, at 1:56 AM, Andrew Pinski wrote:
For BOOT_CFLAGS and STAGE1_CFLAGS, if we change them to be affected by
CFLAGS, we are going to run into issues where the compiler you are
building with understand an option but the bootstrapping one does not.
An example of this is building GCC with a non GCC compiler. So how do
we handle that case, we split out STAGE1_CFLAGS and BOOT_CFLAGS.
This proves the necessity of two different controls, namely
BOOT_CFLAGS and STAGE1_CFLAGS. I don't propose getting rid of those
or removing them. What it doesn't show is why CFLAGS can't always
influence the build product (as long as BOOT_CFLAGS isn't set, of
course). A setter of CFLAGS promises to not use it when it isn't
applicable, any time those options would not be valid for both the
bootstrap and the stage[23] compiler, they promise not to use that
control.
To be concrete, I'd claim, these are the right semantics:
mrs $ make
stage1 builds with -g
stage2 builds with -O2 -g
mrs $ make CFLAGS=-O2
stage1 builds with -O2
stage2 builds with -O2
mrs $ make CFLAGS=-O2 STAGE1_CFLAGS=-O0
stage1 builds with -O0
stage2 builds with -O2
mrs $ make STAGE1_CFLAGS=-O0
stage1 builds with -O0
stage2 builds with -O2 -g
mrs $ make STAGE1_CFLAGS=-O0 BOOT_CFLAGS=-O3
stage1 builds with -O0
stage2 builds with -O3
mrs $ make CFLAGS=-O0 BOOT_CFLAGS=-O3
stage1 builds with -O0
stage2 builds with -O3
mrs $ make BOOT_CFLAGS=-O3
stage1 builds with -g
stage2 builds with -O3
An argument against the proposal would explain the case that you
specifically think is wrong, and why it is wrong. If you need to
test an invocation not shown above to show why it is wrong, you can
test with:
CFLAGS := default
DEFAULT_STAGE1_CFLAGS := -g
STAGE1_CFLAGS := $(shell if [ "$(CFLAGS)" = default ]; then echo "$
(DEFAULT_STAGE1_CFLAGS)"; else echo "$(CFLAGS)"; fi)
DEFAULT_BOOT_CFLAGS := -O2 -g
BOOT_CFLAGS := $(shell if [ "$(CFLAGS)" = default ]; then echo "$
(DEFAULT_BOOT_CFLAGS)"; else echo "$(CFLAGS)"; fi)
all: stage1 stage2
stage1:
@echo stage1 builds with $(STAGE1_CFLAGS)
stage2:
@echo stage2 builds with $(BOOT_CFLAGS)
The idea is that configure gets to set up DEFAULT_STAGE1_CFLAGS and
DEFAULT_BOOT_CFLAGS anyway it wants, if the user doesn't change his
mind, that is what is used in those situations. Paolo, is there any
case that you can identify that is wrong?