All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Jeremy Kerr <jk@ozlabs.org>
Cc: kexec@lists.infradead.org
Subject: Re: [PATCH] Explicitly use BUILD_CC and TARGET_CC
Date: Mon, 18 Aug 2008 17:10:39 +1000	[thread overview]
Message-ID: <20080818071037.GA5029@verge.net.au> (raw)
In-Reply-To: <1219030410.884068.167991623519.1.gpush@pingu>

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

  reply	other threads:[~2008-08-18  7:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18  3:33 [PATCH] Explicitly use BUILD_CC and TARGET_CC Jeremy Kerr
2008-08-18  7:10 ` Simon Horman [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080818071037.GA5029@verge.net.au \
    --to=horms@verge.net.au \
    --cc=jk@ozlabs.org \
    --cc=kexec@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.