All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Nicholas Piggin <npiggin@gmail.com>,
	linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, Arnd Bergmann <arnd@arndb.de>,
	Nicolas Pitre <nico@linaro.org>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Alan Modra <amodra@gmail.com>
Subject: Re: [PATCH 1/5] kbuild: allow architectures to use thin archives instead of ld -r
Date: Sun, 7 Aug 2016 16:40:54 +0200	[thread overview]
Message-ID: <20160807144054.GA14682@ravnborg.org> (raw)
In-Reply-To: <20160807114946.41b682f3@canb.auug.org.au>

On Sun, Aug 07, 2016 at 11:49:46AM +1000, Stephen Rothwell wrote:
> Hi Sam,
> 
> On Sat, 6 Aug 2016 22:10:45 +0200 Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > Did you by any chance evalue the use of INPUT in linker files.
> > Stephen back then (again based on proposal from Alan Modra),
> > also made an implementation using INPUT.
> 
> The problem with that idea was that (at least for some versions of
> binutils in use at the time) we hit a static limit to the number of
> object files and ld just stopped at that point. :-(

The ld bug was caused by opening too many linked definitions files.
We can workaround this by expanding the files.
I gave this a quick spin - see below.

Note - I have no idea if using thin archived or this method is better.
But it seems just wrong to me that we convert to thin archives when
we really do not need to do so.

Note - this was a quick spin. It build fine here and thats it.

	Sam

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 11602e5..37b8bc9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -360,10 +360,16 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 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), $^) \
-		      $(cmd_secanalysis),\
-		      rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
+cmd_link_o_target =                                            \
+$(if $(filter $(obj-y), $^),                                   \
+	echo $(foreach file, $(filter $(obj-y), $^),           \
+		$(if $(filter %/built-in.o, $(file)),          \
+			$(shell cat $(file)),                  \
+			$(file)                                \
+		)                                              \
+	)                                                      \
+        , echo ""                                              \
+) > $@
 
 $(builtin-target): $(obj-y) FORCE
 	$(call if_changed,link_o_target)
@@ -414,10 +420,10 @@ $($(subst $(obj)/,,$(@:.o=-y)))       \
 $($(subst $(obj)/,,$(@:.o=-m)))), $^)
 
 quiet_cmd_link_multi-y = LD      $@
-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
+cmd_link_multi-y = echo INPUT\($(link_multi_deps)\) > $@
 
 quiet_cmd_link_multi-m = LD [M]  $@
-cmd_link_multi-m = $(cmd_link_multi-y)
+cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
 
 $(multi-used-y): FORCE
 	$(call if_changed,link_multi-y)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4f727eb..323c13a 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -41,8 +41,8 @@ info()
 # ${1} output file
 modpost_link()
 {
-	${LD} ${LDFLAGS} -r -o ${1} ${KBUILD_VMLINUX_INIT}                   \
-		--start-group ${KBUILD_VMLINUX_MAIN} --end-group
+	${LD} ${LDFLAGS} -r -o ${1} ${vmlinux_init}            \
+		--start-group ${vmlinux_main} --end-group
 }
 
 # Link of vmlinux
@@ -54,13 +54,13 @@ vmlinux_link()
 
 	if [ "${SRCARCH}" != "um" ]; then
 		${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2}                  \
-			-T ${lds} ${KBUILD_VMLINUX_INIT}                     \
-			--start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1}
+			-T ${lds} ${vmlinux_init}                            \
+			--start-group ${vmlinux_main} --end-group ${1}
 	else
 		${CC} ${CFLAGS_vmlinux} -o ${2}                              \
-			-Wl,-T,${lds} ${KBUILD_VMLINUX_INIT}                 \
+			-Wl,-T,${lds} ${vmlinux_init}                        \
 			-Wl,--start-group                                    \
-				 ${KBUILD_VMLINUX_MAIN}                      \
+				 ${vmlinux_main}                             \
 			-Wl,--end-group                                      \
 			-lutil -lrt -lpthread ${1}
 		rm -f linux
@@ -162,6 +162,23 @@ case "${KCONFIG_CONFIG}" in
 	. "./${KCONFIG_CONFIG}"
 esac
 
+# Expand built-in.o file as they just list .o files
+for f in ${KBUILD_VMLINUX_INIT}; do
+	if [ $(basename $f) = built-in.o ]; then
+		vmlinux_init="${vmlinux_init} $(cat $f)"
+	else
+		vmlinux_init="${vmlinux_init} $f"
+	fi
+done
+
+for f in ${KBUILD_VMLINUX_MAIN}; do
+	if [ $(basename $f) = built-in.o ]; then
+		vmlinux_main="${vmlinux_main} $(cat $f)"
+	else
+		vmlinux_main="${vmlinux_main} $f"
+	fi
+done
+
 #link vmlinux.o
 info LD vmlinux.o
 modpost_link vmlinux.o

  parent reply	other threads:[~2016-08-07 14:41 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 12:11 [RFC][PATCH 0/5] kbuild changes, thin archives, --gc-sections Nicholas Piggin
2016-08-05 12:11 ` [PATCH 1/5] kbuild: allow architectures to use thin archives instead of ld -r Nicholas Piggin
2016-08-06  3:50   ` kbuild test robot
2016-08-06  3:50     ` kbuild test robot
2016-08-06  3:50     ` kbuild test robot
2016-08-06 20:10   ` Sam Ravnborg
2016-08-07  1:49     ` Stephen Rothwell
2016-08-07  3:34       ` Alan Modra
2016-08-07  4:17       ` Nicolas Pitre
2016-08-07 14:40       ` Sam Ravnborg [this message]
2016-08-08  3:19         ` Nicholas Piggin
2016-08-08  4:46           ` Sam Ravnborg
2016-08-08  3:25     ` Nicholas Piggin
2016-08-08  9:18       ` Arnd Bergmann
2016-08-05 12:12 ` [PATCH 2/5] kbuild: allow archs to select build for link dead code/data elimination Nicholas Piggin
2016-08-06 20:14   ` Sam Ravnborg
2016-08-08  3:29     ` Nicholas Piggin
2016-08-08  4:49       ` Sam Ravnborg
2016-08-07  5:33   ` Nicolas Pitre
2016-08-08  3:42     ` Nicholas Piggin
2016-08-08  4:12       ` Nicolas Pitre
2016-08-08  4:27         ` Nicholas Piggin
2016-08-07  9:57   ` Alan Modra
2016-08-07 11:35     ` Andreas Schwab
2016-08-07 20:26     ` Arnd Bergmann
2016-08-07 23:49       ` Alan Modra
2016-08-08 15:14         ` Arnd Bergmann
2016-08-08 23:50           ` Alan Modra
2016-08-09 22:10             ` Arnd Bergmann
2016-08-09  3:16           ` Andi Kleen
2016-08-09 22:29             ` Arnd Bergmann
2016-08-09 23:08               ` Andi Kleen
2016-08-10  0:37               ` Andi Kleen
2016-08-05 12:12 ` [PATCH 3/5] kbuild: add arch specific post-module-link pass Nicholas Piggin
2016-08-05 13:56   ` Nicholas Piggin
2016-08-06 20:16   ` Sam Ravnborg
2016-08-08  3:30     ` Nicholas Piggin
2016-08-05 12:12 ` [PATCH 4/5] powerpc: switch to using thin archives Nicholas Piggin
2016-08-05 12:12 ` [PATCH 5/5] powerpc/64: use linker dce Nicholas Piggin
2016-08-05 13:32 ` [RFC][PATCH 0/5] kbuild changes, thin archives, --gc-sections Nicholas Piggin
2016-08-05 13:32   ` Nicholas Piggin
2016-08-07 20:23 ` Arnd Bergmann
2016-08-08  3:53   ` Nicholas Piggin

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=20160807144054.GA14682@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=amodra@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nico@linaro.org \
    --cc=npiggin@gmail.com \
    --cc=segher@kernel.crashing.org \
    --cc=sfr@canb.auug.org.au \
    /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.