[U-Boot] [RFC/PATCH] allow boards to customize compiler options on a per-file/dir basis

With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_dir_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- config.mk | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/config.mk b/config.mk index b1254e9..5d442b5 100644 --- a/config.mk +++ b/config.mk @@ -206,23 +206,30 @@ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
#########################################################################
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) +cmd_compile.s.S = $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_dir_$(BCURDIR)) -o $@ $< +cmd_compile.o.S = $(CC) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_dir_$(BCURDIR)) -o $@ $< -c +cmd_compile.o.c = $(CC) $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_dir_$(BCURDIR)) -o $@ $< -c + ifndef REMOTE_BUILD
%.s: %.S - $(CPP) $(AFLAGS) -o $@ $< + $(cmd_compile.s.S) %.o: %.S - $(CC) $(AFLAGS) -c -o $@ $< + $(cmd_compile.o.S) %.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(cmd_compile.o.c)
else
$(obj)%.s: %.S - $(CPP) $(AFLAGS) -o $@ $< + $(cmd_compile.s.S) $(obj)%.o: %.S - $(CC) $(AFLAGS) -c -o $@ $< + $(cmd_compile.o.S) $(obj)%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(cmd_compile.o.c) + endif
#########################################################################

With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org --- v2 - dont require dir_ since the naming is already unique (all objects have a ".o" suffix while dirs do not)
config.mk | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/config.mk b/config.mk index b1254e9..c3a787a 100644 --- a/config.mk +++ b/config.mk @@ -206,23 +206,30 @@ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
#########################################################################
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) +cmd_compile.s.S = $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< +cmd_compile.o.S = $(CC) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< -c +cmd_compile.o.c = $(CC) $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c + ifndef REMOTE_BUILD
%.s: %.S - $(CPP) $(AFLAGS) -o $@ $< + $(cmd_compile.s.S) %.o: %.S - $(CC) $(AFLAGS) -c -o $@ $< + $(cmd_compile.o.S) %.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(cmd_compile.o.c)
else
$(obj)%.s: %.S - $(CPP) $(AFLAGS) -o $@ $< + $(cmd_compile.s.S) $(obj)%.o: %.S - $(CC) $(AFLAGS) -c -o $@ $< + $(cmd_compile.o.S) $(obj)%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(cmd_compile.o.c) + endif
#########################################################################

On 03:06 Mon 18 May , Mike Frysinger wrote:
With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org
Acked-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
Best Regards, J.

With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org Acked-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- v3 - updated to apply to next after Jean's changes
config.mk | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/config.mk b/config.mk index 8d47a8e..f5b9c28 100644 --- a/config.mk +++ b/config.mk @@ -206,11 +206,13 @@ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
#########################################################################
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) $(obj)%.s: %.S - $(CPP) $(AFLAGS) -o $@ $< + $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< $(obj)%.o: %.S - $(CC) $(AFLAGS) -c -o $@ $< + $(CC) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< -c $(obj)%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c
#########################################################################

On 09:33 Sun 14 Jun , Mike Frysinger wrote:
With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org Acked-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
v3
- updated to apply to next after Jean's changes
config.mk | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/config.mk b/config.mk index 8d47a8e..f5b9c28 100644 --- a/config.mk +++ b/config.mk @@ -206,11 +206,13 @@ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
#########################################################################
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) $(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090614142939.GG22102@game.jcrosoft.org you wrote:
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) $(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
But since it's already present it also makes sense to keep it, so we don;t have to figure out what it needs to be in case we have to add an assembler file later.
Best regards,
Wolfgang Denk

On 16:45 Sun 14 Jun , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090614142939.GG22102@game.jcrosoft.org you wrote:
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) $(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
But since it's already present it also makes sense to keep it, so we don;t have to figure out what it needs to be in case we have to add an assembler file later.
the .s is supposed to be gcc temp file so It make sense to avoid it as assembly file suffix is .S for source
Best Regards, J.

On Sunday 14 June 2009 11:10:08 Jean-Christophe PLAGNIOL-VILLARD wrote:
On 16:45 Sun 14 Jun , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090614142939.GG22102@game.jcrosoft.org you wrote:
+# Allow boards to use custom optimize flags on a per dir/file basis +BCURDIR := $(notdir $(CURDIR)) $(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
But since it's already present it also makes sense to keep it, so we don;t have to figure out what it needs to be in case we have to add an assembler file later.
the .s is supposed to be gcc temp file
not really. the .s file means "do not run preprocessor before sending to assembler". that is all.
It make sense to avoid it as assembly file suffix is .S for source
usually, yes, but no need to force people to conform if they want to write pure assembly with no CPP stuff. -mike

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090614151008.GK22102@game.jcrosoft.org you wrote:
the .s is supposed to be gcc temp file so It make sense to avoid it as assembly file suffix is .S for source
That's not correct. ".s" has always (from the dawn of time) been normal assembler code in Unix systems. Normally you will use "as" directly on such files. ".S" is a suffix introduced much, much later and indicates files that need to be run through the C preprocessor.
Best regards,
Wolfgang Denk

On Sunday 14 June 2009 10:29:39 Jean-Christophe PLAGNIOL-VILLARD wrote:
On 09:33 Sun 14 Jun , Mike Frysinger wrote:
$(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
looks to me like there is: $ make lib_blackfin/memcmp.s bfin-uclinux-gcc -E -D__ASSEMBLY__ -g -Os -ffixed-P5 -fomit-frame-pointer -mno-fdpic -ffunction-sections -fdata-sections -mcpu=bf561-0.3 -D__KERNEL__ - I/usr/local/src/u-boot/blackfin/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/src/blackfin/toolchains/20090608/bfin- uclinux/lib/gcc/bfin-uclinux/4.3.3/include -pipe -DCONFIG_BLACKFIN -o lib_blackfin/memcmp.s lib_blackfin/memcmp.S
if that target is removed, this no longer works -mike

On 10:56 Sun 14 Jun , Mike Frysinger wrote:
On Sunday 14 June 2009 10:29:39 Jean-Christophe PLAGNIOL-VILLARD wrote:
On 09:33 Sun 14 Jun , Mike Frysinger wrote:
$(obj)%.s: %.S
- $(CPP) $(AFLAGS) -o $@ $<
- $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
we can drop this one as there is no obj %.s
looks to me like there is: $ make lib_blackfin/memcmp.s bfin-uclinux-gcc -E -D__ASSEMBLY__ -g -Os -ffixed-P5 -fomit-frame-pointer -mno-fdpic -ffunction-sections -fdata-sections -mcpu=bf561-0.3 -D__KERNEL__ - I/usr/local/src/u-boot/blackfin/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/src/blackfin/toolchains/20090608/bfin- uclinux/lib/gcc/bfin-uclinux/4.3.3/include -pipe -DCONFIG_BLACKFIN -o lib_blackfin/memcmp.s lib_blackfin/memcmp.S
sorry for the miss I've done a find . -name Makefile | xargs grep ".s" and miss it
Best Regards, J.

Dear Mike Frysinger,
In message 1244986380-24157-1-git-send-email-vapier@gentoo.org you wrote:
With our Blackfin boards, we like to build the compression routines with -O2 as our tests show a pretty good size/speed tradeoff. For the rest of U-Boot though, we want to stick with the default -Os as that is mostly control code. So in our case, we would add a line like so to the board specific config.mk file: CFLAGS_lib_generic += -O2
Now all files under lib_generic/ will have -O2 appended to their build.
Signed-off-by: Mike Frysinger vapier@gentoo.org Acked-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
v3
- updated to apply to next after Jean's changes
config.mk | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
participants (3)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Mike Frysinger
-
Wolfgang Denk