From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A48C49ED6 for ; Wed, 11 Sep 2019 18:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AAC420838 for ; Wed, 11 Sep 2019 18:21:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hKGZhQsc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbfIKSVi (ORCPT ); Wed, 11 Sep 2019 14:21:38 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36562 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729758AbfIKSVi (ORCPT ); Wed, 11 Sep 2019 14:21:38 -0400 Received: by mail-wm1-f67.google.com with SMTP id t3so596345wmj.1 for ; Wed, 11 Sep 2019 11:21:35 -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=wlwkreJLiH000TkL/I+nagVzmxnKwtX6/RI0S+Wf63c=; b=hKGZhQscUbNpwvhbBmzJE5rFZgRkwvD9/oiNRxYjGAsVkTilmapKoZdm3AUVR6aEfe 6ClFLL9oKo+3iXCtcEPH9xPwnNEC204wkwAoq4rwVV2LaW3dSQB7G6ZibmUJ4wOXb9xn 2HQs832KFhz+4iT/5nvPjXbRQGonAJQBRJ4+9oSZxYQEYX3PrZ/ysL0z27nS3jKNloWU 1QHBaAQdaHzvysoPDoUGyeYKBv2XOPac/RM/rREtrT+Lz1SNA8PAKCMgd++uWkcxWPAS NNCN1NTQEhGY6I4r6qvcignOtM+WREgYmTKiEf04lUFKqYJ7S+5tsCgxUr4mSp1sGVVv gB1w== 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=wlwkreJLiH000TkL/I+nagVzmxnKwtX6/RI0S+Wf63c=; b=azW9cW+UOUfmx4UYwOptDylwxWSO4YLwe98G4q7kzifUxPwtu3Y6By+XamPnzaV4uM zBbILn8XUxbsJiSPnSloS0r2OVU4Gyi0dXjU5WrdXwMCQwoCCLGI0+2liBkH/TmTh+Bn fRg2xTxw9DH/T1Wc56sO9/3W+1Xivn2jbTxIn/G4nl/09WIFy2cjhUuu090B1E6p2ZgG 2E82a2JQoXAShBf8zYG8ZUREZe3MHMGLxWPXXZSS3n3x249ZJQEoCa907I+8BJHVEkVV gpLqasGmLdM+JgmhngJIEVdpXlBK7qysU9gMlX0kQv7YL2+1F3j+3H0sqlkaL2t6x707 DFrg== X-Gm-Message-State: APjAAAXtTLr+wT4jH5lPGWMm41uKNrtiXQT86lUMkXQK4vbaMyBTlISo wwxJsWIuIFVY6pYbXUqkD5E= X-Google-Smtp-Source: APXvYqyleXXjEorGaKD9ck8QMoH1+NVOdLcyINZOZd9kylDsAeiOy+WMu/ZstSjZJtQsIASujOMMLw== X-Received: by 2002:a1c:7314:: with SMTP id d20mr4832772wmb.107.1568226095056; Wed, 11 Sep 2019 11:21:35 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id q9sm2356753wmq.15.2019.09.11.11.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 11:21:34 -0700 (PDT) From: Nathan Chancellor To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Daniel Axtens Subject: [PATCH v3 1/3] powerpc: Don't add -mabi= flags when building with Clang Date: Wed, 11 Sep 2019 11:20:49 -0700 Message-Id: <20190911182049.77853-2-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190911182049.77853-1-natechancellor@gmail.com> References: <20190911182049.77853-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 v2 -> v3: * Rebase and merge into a single series. arch/powerpc/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 46ed198a3aa3..150925a2e06e 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 @@ -143,6 +145,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) @@ -151,6 +154,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) -- 2.23.0