From patchwork Tue Aug 20 23:29:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 1150491 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46CnB70XMsz9s7T for ; Wed, 21 Aug 2019 09:31:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qL9WYEAm"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46CnB65RdlzDr7M for ; Wed, 21 Aug 2019 09:31:42 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=natechancellor@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qL9WYEAm"; dkim-atps=neutral Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46Cn8M4YvwzDqB5 for ; Wed, 21 Aug 2019 09:30:11 +1000 (AEST) Received: by mail-wm1-x341.google.com with SMTP id c5so51203wmb.5 for ; Tue, 20 Aug 2019 16:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3E0fEKA3bxpvm4KYV/1/j8Enrv4yxANJ69KlmVGSvq8=; b=qL9WYEAmRF2OA5tOc2hmXmPINV9AHY6IJjQG3CkcZW3MErZefGZnVpDuoKZlUnklSz Y3OEcvim5+8jgXIoV377MUTKW0p3G1Wsdz/23x2jaTKVEsnajuZEQPiyXjfozpbK5nVh usCo8wrDRKRnqhlZuuH+aIc4G1Ssn6acvhnGhpp5Ee8rMQsIwvqyBiETmghdBtg59HDN 43kRFVDbyTxL8oH6n673ADgxGh/EHhA7EcUEUAjg5afDtDb1UzzUpeL436Qjg5Y+2dDp V9oy1ayM7HyApVOLLJ33QeWST99pKGLaqaKa6mg4w5IaEaHNhF0aLFpvLALrSBaR6L6H tZpQ== 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:mime-version:content-transfer-encoding; bh=3E0fEKA3bxpvm4KYV/1/j8Enrv4yxANJ69KlmVGSvq8=; b=UAsHZYQvN0KbBywcyTGZKj943XbQOvof6CY1fqAwmZSYR9Md8rQI3W8dVgjVUEpB9k 73drjFrhcISh5p/SKo3g5Tl49fRLpoqLlaHTtG+7RYnhqJdWU5UGaanuZTyp1bWJvMbO pnLIUxMW9qvV8t93Szu//L1yPxkHDEJ7uP40gcH1+pRGui82xfwV99NSe7NTP5j0W1do muw+oWbc0Ymj3Y+VdS26vLwCrioFX0B3Tg8/D3rwjk9XtNKk2geFHTpzGRXpaxbpJ8Ap VjFenOs0gxNRQItUwWVKzWQRwIn/ZYeWlSxXmyKp+rK8k0neqyM5ICnacpyEzR++IGUK iJTQ== X-Gm-Message-State: APjAAAUJXPAQWLkKEmkJmzH3fwsq/nS1vol7U8mvLdGbM3CNC8CzQ2cs PcbXMfTG5RoNhAVBEmAqDSU= X-Google-Smtp-Source: APXvYqwLy12XGcq+Wokg8S4AmGmnxAD1uhS8zQhSmBUYtZdz5flW02Zh/pEiXqkfah0Vjuf5p/b7zg== X-Received: by 2002:a1c:790d:: with SMTP id l13mr2185240wme.49.1566343807239; Tue, 20 Aug 2019 16:30:07 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id u7sm15703259wrp.96.2019.08.20.16.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:30:06 -0700 (PDT) From: Nathan Chancellor To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: [PATCH v2] powerpc: Don't add -mabi= flags when building with Clang Date: Tue, 20 Aug 2019 16:29:22 -0700 Message-Id: <20190820232921.102673-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190818191321.58185-1-natechancellor@gmail.com> References: <20190818191321.58185-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: clang-built-linux@googlegroups.com, Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Daniel Axtens Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When building pseries_defconfig, building vdso32 errors out: error: unknown target ABI 'elfv1' This happens because -m32 in clang changes the target to 32-bit, which does not allow the ABI to be changed, as the setABI virtual function is not overridden: https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0-rc2/clang/include/clang/Basic/TargetInfo.h#L1073-L1078 https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0-rc2/clang/lib/Basic/Targets/PPC.h#L327-L365 Commit 4dc831aa8813 ("powerpc: Fix compiling a BE kernel with a powerpc64le toolchain") added these flags to fix building big endian kernels with a little endian GCC. Clang doesn't need -mabi because the target triple controls the default value. -mlittle-endian and -mbig-endian manipulate the triple into either powerpc64-* or powerpc64le-*, which properly sets the default ABI: https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0-rc2/clang/lib/Driver/Driver.cpp#L450-L463 https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0-rc2/llvm/lib/Support/Triple.cpp#L1432-L1516 https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0-rc2/clang/lib/Basic/Targets/PPC.h#L377-L383 Adding a debug print out in the PPC64TargetInfo constructor after line 383 above shows this: $ echo | ./clang -E --target=powerpc64-linux -mbig-endian -o /dev/null - Default ABI: elfv1 $ echo | ./clang -E --target=powerpc64-linux -mlittle-endian -o /dev/null - Default ABI: elfv2 $ echo | ./clang -E --target=powerpc64le-linux -mbig-endian -o /dev/null - Default ABI: elfv1 $ echo | ./clang -E --target=powerpc64le-linux -mlittle-endian -o /dev/null - Default ABI: elfv2 Don't specify -mabi when building with clang to avoid the build error with -m32 and not change any code generation. -mcall-aixdesc is not an implemented flag in clang so it can be safely excluded as well, see commit 238abecde8ad ("powerpc: Don't use gcc specific options on clang"). pseries_defconfig successfully builds after this patch and powernv_defconfig and ppc44x_defconfig don't regress. Link: https://github.com/ClangBuiltLinux/linux/issues/240 Reviewed-by: Daniel Axtens Signed-off-by: Nathan Chancellor --- v1 -> v2: * Improve commit message wording and explanation. * Add Daniel's reviewed-by. arch/powerpc/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index c345b79414a9..971b04bc753d 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -93,11 +93,13 @@ MULTIPLEWORD := -mmultiple endif ifdef CONFIG_PPC64 +ifndef CONFIG_CC_IS_CLANG cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 endif +endif ifndef CONFIG_CC_IS_CLANG cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align @@ -144,6 +146,7 @@ endif endif CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no) +ifndef CONFIG_CC_IS_CLANG ifdef CONFIG_CPU_LITTLE_ENDIAN CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) @@ -152,6 +155,7 @@ CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) endif +endif CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)