From patchwork Mon Nov 14 11:43:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 13042179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B154FC4332F for ; Mon, 14 Nov 2022 11:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236818AbiKNLqr (ORCPT ); Mon, 14 Nov 2022 06:46:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236779AbiKNLqH (ORCPT ); Mon, 14 Nov 2022 06:46:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F110523392; Mon, 14 Nov 2022 03:45:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B9556106E; Mon, 14 Nov 2022 11:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31EBBC433D6; Mon, 14 Nov 2022 11:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668426305; bh=cDaL2fr4ds1QFPZqTUk+kKTp3g2JDWGKaf0MMC6B8X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=axz9z9rmp0DF1yNW2Noyvv4Ams50QT88IMMv7mytIv0BAoxo3ZprIJOr3jD2qNkrH hLr2L8iLnT9EqQrGmrVi+ERKM2z7/wk2jkUtqr2gQggsZfBszIRDNeWhDZG0m/xMPI g6leDXiyanYdsK11/1nbv9vxpama8/y0C7iVa5DVRx60ByfqeVTVBFztfRXZJdEy1G vlLWZCVQlFb/1TNrxcaswglRAzWwC4BgmYFyM8qtqLiXtG+5cBribG3CViVtlQEqZE ZksYWKtDotJ7HbrcxfDMelz0cNtFB3Cf4kpoaaIORBy+haBnZdaPlB7QSUCHuNlwsq 7N3JHoXdEPk5Q== From: "Jiri Slaby (SUSE)" To: linux-kernel@vger.kernel.org Cc: Andi Kleen , Masahiro Yamada , Michal Marek , Nick Desaulniers , linux-kbuild@vger.kernel.org, Martin Liska , Jiri Slaby Subject: [PATCH 28/46] scripts, lto: re-add gcc-ld Date: Mon, 14 Nov 2022 12:43:26 +0100 Message-Id: <20221114114344.18650-29-jirislaby@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114114344.18650-1-jirislaby@kernel.org> References: <20221114114344.18650-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Andi Kleen 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 Cc: Michal Marek Cc: Nick Desaulniers Cc: linux-kbuild@vger.kernel.org Signed-off-by: Andi Kleen Signed-off-by: Martin Liska Signed-off-by: Jiri Slaby --- 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