Received: by 10.213.65.68 with SMTP id h4csp540754imn; Sun, 25 Mar 2018 06:26:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ZKGuRC+l5U3UHPbgnT7Pi7istKz57aRvWrcrpTMyVKl6F6nMWLj4qOmnInniolSgPXmqB X-Received: by 10.98.172.21 with SMTP id v21mr2936303pfe.203.1521984389321; Sun, 25 Mar 2018 06:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521984389; cv=none; d=google.com; s=arc-20160816; b=oCvZGT4nHTjedp5ffXxFhGBaRhSpKtasvZ8FluhshnpUoYaPcliRTqBJZ7Eysqxrip zUtAeiOL5tDMaqB+jd/RD7J7+yJqYl3uR8OYIWtjt2xiYo+hr35BM8gNZsf2P5XoXPXj i6tYJbUShe8vHdo6M0GHtnfznlhfodsQcyumgi3rf1AEIllJ/lCwya3oB6bOVc1ylMCK GKxvVaVo4gxcGozUOZrkowzFyorA0HLAWb4yx1MuZ7AX5fJ27z/drVtXYniUmMVu5BEu 1R9nE4k2nsbY2CkfcVaAJGNU9B7zHrsqVtUn0IVIoDp4TzfbFQlrKVYr53rXmLe8vQLs EXYg== 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=cHPhmYnDbz67Ul/bGSVQUn7ZlBOYXDMvbCTBiB5SzeA=; b=c6Rqu5ghFP2u7TJoXao0H5mCAgy/xauMgmH20ZzGhNwFo/QraHtwRfSdZJwVVx8RRK LN09VNqyKSMborsVb0feOOKa6UlXVVr24CVnzi93aF33zDCGu6MIdINssFQMIWTO8w26 W/P0MU6QQm99kbAGjnv6xgm3z9tn57kjY3jQsvLbQ6maFDdSd3lFNqc5sdsw1Wf31tCB kmg/ShKwsI1fifwLtqHqw55AxL+sYCKxuCLMA2weHq6MVOWSaVOV5+WJujJl69EeG4bK lDje3TQu19caJK3c8sMFDuqym7sGvvmMfayl2fRWAlI/7tHI43sjT6w7YPLICriDrMTu P9HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=qWIfbP8/; 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 d23si8825853pgn.235.2018.03.25.06.26.02; Sun, 25 Mar 2018 06:26:29 -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=qWIfbP8/; 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 S1753269AbeCYNYO (ORCPT + 99 others); Sun, 25 Mar 2018 09:24:14 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:51949 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbeCYNYL (ORCPT ); Sun, 25 Mar 2018 09:24:11 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id EABEC5C0223; Sun, 25 Mar 2018 15:23:42 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Sun, 25 Mar 2018 15:24:09 +0200 From: Stefan Agner To: Stefan Agner Cc: Russell King - ARM Linux , 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, mka@chromium.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: <20180320231832.GK2743@n2100.armlinux.org.uk> References: <20180320230206.25289-1-stefan@agner.ch> <20180320230206.25289-6-stefan@agner.ch> <20180320231832.GK2743@n2100.armlinux.org.uk> Message-ID: <83b9fadfc294ef195b6aff54f000d9a6@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=1521984223; bh=cHPhmYnDbz67Ul/bGSVQUn7ZlBOYXDMvbCTBiB5SzeA=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; b=qWIfbP8/wXGOWwtXsjaPKzF/bv9sVy07nOHzyGiAvnQ5uRUKJmQ4jJT7GUVzjtKOrOUy/D/FiBhcIUl502sQD5x88uIwTEjBELq+GniI/EzJUpNF3VsJSyCCDkzU7OniYjnVJ62GPpt/zKBsaYu/KRnyjjL/q4Qsb4yAAul+uag= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.03.2018 00:18, Russell King - ARM Linux wrote: > 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 >> --- >> 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. Just for the records, compiled with clang, this patchset applied and CONFIG_FRAME_POINTER=y as expected leads to a non functional backtrace: [ 4.583711] ------------[ cut here ]------------ [ 4.588347] WARNING: CPU: 0 PID: 1 at init/main.c:1012 kernel_init+0x60/0x238 [ 4.595505] Modules linked in: [ 4.598590] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.16.0-rc5-00019-g686ee524148e-dirty #42 [ 4.608514] Hardware name: Freescale i.MX7 Dual (Device Tree) [ 4.614266] Backtrace: [ 4.616728] [] (0xdc063f34) from [<00000000>] ( (null)) [ 4.622918] Backtrace aborted due to bad frame pointer <8c0165e4> [ 4.629046] ---[ end trace 200951c950497708 ]--- clang with CONFIG_FRAME_POINTER=y should really error out. Without the cc-option calls building witih clang will print the following errors: ... CC kernel/bounds.s clang-6.0: error: unknown argument: '-mapcs' clang-6.0: error: unknown argument: '-mno-sched-prolog' ... Using CONFIG_ARM_UNWIND=y compiles fine and backtraces do work fine too: [ 4.630877] ------------[ cut here ]------------ [ 4.635515] WARNING: CPU: 0 PID: 1 at init/main.c:1012 kernel_init+0x5c/0x234 [ 4.642672] Modules linked in: [ 4.645742] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.16.0-rc5-00019-g686ee524148e-dirty #41 [ 4.655666] Hardware name: Freescale i.MX7 Dual (Device Tree) [ 4.661437] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 4.669200] [] (show_stack) from [] (dump_stack+0x9c/0xac) [ 4.676442] [] (dump_stack) from [] (__warn+0xb4/0x120) [ 4.683419] [] (__warn) from [] (warn_slowpath_null+0x40/0x48) [ 4.691003] [] (warn_slowpath_null) from [] (kernel_init+0x5c/0x234) [ 4.699111] [] (kernel_init) from [] (ret_from_fork+0x14/0x2c) [ 4.706691] Exception stack(0xdc063fb0 to 0xdc063ff8) [ 4.711752] 3fa0: 00000000 00000000 00000000 00000000 [ 4.719943] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 4.728133] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 4.734792] ---[ end trace 200951c950497708 ]--- -- Stefan