From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kbuild@vger.kernel.org, Martin Liska <mliska@suse.cz>,
Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 28/46] scripts, lto: re-add gcc-ld
Date: Mon, 14 Nov 2022 12:43:26 +0100 [thread overview]
Message-ID: <20221114114344.18650-29-jirislaby@kernel.org> (raw)
In-Reply-To: <20221114114344.18650-1-jirislaby@kernel.org>
From: Andi Kleen <ak@linux.intel.com>
The primary goal of the script is to mangle linker command line arguments
into something which gcc understands. Such as converting "-z now" into
"-Wl,-z,now".
The script was removed by commit 86879fd277e8 (scripts: remove obsolete
gcc-ld script) as there was no use in the kernel. It had been added long
time ago to support exactly these lto patches, so we need to add it back
now.
Since the removed version, it is improved a bit:
* some missing linker and gcc command line arguments were added, and
* when V=1 is specified, it prints the final gcc command line
[js] rebase + commit message massage
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
scripts/gcc-ld | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100755 scripts/gcc-ld
diff --git a/scripts/gcc-ld b/scripts/gcc-ld
new file mode 100755
index 000000000000..13e85ece8d04
--- /dev/null
+++ b/scripts/gcc-ld
@@ -0,0 +1,40 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# run gcc with ld options
+# used as a wrapper to execute link time optimizations
+# yes virginia, this is not pretty
+
+ARGS="-nostdlib"
+
+for j in "$@" ; do
+ if [ "$j" = -v ] ; then
+ exec `$CC -print-prog-name=ld` -v
+ fi
+done
+
+while [ "$1" != "" ] ; do
+ case "$1" in
+ -save-temps*|-m32|-m64) N="$1" ;;
+ -r) N="$1" ;;
+ -flinker-output*) N="$1" ;;
+ -[Wg]*) N="$1" ;;
+ -[olv]|-[Ofd]*|-nostdlib) N="$1" ;;
+ --end-group|--start-group|--whole-archive|--no-whole-archive|\
+--no-undefined|--hash-style*|--build-id*|--eh-frame-hdr|-Bsymbolic)
+ N="-Wl,$1" ;;
+ -[RTFGhIezcbyYu]*|\
+--script|--defsym|-init|-Map|--oformat|-rpath|\
+-rpath-link|--sort-section|--section-start|-Tbss|-Tdata|-Ttext|-soname|\
+--version-script|--dynamic-list|--version-exports-symbol|--wrap|-m|-z)
+ A="$1" ; shift ; N="-Wl,$A,$1" ;;
+ -[m]*) N="$1" ;;
+ -*) N="-Wl,$1" ;;
+ *) N="$1" ;;
+ esac
+ ARGS="$ARGS $N"
+ shift
+done
+
+[ -n "$V" ] && echo >&2 $CC $ARGS
+
+exec $CC $ARGS
--
2.38.1
next parent reply other threads:[~2022-11-14 11:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221114114344.18650-1-jirislaby@kernel.org>
2022-11-14 11:43 ` Jiri Slaby (SUSE) [this message]
2022-11-14 11:43 ` [PATCH 29/46] scripts, lto: use CONFIG_LTO for many LTO specific actions Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 30/46] Kbuild, lto: Add Link Time Optimization support Jiri Slaby (SUSE)
2022-11-14 18:55 ` Josh Poimboeuf
2022-11-15 13:31 ` Martin Liška
2022-11-14 11:43 ` [PATCH 34/46] scripts, lto: disable gcc LTO for some mod sources Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 35/46] Kbuild, lto: disable gcc LTO for bounds+asm-offsets Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 38/46] Kbuild, lto: don't include weak source file symbols in System.map Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 43/46] scripts, lto: check C symbols for modversions Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 44/46] scripts/bloat-o-meter, lto: handle gcc LTO Jiri Slaby (SUSE)
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=20221114114344.18650-29-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=ak@linux.intel.com \
--cc=jslaby@suse.cz \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=mliska@suse.cz \
--cc=ndesaulniers@google.com \
/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