mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: barebox@lists.infradead.org
Cc: Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH 6/8] kbuild: unify barebox and pbl build commands
Date: Tue, 19 May 2020 16:13:50 +0900	[thread overview]
Message-ID: <20200519071353.395493-6-masahiroy@kernel.org> (raw)
In-Reply-To: <20200519071353.395493-1-masahiroy@kernel.org>

The current Linux uses the unified build command for built-in objects
and module objects. This is possible because part-of-module is set to
y when the target is being built for a module. If so, quiet_modtag is
set to [M], and modkern_cflags is set to KBUILD_CFLAGS_MODULE instead
of KBUILD_CFLAGS_KERNEL.

Currently, barebox uses a separate build command for pbl, but the
difference between cmd_cc_o_c and cmd_pbl_cc_o_c is just
"-D__PBL__ $(PBL_CPPFLAGS)".

By using the same approach as Linux, it can be unified.

Set pbl-of-pbl flag to y when the target is being built for pbl.
Merge cmd_as_o_S and cmd_link_o_target as well.

This also changes the shortlog style as follows:

  PBLCC  ->  CC [P]
  PBLAS  ->  AS [P]
  PBLLD  ->  LD [P]

This is more consistent with the policy in the Linux build system.

In Linux, a capital letter enclosed square blackets indicates which
target the object is being built for.

  CC      object built for built-in
  CC [M]  object built for modules
  CC [U]  object built for userspace (proposed for Linux 5.8-rc1)

The idea behind this is we use the same compiler $(CC) for them.
Only the difference is the compiler flags. On the other hand, host
programs are compiled by a different tool, $(HOSTCC), hence the
shortlog is 'HOSTCC'.

Barebox supports module builds (it seems), but the [P] notation does
not conflict with [M] because pbl has a limited memory footprint.
We never expect pbl can support the module feature.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/Makefile.build | 35 ++++++++---------------------------
 scripts/Makefile.lib   |  9 ++++++---
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f575a07fd..31341d23c 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -117,25 +117,18 @@ cmd_cc_i_c       = $(CPP) $(c_flags)   -o $@ $<
 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
-      cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
-quiet_cmd_pbl_cc_o_c = PBLCC   $@
-      cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $<
+      cmd_cc_o_c = $(CC) $(c_flags) $(if $(part-of-pbl),-D__PBL__ $(PBL_CPPFLAGS)) -c -o $@ $<
 
 define rule_cc_o_c
 	$(call cmd,checksrc)
 	$(call cmd_and_fixdep,cc_o_c)
 endef
 
-define rule_pbl_cc_o_c
-	$(call cmd,checksrc)
-	$(call cmd_and_fixdep,pbl_cc_o_c)
-endef
-
 # Built-in and composite module parts
 
 %.pbl.o: %.c FORCE
 	$(call cmd,force_checksrc)
-	$(call if_changed_rule,pbl_cc_o_c)
+	$(call if_changed_rule,cc_o_c)
 
 %.o: %.c FORCE
 	$(call cmd,force_checksrc)
@@ -168,11 +161,8 @@ cmd_as_s_S       = $(CPP) $(a_flags)   -o $@ $<
 quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
 cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
 
-quiet_cmd_pbl_as_o_S = PBLAS   $@
-cmd_pbl_as_o_S       = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $<
-
 %.pbl.o: %.S FORCE
-	$(call if_changed_dep,pbl_as_o_S)
+	$(call if_changed_dep,as_o_S)
 
 %.o: %.S FORCE
 	$(call if_changed_dep,as_o_S)
@@ -198,31 +188,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 #
 # Rule to compile a set of .o files into one .o file
 #
-ifdef builtin-target
-quiet_cmd_link_o_target = LD      $@
+
 # If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $(obj-y)),\
-		      $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
+quiet_cmd_link_o_target = LD $(quiet_modtag)  $@
+cmd_link_o_target = $(if $(strip $(real-prereqs)),\
+		      $(LD) $(ld_flags) -r -o $@ $(real-prereqs),\
 		      rm -f $@; $(AR) rcs $@)
 
 $(builtin-target): $(obj-y) FORCE
 	$(call if_changed,link_o_target)
 
 targets += $(builtin-target)
-endif # builtin-target
-
-ifdef pbl-target
-quiet_cmd_pbl_link_o_target = PBLLD   $@
-# If the list of objects to link is empty, just create an empty built-in-pbl.o
-cmd_pbl_link_o_target = $(if $(strip $(pbl-y)),\
-		      $(LD) $(ld_flags) -r -o $@ $(filter $(pbl-y), $^),\
-		      rm -f $@; $(AR) rcs $@)
 
 $(pbl-target): $(pbl-y) FORCE
-	$(call if_changed,pbl_link_o_target)
+	$(call if_changed,link_o_target)
 
 targets += $(pbl-target)
-endif # pbl-target
 
 #
 # Rule to compile a set of .o files into one .a file
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a6cba747f..55d251844 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -154,7 +154,10 @@ __cpp_flags     =                          $(call flags,_cpp_flags)
 endif
 
 part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
-quiet_modtag = $(if $(part-of-module),[M],   )
+part-of-pbl    = $(if $(filter $(basename $@).o, $(pbl-y) $(pbl-target)),y)
+quiet_modtag = $(if $(part-of-pbl),[P],$(if $(part-of-module),[M],   ))
+
+pbl_cppflags = $(if $(part-of-pbl), -D__PBL__ $(PBL_CPPFLAGS))
 
 modkern_cflags =                                          \
 	$(if $(part-of-module),                           \
@@ -166,11 +169,11 @@ modkern_aflags = $(if $(part-of-module),				\
 			$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
 
 c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
-		 $(__c_flags) $(modkern_cflags) \
+		 $(__c_flags) $(modkern_cflags) $(pbl_cppflags) \
 		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
 
 a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
-		 $(__a_flags) $(modkern_aflags)
+		 $(__a_flags) $(modkern_aflags) $(pbl_cppflags)
 
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
 
-- 
2.25.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-05-19  7:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  7:13 [PATCH 1/8] kbuild: rename pbl object pbl-*.o to *.pbl.o Masahiro Yamada
2020-05-19  7:13 ` [PATCH 2/8] kbuild: remove obj-dtb-y, pbl-dtb-y, lwl-dtb-y syntax Masahiro Yamada
2020-05-19  7:13 ` [PATCH 3/8] kbuild: resync mkdir code with Linux 5.7-rc6 Masahiro Yamada
2020-05-19  7:13 ` [PATCH 4/8] kbuild: append $(bbenv-y) to obj-y earlier Masahiro Yamada
2020-05-19  7:13 ` [PATCH 5/8] kbuild: resync modkern_{c, a}flags and quiet_modtag with Linux 5.7-rc6 Masahiro Yamada
2020-05-19  7:13 ` Masahiro Yamada [this message]
2020-05-19  7:49   ` [PATCH 6/8] kbuild: unify barebox and pbl build commands Masahiro Yamada
2020-05-19  7:13 ` [PATCH 7/8] kbuild: switch over to thin archive Masahiro Yamada
2020-05-19  7:13 ` [PATCH 8/8] Revert "ARM: socfpga: generate smaller images when multiple boards are selected" Masahiro Yamada
2020-05-20 11:18 ` [PATCH 1/8] kbuild: rename pbl object pbl-*.o to *.pbl.o Sascha Hauer

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=20200519071353.395493-6-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=barebox@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox