From patchwork Thu Jun 15 00:50:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Sodagudi X-Patchwork-Id: 9787725 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 41FC660384 for ; Thu, 15 Jun 2017 00:51:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35CE2284C5 for ; Thu, 15 Jun 2017 00:51:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A0EB284DC; Thu, 15 Jun 2017 00:51:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A135B284C5 for ; Thu, 15 Jun 2017 00:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9Hr9uqn4l4fzlQx7P5ZTgEZOJrE2azh/nDLq48X1qKw=; b=ETuPm1GFLsp0T9Pp3NRiH0wWr 9YcLZn4WQQfzTdz5BXaAzYvEUeImD7n4OlcpdyYp16YGMkfSy6G0HZStIkqFY8RuYwPSFObpi6iE0 71yoT17OvpuOxKRnKiwxKgu6ATFLSr8xEFjKvHQQrwnpoyhTxybCkA1Id761492ocN0LY88AJhnpk UzVs5fHU7H4j/NijEDfetUOjuUR0Ca3BeSodzB3uF+PCcrCziwNLjjk1283ox7SHFGq2G4whpnfmM mz+OPEqio0yDZHOS6qlLrbcdE2HB/QSz4on1G2WjwW1tfmB8KYj5CMgS7t9ValF5+S6bYut947yC+ 9C3mF9AEg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dLJ0C-0004d3-Ka; Thu, 15 Jun 2017 00:51:12 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dLIzn-0004bC-ST for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2017 00:50:49 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 16A4D6080B; Thu, 15 Jun 2017 00:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1497487827; bh=gEi9Fj4PR/shDKyowYurPqtMysYc9/VRNtgOSzRlrjY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Gtu7Tlt041QMar7LurfMepMIpqLAVeEEbsVe1zS5hyp8P0eE1ms3OH/yui3wD2BJQ CltSTPG3XqCKW3056ZxpCUPBuuVc6BHiyCLOe9QI1GKfzrYoX2B3C5s2CHMJABp9GS /bMvzM/mkjb6Y//K0frkUdNeH98c+CeuaNYVtbc8= Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 4AA866080B; Thu, 15 Jun 2017 00:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1497487826; bh=gEi9Fj4PR/shDKyowYurPqtMysYc9/VRNtgOSzRlrjY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OWSQ0Pvs0z6YjRDJTUomPAAHFDibx8k+6pow/AfQtJKPIozZjUmqcNLxSNrHFrNUH wWYPWkLRU8G2plpvtiigiWDAQqRdQPv2k8WTdubKQSOTHVVovlOH8wbPc6TTG8Gn2D z7M2BDbg1ruQxH6Gc3UMEXH2GQo+WYAM0P1qtRSk= MIME-Version: 1.0 Date: Wed, 14 Jun 2017 17:50:26 -0700 From: Sodagudi Prasad To: Will Deacon Subject: Re: Using __always_inline attribute In-Reply-To: <9198053a46999b0b46dcab992527d0d7@codeaurora.org> References: <2a762f1f3b355e71c5bca6a6e00bffe0@codeaurora.org> <20170614100641.GB16190@arm.com> <9198053a46999b0b46dcab992527d0d7@codeaurora.org> Message-ID: X-Sender: psodagud@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170614_175047_964068_D4A73B1E X-CRM114-Status: GOOD ( 20.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, peterz@infradead.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, mingo@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 2017-06-14 15:33, Sodagudi Prasad wrote: > On 2017-06-14 03:06, Will Deacon wrote: >> Hi Prasad, >> >> On Tue, Jun 13, 2017 at 03:39:37PM -0700, Sodagudi Prasad wrote: >>> With a variant of a CLANG(based on 4.0) following errors observed on >>> Linux >>> 4.12-rc5 tag. >> >> How are you building the kernel with clang, btw? I'd be keen to try >> the same >> thing, but I thought the LLVMLinux project was largely dead at his >> point. Do >> you still need build system patches, or is this now integrated with >> Kbuild? > Hi Will, > Trying clang patches from below tree - > https://android.googlesource.com/kernel/common/+/experimental/android-4.4-llvm > >> >>> net/built-in.o: In function `__xchg_mb': >>> arch/arm64/include/asm/cmpxchg.h:99: \ >>> undefined reference to `__compiletime_assert_99' >>> arch/arm64/include/asm/cmpxchg.h:99: \ >>> undefined reference to `__compiletime_assert_99 >>> >>> Clang does not seems to be marking this macro as inline and causing >>> above >>> compilation issue due to BUILD_BUG(). >> >> The only BUILD_BUG I see around here is if the size parameter (which >> is >> calculated using sizeof) is not known to be 1,2,4 or 8 at compile >> time. It >> would be interesting to know which call site is confusing clang in >> this way >> and what code is actually being emitted here. >> >> If it's just that __xchg_mb isn't being inlined into the >> __xchg_wrapper >> macro, then your patch should be ok, but I'd like to be sure it's not >> something else. I'm also surprised you haven't see this crop up in >> other >> places. > After digging further, we observed that inline definition was changed > recently and causing this issue. > Here is missing part of inline macro definition > __attribute__((unused)). > > Commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused > static inline functions") have redefined the inline macro as below > #define inline inline __attribute__((unused)) > > But actual definition of inline macro defined compiler-gcc.h file as > shown below. > #define inline inline __attribute__((always_inline)) > notrace > > As always_inline attribute is missing in inline definition, compile > may not inline macros __xchg_mb in > arch/arm64/include/asm/cmpxchg.h file and leading to error. > > Some compilers may not honor inline as inline if always_inline > attribute is removed because of > -inline-threshold compiler options. > > Here is the change to fix this issue- > diff --git a/include/linux/compiler-clang.h > b/include/linux/compiler-clang.h > index d614c5e..a0e6433 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -22,4 +22,4 @@ > * directives. Suppress the warning in clang as well. > */ > #undef inline > -#define inline inline __attribute__((unused)) notrace > +#define inline __attribute__((always_inline)) __attribute__((unused)) > notrace > > -Thanks, Prasad Hi Will, Here is the proper patch - compiler, clang: Add always_inline attribute to inline Commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions") re-defining the 'inline' macro but __attribute__((always_inline)) is missing. Some compilers may not honor inline hint if always_iniline attribute is not there. So add always_inline attribute to inline as done by compiler-gcc.h file. __attribute__((unused)) notrace -Thanks, Prasad >> >> Will diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index d614c5e..400b0cd 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -22,4 +22,4 @@ * directives. Suppress the warning in clang as well. */ #undef inline -#define inline inline __attribute__((unused)) notrace +#define inline inline __attribute__((always_inline))