* [PATCH] Explicitly use BUILD_CC and TARGET_CC
@ 2008-08-18 3:33 Jeremy Kerr
2008-08-18 7:10 ` Simon Horman
2008-08-19 15:38 ` Lombard, David N
0 siblings, 2 replies; 6+ messages in thread
From: Jeremy Kerr @ 2008-08-18 3:33 UTC (permalink / raw)
To: kexec; +Cc: horms
Currently, we override CC for build and target compiles:
$(BIN_TO_HEX): CC=$(BUILD_CC)
However, this breaks when a user does something like:
make CC=host-arch-gcc
- since command-line parameter overrides all makefile variables, so
we end up using host-arch-gcc for *all* compiles, including those for
target and build.
This change explicitly uses BUILD_CC and TARGET_CC where necessary,
so that the CC variable isn't used for build and target compiles.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
purgatory/Makefile | 16 +++++++++-------
util/Makefile | 6 +-----
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/purgatory/Makefile b/purgatory/Makefile
index ac58719..d7aec3a 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -42,27 +42,29 @@ purgatory/sha256.o: CFLAGS += -O0
purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
mkdir -p $(@D)
- $(COMPILE.c) -o $@ $^
+ $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -o $@ $^
-$(PURGATORY): CC=$(TARGET_CC)
-$(PURGATORY): CFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+$(PURGATORY): TARGET_CFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-Os -fno-builtin -ffreestanding \
-fno-zero-initialized-in-bss
-$(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+$(PURGATORY): TARGET_CPPFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-I$(srcdir)/purgatory/include \
-I$(srcdir)/purgatory/arch/$(ARCH)/include \
-I$(srcdir)/util_lib/include \
-I$(shell $(CC) -print-file-name=include)
-$(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
+
+$(PURGATORY): TARGET_LDFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
--no-undefined -nostartfiles -nostdlib -nodefaultlibs \
-e purgatory_start -r
$(PURGATORY): $(PURGATORY_OBJS)
$(MKDIR) -p $(@D)
- $(CC) $(LDFLAGS) -o $@ $^
+ $(TARGET_CC) $(TARGET_LDFLAGS) -o $@ $^
-# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
+$(PURGATORY_OBJS): %.o: %.c
+ $(MKDIR) -p $(@D)
+ $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -o $@ $^
echo::
@echo "PURGATORY_SRCS $(PURGATORY_SRCS)"
diff --git a/util/Makefile b/util/Makefile
index 948ee63..9c005d5 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -2,11 +2,7 @@ BIN_TO_HEX:= bin/bin-to-hex
$(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
@$(MKDIR) -p $(@D)
- $(LINK.o) $(CFLAGS) -o $@ $^
-
-$(BIN_TO_HEX): CC=$(BUILD_CC)
-$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)
-$(BIN_TO_HEX): LDFLAGS=
+ $(BUILD_CC) $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -o $@ $^
dist += util/Makefile util/bin-to-hex.c
clean += util/bin-to-hex.o $(BIN_TO_HEX)
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
2008-08-18 3:33 [PATCH] Explicitly use BUILD_CC and TARGET_CC Jeremy Kerr
@ 2008-08-18 7:10 ` Simon Horman
2008-08-18 7:19 ` Jeremy Kerr
2008-08-19 15:38 ` Lombard, David N
1 sibling, 1 reply; 6+ messages in thread
From: Simon Horman @ 2008-08-18 7:10 UTC (permalink / raw)
To: Jeremy Kerr; +Cc: kexec
On Mon, Aug 18, 2008 at 11:33:30AM +0800, Jeremy Kerr wrote:
> Currently, we override CC for build and target compiles:
>
> $(BIN_TO_HEX): CC=$(BUILD_CC)
>
> However, this breaks when a user does something like:
>
> make CC=host-arch-gcc
>
> - since command-line parameter overrides all makefile variables, so
> we end up using host-arch-gcc for *all* compiles, including those for
> target and build.
>
> This change explicitly uses BUILD_CC and TARGET_CC where necessary,
> so that the CC variable isn't used for build and target compiles.
>
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Hi Jeremy,
Unfortunately I have stumbled upon a couple of problems with
this patch.
> ---
> purgatory/Makefile | 16 +++++++++-------
> util/Makefile | 6 +-----
> 2 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/purgatory/Makefile b/purgatory/Makefile
> index ac58719..d7aec3a 100644
> --- a/purgatory/Makefile
> +++ b/purgatory/Makefile
> @@ -42,27 +42,29 @@ purgatory/sha256.o: CFLAGS += -O0
>
> purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
> mkdir -p $(@D)
> - $(COMPILE.c) -o $@ $^
> + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -o $@ $^
This target is now duplicated by $(PURGATORY_OBJS): %.o: %.c below
>
> -$(PURGATORY): CC=$(TARGET_CC)
> -$(PURGATORY): CFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
> +$(PURGATORY): TARGET_CFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
> -Os -fno-builtin -ffreestanding \
> -fno-zero-initialized-in-bss
>
> -$(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
> +$(PURGATORY): TARGET_CPPFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
> -I$(srcdir)/purgatory/include \
> -I$(srcdir)/purgatory/arch/$(ARCH)/include \
> -I$(srcdir)/util_lib/include \
> -I$(shell $(CC) -print-file-name=include)
> -$(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
> +
> +$(PURGATORY): TARGET_LDFLAGS += $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
> --no-undefined -nostartfiles -nostdlib -nodefaultlibs \
> -e purgatory_start -r
>
> $(PURGATORY): $(PURGATORY_OBJS)
> $(MKDIR) -p $(@D)
> - $(CC) $(LDFLAGS) -o $@ $^
> + $(TARGET_CC) $(TARGET_LDFLAGS) -o $@ $^
>
> -# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
> +$(PURGATORY_OBJS): %.o: %.c
On some architectures, such as ia64, PURGATORY_SRCS can include .S files.
Prehaps we need PURGATORY_C_SRCS and PURGATORY_ASM_SRCS ?
> + $(MKDIR) -p $(@D)
> + $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -o $@ $^
I think that you need $(TARGET_CC) -c here.
Also above for purgatory/sha256.o if that target is to remain separate.
>
> echo::
> @echo "PURGATORY_SRCS $(PURGATORY_SRCS)"
> diff --git a/util/Makefile b/util/Makefile
> index 948ee63..9c005d5 100644
> --- a/util/Makefile
> +++ b/util/Makefile
> @@ -2,11 +2,7 @@ BIN_TO_HEX:= bin/bin-to-hex
>
> $(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c
> @$(MKDIR) -p $(@D)
> - $(LINK.o) $(CFLAGS) -o $@ $^
> -
> -$(BIN_TO_HEX): CC=$(BUILD_CC)
> -$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS)
> -$(BIN_TO_HEX): LDFLAGS=
> + $(BUILD_CC) $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -o $@ $^
>
> dist += util/Makefile util/bin-to-hex.c
> clean += util/bin-to-hex.o $(BIN_TO_HEX)
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
2008-08-18 7:10 ` Simon Horman
@ 2008-08-18 7:19 ` Jeremy Kerr
2008-08-19 14:40 ` Jeremy Kerr
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Kerr @ 2008-08-18 7:19 UTC (permalink / raw)
To: kexec; +Cc: Simon Horman
Hi Horms,
> On some architectures, such as ia64, PURGATORY_SRCS can include .S
> files. Prehaps we need PURGATORY_C_SRCS and PURGATORY_ASM_SRCS ?
That should be fine: we just add a rule for %.o: %.S
> I think that you need $(TARGET_CC) -c here.
> Also above for purgatory/sha256.o if that target is to remain
> separate.
Good point. New patch coming.
Jeremy
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
2008-08-18 7:19 ` Jeremy Kerr
@ 2008-08-19 14:40 ` Jeremy Kerr
2008-08-19 23:02 ` Simon Horman
0 siblings, 1 reply; 6+ messages in thread
From: Jeremy Kerr @ 2008-08-19 14:40 UTC (permalink / raw)
To: kexec; +Cc: Simon Horman
> That should be fine: we just add a rule for %.o: %.S
OK, that's not going to work, because rules of the form
list: pattern: prereq
*require* the prereqs to be build. ie, in our case:
$(PURGATORY_OBJS): %.o: %.S
will require a .S for all .o files in PURGATORY_OBJS. Which is not what
we want :(
So, the solution left would be to override COMPILE.c, COMPILE.S and
LINK.o for target and build compiles. For example:
$(PURGATORY_OBJS): COMPILE.c = $(TARGET_CC) $(TARGET_CFLAGS) \
$(TARGET_CPPFLAGS) -c
It's unlikely that a user is going to override COMPILE.c on the make
command-line :)
How does that sound?
Cheers,
Jeremy
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
2008-08-18 3:33 [PATCH] Explicitly use BUILD_CC and TARGET_CC Jeremy Kerr
2008-08-18 7:10 ` Simon Horman
@ 2008-08-19 15:38 ` Lombard, David N
1 sibling, 0 replies; 6+ messages in thread
From: Lombard, David N @ 2008-08-19 15:38 UTC (permalink / raw)
To: Jeremy Kerr; +Cc: horms@verge.net.au, kexec@lists.infradead.org
On Sun, Aug 17, 2008 at 08:33:30PM -0700, Jeremy Kerr wrote:
> Currently, we override CC for build and target compiles:
>
> $(BIN_TO_HEX): CC=$(BUILD_CC)
>
> However, this breaks when a user does something like:
>
> make CC=host-arch-gcc
>
> - since command-line parameter overrides all makefile variables, so
> we end up using host-arch-gcc for *all* compiles, including those for
> target and build.
>
> This change explicitly uses BUILD_CC and TARGET_CC where necessary,
> so that the CC variable isn't used for build and target compiles.
Thanks!
--
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
2008-08-19 14:40 ` Jeremy Kerr
@ 2008-08-19 23:02 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2008-08-19 23:02 UTC (permalink / raw)
To: Jeremy Kerr; +Cc: kexec
On Tue, Aug 19, 2008 at 10:40:16PM +0800, Jeremy Kerr wrote:
>
> > That should be fine: we just add a rule for %.o: %.S
>
> OK, that's not going to work, because rules of the form
>
> list: pattern: prereq
>
> *require* the prereqs to be build. ie, in our case:
>
> $(PURGATORY_OBJS): %.o: %.S
>
> will require a .S for all .o files in PURGATORY_OBJS. Which is not what
> we want :(
>
> So, the solution left would be to override COMPILE.c, COMPILE.S and
> LINK.o for target and build compiles. For example:
>
> $(PURGATORY_OBJS): COMPILE.c = $(TARGET_CC) $(TARGET_CFLAGS) \
> $(TARGET_CPPFLAGS) -c
>
> It's unlikely that a user is going to override COMPILE.c on the make
> command-line :)
>
> How does that sound?
Sounds fine to me.
Another option is to split up PURGATORY_OBJS and PURGATORY_SRCS based
on wheather the source is a .S or a .c file. Though I suspect your
idea is cleaner.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-19 23:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-18 3:33 [PATCH] Explicitly use BUILD_CC and TARGET_CC Jeremy Kerr
2008-08-18 7:10 ` Simon Horman
2008-08-18 7:19 ` Jeremy Kerr
2008-08-19 14:40 ` Jeremy Kerr
2008-08-19 23:02 ` Simon Horman
2008-08-19 15:38 ` Lombard, David N
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.