From patchwork Wed Nov 29 23:44:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 10083937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78FFC6020B for ; Wed, 29 Nov 2017 23:46:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B7F629C84 for ; Wed, 29 Nov 2017 23:46:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6056929D55; Wed, 29 Nov 2017 23:46:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1545A29C84 for ; Wed, 29 Nov 2017 23:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753072AbdK2Xo5 (ORCPT ); Wed, 29 Nov 2017 18:44:57 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:34021 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752708AbdK2Xoy (ORCPT ); Wed, 29 Nov 2017 18:44:54 -0500 Received: by mail-pl0-f68.google.com with SMTP id d21so3069562pll.1 for ; Wed, 29 Nov 2017 15:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SlYvTcgCKJS3q6n8QM2qaI3UJ2v/g8LRNVG+cO2Gckg=; b=COuw69veuRya8rA9VtbDCSIYvwP2K2pb7D+qsZ/a/M10BZHIfrawR4HL9hgd5YvA+D Biy1S4UIVDaMwfHRxRTKMT8Zi4zc7mbWf5rg4XGRowcLqIhDZvXQMwrBNM2jgFvgRKHv mlc8937FX5sPytbBx/4tGzQnumAx/UsWyjXlF2LxYK4npgzw8rtncj5JIT9Gn+i3mEZ7 cJDYOz6yjUSPD2RvoR+BShJ3zfWPlq9N7GMtuSU4b8nxkYC39S1NumWJjDaropMMklaL cB1Aizm1t24d0t8IGZ47d424klDoURDRWUtBTLR5mvQdkJcXuTd4qVO5+WHRV7ReYqw/ wpuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SlYvTcgCKJS3q6n8QM2qaI3UJ2v/g8LRNVG+cO2Gckg=; b=CHoBAwYpHTf9po5h4xuECsiHyBL1NH5uF2IItFjDPejV/RhtEQDDzbx6PEoxTyeim5 O9OLbKKgD2GFnW6DKuY4QjUffirFvqcaGJcmQHMy0B8eo8bH+zwOh6DNWUgUBftByg6/ Abi4RuogdCN/Gspsx+Pn4bz4vWzb/hiL+SvBrR5gfQY94aSXwFKjAWQOmoipVIkRNYpH PIxiNZffu0217/l/MYDoquu9KIycb8Xs47XRhNaDnlv1RbENGJI7gFEWeeJ6dHAP8Zd9 SSQLPYUuEGZz5cZjHVNZIaTG3LMparHSW2U1YBX3+oz/BI0iAicRXQGQxKP9hIZ/ruCi HR9Q== X-Gm-Message-State: AJaThX77rScYRzdq4Um1aMzG2kiv00E8Ecfo+eLWLvoz4K6rEtu1QQP+ HWzCt8ohzIl1bpPAaoDYZNE/aQ== X-Google-Smtp-Source: AGs4zMYGzaRJW5r30QoI47KOQ9YDQeOR8JvckwvbRl2nwitALe152BTcTkweXSNLMJEtudEp2psbvA== X-Received: by 10.159.207.149 with SMTP id z21mr157894plo.68.1511999093245; Wed, 29 Nov 2017 15:44:53 -0800 (PST) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id s14sm5326948pfe.36.2017.11.29.15.44.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 15:44:49 -0800 (PST) From: Sami Tolvanen To: Alex Matveev , Andi Kleen , Ard Biesheuvel , Greg Hackmann , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Masahiro Yamada , Maxim Kuvyrkov , Michal Marek , Nick Desaulniers , Yury Norov , Matthias Kaehlcke , Nicholas Piggin Cc: Sami Tolvanen Subject: [PATCH 1/7] kbuild: add ld-name macro and support for GNU gold Date: Wed, 29 Nov 2017 15:44:36 -0800 Message-Id: <20171129234442.655-2-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171129234442.655-1-samitolvanen@google.com> References: <20171129234442.655-1-samitolvanen@google.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP GNU gold may require different flags than GNU ld. Add a macro for detecting the linker and conditionally add gold specific flags from LDFLAGS_GOLD. Signed-off-by: Sami Tolvanen Reviewed-by: Nick Desaulniers --- Makefile | 5 +++++ scripts/Kbuild.include | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile b/Makefile index f761bf475ba5..a16c98d6e3ba 100644 --- a/Makefile +++ b/Makefile @@ -814,6 +814,11 @@ include scripts/Makefile.kasan include scripts/Makefile.extrawarn include scripts/Makefile.ubsan +# Add any flags specific to ld.gold +ifeq ($(ld-name),gold) +LDFLAGS += $(LDFLAGS_GOLD) +endif + # Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the # last assignments KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b6d7d347b203..a7c7843c2cf1 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -277,6 +277,10 @@ ld-option = $(call try-run-cached,\ # Important: no spaces around options ar-option = $(call try-run-cached, $(AR) rc$(1) "$$TMP",$(1),$(2)) +# ld-name +# Expands to either bfd or gold +ld-name = $(shell $(LD) -v 2>&1 | grep -q "GNU gold" && echo gold || echo bfd) + # ld-version # Note this is mainly for HJ Lu's 3 number binutil versions ld-version = $(call shell-cached,$(LD) --version | $(srctree)/scripts/ld-version.sh)