linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: remove top-level built-in.a
@ 2019-01-14  3:27 Masahiro Yamada
  2019-01-14  3:27 ` [PATCH 2/2] kbuild: merge KBUILD_VMLINUX_{INIT,MAIN} into KBUILD_VMLINUX_OBJS Masahiro Yamada
  2019-01-15  7:15 ` [PATCH 1/2] kbuild: remove top-level built-in.a Nicholas Piggin
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-01-14  3:27 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nicholas Piggin, Stephen Rothwell, Masahiro Yamada, linux-kernel

The symbol table in the final archive is unneeded because it is passed
to the linker after the --whole-archive option. Every object file in
the archive is included in the link anyway.

Pass thin archives from subdirectories directly to the linker, and
remove the final archiving step.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/link-vmlinux.sh | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index c8cf453..4788def 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -44,24 +44,6 @@ info()
 	fi
 }
 
-# Thin archive build here makes a final archive with symbol table and indexes
-# from vmlinux objects INIT and MAIN, which can be used as input to linker.
-# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes
-# added.
-#
-# Traditional incremental style of link does not require this step
-#
-# built-in.a output file
-#
-archive_builtin()
-{
-	info AR built-in.a
-	rm -f built-in.a;
-	${AR} rcsTP${KBUILD_ARFLAGS} built-in.a			\
-				${KBUILD_VMLINUX_INIT}		\
-				${KBUILD_VMLINUX_MAIN}
-}
-
 # Link of vmlinux.o used for section mismatch analysis
 # ${1} output file
 modpost_link()
@@ -69,7 +51,8 @@ modpost_link()
 	local objects
 
 	objects="--whole-archive				\
-		built-in.a					\
+		${KBUILD_VMLINUX_INIT}				\
+		${KBUILD_VMLINUX_MAIN}				\
 		--no-whole-archive				\
 		--start-group					\
 		${KBUILD_VMLINUX_LIBS}				\
@@ -88,7 +71,8 @@ vmlinux_link()
 
 	if [ "${SRCARCH}" != "um" ]; then
 		objects="--whole-archive			\
-			built-in.a				\
+			${KBUILD_VMLINUX_INIT}			\
+			${KBUILD_VMLINUX_MAIN}			\
 			--no-whole-archive			\
 			--start-group				\
 			${KBUILD_VMLINUX_LIBS}			\
@@ -99,7 +83,8 @@ vmlinux_link()
 			-T ${lds} ${objects}
 	else
 		objects="-Wl,--whole-archive			\
-			built-in.a				\
+			${KBUILD_VMLINUX_INIT}			\
+			${KBUILD_VMLINUX_MAIN}			\
 			-Wl,--no-whole-archive			\
 			-Wl,--start-group			\
 			${KBUILD_VMLINUX_LIBS}			\
@@ -160,7 +145,6 @@ cleanup()
 	rm -f .tmp_System.map
 	rm -f .tmp_kallsyms*
 	rm -f .tmp_vmlinux*
-	rm -f built-in.a
 	rm -f System.map
 	rm -f vmlinux
 	rm -f vmlinux.o
@@ -217,8 +201,6 @@ fi;
 # final build of init/
 ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
 
-archive_builtin
-
 #link vmlinux.o
 info LD vmlinux.o
 modpost_link vmlinux.o
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] kbuild: merge KBUILD_VMLINUX_{INIT,MAIN} into KBUILD_VMLINUX_OBJS
  2019-01-14  3:27 [PATCH 1/2] kbuild: remove top-level built-in.a Masahiro Yamada
@ 2019-01-14  3:27 ` Masahiro Yamada
  2019-01-15  7:15 ` [PATCH 1/2] kbuild: remove top-level built-in.a Nicholas Piggin
  1 sibling, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2019-01-14  3:27 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Nicholas Piggin, Stephen Rothwell, Masahiro Yamada, Michal Marek,
	linux-kernel

The top Makefile does not need to export KBUILD_VMLINUX_INIT and
KBUILD_VMLINUX_MAIN separately.

Put every built-in.a into KBUILD_VMLINUX_OBJS. The order of
$(head-y), $(init-y), $(core-y), ... is still retained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 Makefile                |  6 +++---
 scripts/link-vmlinux.sh | 28 ++++++++++------------------
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 499b968..68898cc 100644
--- a/Makefile
+++ b/Makefile
@@ -975,15 +975,15 @@ libs-y2		:= $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
 virt-y		:= $(patsubst %/, %/built-in.a, $(virt-y))
 
 # Externally visible symbols (used by link-vmlinux.sh)
-export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
-export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y)
+export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
+			      $(drivers-y) $(net-y) $(virt-y)
 export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
 # used by scripts/package/Makefile
 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
 
-vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS)
+vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
 
 # Recurse until adjust_autoksyms.sh is satisfied
 PHONY += autoksyms_recursive
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4788def..bc7f1fc 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -3,22 +3,17 @@
 #
 # link vmlinux
 #
-# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and
-# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files
-# from top-level directories in the kernel tree, others are specified in
-# arch/$(ARCH)/Makefile. Ordering when linking is important, and
-# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives
-# which are linked conditionally (not within --whole-archive), and do not
-# require symbol indexes added.
+# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
+# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
+# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
+# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
+# (not within --whole-archive), and do not require symbol indexes added.
 #
 # vmlinux
 #   ^
 #   |
-#   +-< $(KBUILD_VMLINUX_INIT)
-#   |   +--< init/version.o + more
-#   |
-#   +--< $(KBUILD_VMLINUX_MAIN)
-#   |    +--< drivers/built-in.a mm/built-in.a + more
+#   +--< $(KBUILD_VMLINUX_OBJS)
+#   |    +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
 #   |
 #   +--< $(KBUILD_VMLINUX_LIBS)
 #   |    +--< lib/lib.a + more
@@ -51,8 +46,7 @@ modpost_link()
 	local objects
 
 	objects="--whole-archive				\
-		${KBUILD_VMLINUX_INIT}				\
-		${KBUILD_VMLINUX_MAIN}				\
+		${KBUILD_VMLINUX_OBJS}				\
 		--no-whole-archive				\
 		--start-group					\
 		${KBUILD_VMLINUX_LIBS}				\
@@ -71,8 +65,7 @@ vmlinux_link()
 
 	if [ "${SRCARCH}" != "um" ]; then
 		objects="--whole-archive			\
-			${KBUILD_VMLINUX_INIT}			\
-			${KBUILD_VMLINUX_MAIN}			\
+			${KBUILD_VMLINUX_OBJS}			\
 			--no-whole-archive			\
 			--start-group				\
 			${KBUILD_VMLINUX_LIBS}			\
@@ -83,8 +76,7 @@ vmlinux_link()
 			-T ${lds} ${objects}
 	else
 		objects="-Wl,--whole-archive			\
-			${KBUILD_VMLINUX_INIT}			\
-			${KBUILD_VMLINUX_MAIN}			\
+			${KBUILD_VMLINUX_OBJS}			\
 			-Wl,--no-whole-archive			\
 			-Wl,--start-group			\
 			${KBUILD_VMLINUX_LIBS}			\
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] kbuild: remove top-level built-in.a
  2019-01-14  3:27 [PATCH 1/2] kbuild: remove top-level built-in.a Masahiro Yamada
  2019-01-14  3:27 ` [PATCH 2/2] kbuild: merge KBUILD_VMLINUX_{INIT,MAIN} into KBUILD_VMLINUX_OBJS Masahiro Yamada
@ 2019-01-15  7:15 ` Nicholas Piggin
  2019-01-15  9:01   ` Masahiro Yamada
  1 sibling, 1 reply; 5+ messages in thread
From: Nicholas Piggin @ 2019-01-15  7:15 UTC (permalink / raw)
  To: linux-kbuild, Masahiro Yamada; +Cc: linux-kernel, Stephen Rothwell

Masahiro Yamada's on January 14, 2019 1:27 pm:
> The symbol table in the final archive is unneeded because it is passed
> to the linker after the --whole-archive option. Every object file in
> the archive is included in the link anyway.
> 
> Pass thin archives from subdirectories directly to the linker, and
> remove the final archiving step.

This seems like a good improvement. As far as I remember, it was slower 
to do the final link without the index built. Maybe I was testing it 
in a revision before moving those files into --whole-archive? If there
is no slowdown, then I have no objection.

Acked-by: Nicholas Piggin <npiggin@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] kbuild: remove top-level built-in.a
  2019-01-15  7:15 ` [PATCH 1/2] kbuild: remove top-level built-in.a Nicholas Piggin
@ 2019-01-15  9:01   ` Masahiro Yamada
  2019-01-23  8:26     ` Nicholas Piggin
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2019-01-15  9:01 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Linux Kbuild mailing list, Linux Kernel Mailing List, Stephen Rothwell

Hi Nicholas,


On Tue, Jan 15, 2019 at 5:07 PM Nicholas Piggin <npiggin@gmail.com> wrote:
>
> Masahiro Yamada's on January 14, 2019 1:27 pm:
> > The symbol table in the final archive is unneeded because it is passed
> > to the linker after the --whole-archive option. Every object file in
> > the archive is included in the link anyway.
> >
> > Pass thin archives from subdirectories directly to the linker, and
> > remove the final archiving step.
>
> This seems like a good improvement. As far as I remember, it was slower
> to do the final link without the index built. Maybe I was testing it
> in a revision before moving those files into --whole-archive? If there
> is no slowdown, then I have no objection.


Thanks for the review.


I measured the performance of scripts/link-vmlinux.sh with 'perf stat'.
(20 times for each)



Before this patch:

 Performance counter stats for 'make vmlinux' (20 runs):

       5.266796537 seconds time elapsed
          ( +-  0.12% )



After this patch:

 Performance counter stats for 'make vmlinux' (20 runs):

       4.945576395 seconds time elapsed




So, the performance is slightly better.

Maybe, does omitting the 'ar' save some time?


Anyway, this commit is good.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] kbuild: remove top-level built-in.a
  2019-01-15  9:01   ` Masahiro Yamada
@ 2019-01-23  8:26     ` Nicholas Piggin
  0 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2019-01-23  8:26 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Linux Kernel Mailing List, Stephen Rothwell

Masahiro Yamada's on January 15, 2019 7:01 pm:
> Hi Nicholas,
> 
> 
> On Tue, Jan 15, 2019 at 5:07 PM Nicholas Piggin <npiggin@gmail.com> wrote:
>>
>> Masahiro Yamada's on January 14, 2019 1:27 pm:
>> > The symbol table in the final archive is unneeded because it is passed
>> > to the linker after the --whole-archive option. Every object file in
>> > the archive is included in the link anyway.
>> >
>> > Pass thin archives from subdirectories directly to the linker, and
>> > remove the final archiving step.
>>
>> This seems like a good improvement. As far as I remember, it was slower
>> to do the final link without the index built. Maybe I was testing it
>> in a revision before moving those files into --whole-archive? If there
>> is no slowdown, then I have no objection.
> 
> 
> Thanks for the review.
> 
> 
> I measured the performance of scripts/link-vmlinux.sh with 'perf stat'.
> (20 times for each)
> 
> 
> 
> Before this patch:
> 
>  Performance counter stats for 'make vmlinux' (20 runs):
> 
>        5.266796537 seconds time elapsed
>           ( +-  0.12% )
> 
> 
> 
> After this patch:
> 
>  Performance counter stats for 'make vmlinux' (20 runs):
> 
>        4.945576395 seconds time elapsed
> 
> 
> 
> 
> So, the performance is slightly better.
> 
> Maybe, does omitting the 'ar' save some time?

Wow yeah that's a good speedup and simplification to boot. Thanks for 
checking it.

> Anyway, this commit is good.

Yes, it's a good improvement.

Thanks,
Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-23  8:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-14  3:27 [PATCH 1/2] kbuild: remove top-level built-in.a Masahiro Yamada
2019-01-14  3:27 ` [PATCH 2/2] kbuild: merge KBUILD_VMLINUX_{INIT,MAIN} into KBUILD_VMLINUX_OBJS Masahiro Yamada
2019-01-15  7:15 ` [PATCH 1/2] kbuild: remove top-level built-in.a Nicholas Piggin
2019-01-15  9:01   ` Masahiro Yamada
2019-01-23  8:26     ` Nicholas Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).