Received: by 10.213.65.68 with SMTP id h4csp1083240imn; Wed, 21 Mar 2018 02:04:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELsVdxBpADPsdk3EDIYA5E1ZvsXwNGAfas8fYiBtdGaNyo7VIhEOTRfXAjBze+U4HfTYZwsm X-Received: by 10.99.107.131 with SMTP id g125mr14211751pgc.16.1521623083611; Wed, 21 Mar 2018 02:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521623083; cv=none; d=google.com; s=arc-20160816; b=P8Dnb4N7VTlFHV/vuLtkrP6P48J+AIrSAloYxfEgiRcI4lCY2keHDSCt4Hyvy5UK4S kwFrkHzdo5WnB5GGTNUPNutmxjO283piBpG4A5VTYGQ7lk98peBl9vF139QfB/L93whj ORhSYa0REerCFTRWLgsDwFweT3DwVttefC2G5M4vNKyCm6GixPRSMRYmDMNfy7Fpsf+N gG5BLO1+YR+VEFwtSqiCVy/QP5FilQRJK/FbKIzWgZ3UfojMpvYvRwqhG9fvKqTrSsUE USF+zKBi7dZeyzlZHUTyrya6Zbuluv8WrqmySIn9ayz2rTb7XOYodkBG8Z6nfRuCA0gU 05zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:user-agent:message-id :references:in-reply-to:subject:cc:to:from:date :content-transfer-encoding:mime-version:arc-authentication-results; bh=Tb/jBQbXYc12stczqEm7hL4pLtQtK4Put81knCJnw2Y=; b=O1aOtz9JWqNiM+Omsrn+72Gs6WW6Dqj/bL6S3igercqALoDchCUi1y2aTYkwEV7Rgo Z0AHnEygaScGgr6EDRFwlNKwABmCMHirQVSfup2QsA3By48l5aUg4yoG/gQj407NbPL0 XFNdJO5MtCkNNKtQuX1ToqZcDgKYITW+rgEACGlUU3rhGSS90OA9XJ3qMQtBmixs68PU AnS7fmeTdhAlVyctueeH3Q9Ik6zTwfhT/gO4TQy0/BfzKDK2TTzs9DoZbybabq78dnpS uxaif2SWRkFjub/xc702R6RTersHSU2G/X9aZUcH79295x35MJEB1656MGJewzbdXW3s JN+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=wEACp7Vb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v190si2506192pgb.67.2018.03.21.02.04.29; Wed, 21 Mar 2018 02:04:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=wEACp7Vb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751775AbeCUJD2 (ORCPT + 99 others); Wed, 21 Mar 2018 05:03:28 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:48568 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671AbeCUJDX (ORCPT ); Wed, 21 Mar 2018 05:03:23 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 5119F5C1EFB; Wed, 21 Mar 2018 10:03:00 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: Wed, 21 Mar 2018 10:03:22 +0100 From: Stefan Agner To: Matthias Kaehlcke , Russell King - ARM Linux Cc: ard.biesheuvel@linaro.org, arnd@arndb.de, nicolas.pitre@linaro.org, marc.zyngier@arm.com, behanw@converseincode.com, keescook@chromium.org, Bernhard.Rosenkranzer@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/5] ARM: add support for building ARM kernel with clang In-Reply-To: <20180321002022.GH37438@google.com> References: <20180320230206.25289-1-stefan@agner.ch> <20180320230206.25289-6-stefan@agner.ch> <20180320231832.GK2743@n2100.armlinux.org.uk> <20180321002022.GH37438@google.com> Message-ID: <602b427702af61a503d9ffe38c35075c@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1521622980; bh=Tb/jBQbXYc12stczqEm7hL4pLtQtK4Put81knCJnw2Y=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; b=wEACp7VbmAHsmbE8uGyzW7BU0ClFmqz0ygJcr3RWVPMHEeHKuOlRdDF9JEU1/lAah9KlH7lprThcXkwR9oZ/cqQ+eq2yo7YtTh6Ax4aGmgObbenPBmZuH6u22hKUx0i76p5aMLwJsy6UW3Mij0gv452F+WUzivMT9rkls2/2cmM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.03.2018 01:20, Matthias Kaehlcke wrote: > El Tue, Mar 20, 2018 at 11:18:33PM +0000 Russell King - ARM Linux ha dit: > >> On Wed, Mar 21, 2018 at 12:02:06AM +0100, Stefan Agner wrote: >> > Use cc-options call for compiler options which are not available >> > in clang. With this patch an ARMv7 multi platform kernel can be >> > successfully build using clang (tested with version 5.0.1). >> > >> > Based-on-patches-by: Behan Webster >> > Signed-off-by: Stefan Agner > > Great to see your work on bringing clang support for 32-bit ARM > upstream! > >> > --- >> > arch/arm/Makefile | 2 +- >> > arch/arm/boot/compressed/Makefile | 2 +- >> > 2 files changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/arch/arm/Makefile b/arch/arm/Makefile >> > index e9e3fde3c657..20e9fee1ccc5 100644 >> > --- a/arch/arm/Makefile >> > +++ b/arch/arm/Makefile >> > @@ -39,7 +39,7 @@ KBUILD_CFLAGS += $(call cc-option,-mno-unaligned-access) >> > endif >> > >> > ifeq ($(CONFIG_FRAME_POINTER),y) >> > -KBUILD_CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog >> > +KBUILD_CFLAGS +=-fno-omit-frame-pointer $(call cc-option,-mapcs,) $(call cc-option,-mno-sched-prolog,) >> >> Some of these options here are to ensure that we generate the following >> code, so we can backtrace: >> >> mov ip, sp >> stmfd sp!, {fp, ip, lr, pc} >> sub fp, ip, #4 >> >> If clang isn't producing that code at the start of functions with >> CONFIG_FRAME_POINTER=y, then backtracing will not work, and arguably >> CONFIG_FRAME_POINTER=y is useless there. In that circumstance, it's >> probably better to fail so the user can configure something more >> debuggable, rather than having the kernel potentially producing >> undebuggable oopses. With clang and -fno-omit-frame-pointer function prologue looks something like this: 0: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr} 4: e28db01c add fp, sp, #28 ... This bug seems to be related: https://bugs.llvm.org/show_bug.cgi?id=18505 It seems that LLVM/clang does not plan to add APCS format/gcc interoperability for the same frame layout. I guess it would be possible to support the LLVM/clang frame layout? But until then, I am with Russel here: Better just let clang fail on CONFIG_FRAME_POINTER=y. Most configs probably anyway use CONFIG_ARM_UNWIND. At least multi_v7_defconfig does. > > Which option in particular is important to generate the above code for > backstracing? For gcc, I guess really all of them. -- Stefan > > According to the gcc doc -mapcs(-frame) is deprecated. > > For -mno-sched-prolog the doc says: > > "Prevent the reordering of instructions in the function prologue, or > the merging of those instruction with the instructions in the > function’s body. This means that all functions start with a > recognizable set of instructions (or in fact one of a choice from a > small set of different function prologues), and this information can > be used to locate the start of functions inside an executable piece of > code. The default is -msched-prolog." > > Thanks > > Matthias