From patchwork Fri Jul 13 15:30:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 10523579 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 1AD9C601C2 for ; Fri, 13 Jul 2018 15:30:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0895F29C4D for ; Fri, 13 Jul 2018 15:30:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0C8C29CB0; Fri, 13 Jul 2018 15:30:44 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 86D0629C4D for ; Fri, 13 Jul 2018 15:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730149AbeGMPpt (ORCPT ); Fri, 13 Jul 2018 11:45:49 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37985 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729725AbeGMPpt (ORCPT ); Fri, 13 Jul 2018 11:45:49 -0400 Received: by mail-pl0-f68.google.com with SMTP id b1-v6so12349001pls.5 for ; Fri, 13 Jul 2018 08:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ciWjzt1NHGWjS5vKTA/ijV1ahtym+4HbGR1Y0dLCQ0o=; b=w6Yg8QvQFtmGoH0Z4ktJIDuW5l7aBK+zHagMbzPPi1oQ5tFhU4v2NOcb+5dnbYnzIT BGW+S6l1Un+NjIEWfq3bvVsJ/sFoC91oq/n42eGIwgf0G6R/bzYJkz0KwWoEi5qT0pSb TFltgL8EUjkdA8LV4ARDGIYqC/7eIRGM1ftIxQEarBsMR6TOZeeen89w+K8t+PuU9wUa epfIa9vPgaPcGgYUKo5J1xNvtomfs/RLzY4wil/R1pZiIRr46mNg5kmCagg5R++i49es wOL3A3ZuCBN/6ek2JbyypzC4XsN1YN/BTaLaKnu4EE/wQhRYRG85a6PZqpat4vJcQO9/ MQEA== 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=ciWjzt1NHGWjS5vKTA/ijV1ahtym+4HbGR1Y0dLCQ0o=; b=FkAdBq2C0T/adwmqPUOUxOxmgocsBa53r/3g5hOgE0nq81/aYVq1YJSicf+pB5eBZ2 SbVlHCyjkRwF4GV7eI05IcrRR4OYpYlZOnkbBEdvXuCwvtzxtaFMzs3yf2Klwb3oAXLD yO1UGgJLvMy4gfo0SZecU5/k63mNYm/M9050yIMOKbpaF3giR26vJ82/Fz41yPCgqVz+ gzoeYFk8JKiDBSy9Ksnk0jLFCSvwy9XTzmY8Kn1cFSyK66k6bSs79rWeF6WxFrjxDzFZ syZir6yXxbLO2Z5COPswvDdNuvbCflKbM3bPrsk0VE87FdhY/pwidIi6zWXbL4P23xuB c6Yg== X-Gm-Message-State: AOUpUlFXlnGceIgbruvpcQrn8rYswvv4GX5ChM5Y+qx3vTCTjxrTAP+/ 1wg3LQjm7TMVircTq7JNb50Hyw== X-Google-Smtp-Source: AAOMgpf1sK5nvpu724GMOdErS0WEK6rxS53VyMdh/wSKiKXYI7XqTynPcozJ/SnblaRSDMjouLDoNQ== X-Received: by 2002:a17:902:bf0b:: with SMTP id bi11-v6mr6714436plb.25.1531495842796; Fri, 13 Jul 2018 08:30:42 -0700 (PDT) Received: from localhost.localdomain (99-152-116-91.lightspeed.sntcca.sbcglobal.net. [99.152.116.91]) by smtp.gmail.com with ESMTPSA id c29-v6sm21192139pfe.169.2018.07.13.08.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 08:30:41 -0700 (PDT) From: Olof Johansson To: Will Deacon , Catalin Marinas Cc: Masahiro Yamada , Michal Marek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Olof Johansson , Paul Kocialkowski Subject: [PATCH] arm64: build with baremetal linker target instead of Linux when available Date: Fri, 13 Jul 2018 08:30:33 -0700 Message-Id: <20180713153033.20540-1-olof@lixom.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180713150701.GA3049@arm.com> References: <20180713150701.GA3049@arm.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 Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't. Reported-by: Laura Abbott Cc: Paul Kocialkowski Signed-off-by: Olof Johansson Tested-by: Laura Abbott Acked-by: Masahiro Yamada --- arch/arm64/Makefile | 9 +++++---- scripts/Kbuild.include | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index e7101b19d590..efe61a2e4b5e 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) KBUILD_CPPFLAGS += -mbig-endian CHECKFLAGS += -D__AARCH64EB__ AS += -EB -# We must use the linux target here, since distributions don't tend to package -# the ELF linker scripts with binutils, and this results in a build failure. -LDFLAGS += -EB -maarch64linuxb +# Prefer the baremetal ELF build target, but not all toolchains include +# it so fall back to the standard linux version if needed. +LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb) UTS_MACHINE := aarch64_be else KBUILD_CPPFLAGS += -mlittle-endian CHECKFLAGS += -D__AARCH64EL__ AS += -EL -LDFLAGS += -EL -maarch64linux # See comment above +# Same as above, prefer ELF but fall back to linux target if needed. +LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux) UTS_MACHINE := aarch64 endif diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c8156d61678c..1e13f502b42f 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\ $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) # ld-option -# Usage: LDFLAGS += $(call ld-option, -X) -ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2)) +# Usage: LDFLAGS += $(call ld-option, -X, -Y) +ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3)) # ar-option # Usage: KBUILD_ARFLAGS := $(call ar-option,D)