From patchwork Fri Apr 21 06:21:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9691933 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 E6AC96037F for ; Fri, 21 Apr 2017 06:22:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D895D285E7 for ; Fri, 21 Apr 2017 06:22:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA44285FB; Fri, 21 Apr 2017 06:22:51 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71CC8285E7 for ; Fri, 21 Apr 2017 06:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035753AbdDUGWW (ORCPT ); Fri, 21 Apr 2017 02:22:22 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:58666 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033632AbdDUGWT (ORCPT ); Fri, 21 Apr 2017 02:22:19 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id v3L6LGaS028192; Fri, 21 Apr 2017 15:21:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v3L6LGaS028192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1492755678; bh=d0a2OpoDn//lvwVomeM86WTHgT09GXRgoJ3YJK8D7sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3pW+9mFpipHagbUof3+2I/pZP6Bia48yzK/KzUKQTIOO2wfQyddMaaFu3zBSdVgE hKVj6L7VjozOYcOqoNwX75aG2L5YgmrhSxfjYYs/hgouiEGsxjCpXm4XlBVv+zD3iI 7Gaxt+YlfvA0jv7eG6ZBXV9CNR5Qxg03iShNJVAmltaXFaGfAa6td1nB+SjrUzDlS5 Te1nlx4XsLKtNd8+dx7+5VoDzvy98m1oPor+2si1hRFyaXek2fLvq92+2VNKETMHVd JKE11ffbbCsjDiGgFzR6L70F2H2/xJNGq0oljfDoXtGd0GWsQeYKrJZmMuqkJZBtVJ NaLUJW++YHcEQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Matthias Kaehlcke , David Howells , Michael Davidson , Michal Marek , Jan Beulich , Alexander van Heukelum , Jeroen Hofstee , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] kbuild: fix asm-offset generation to work with clang Date: Fri, 21 Apr 2017 15:21:11 +0900 Message-Id: <1492755671-19005-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492755671-19005-1-git-send-email-yamada.masahiro@socionext.com> References: <1492755671-19005-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeroen Hofstee KBuild abuses the asm statement to write to a file and clang chokes about these invalid asm statements. Hack it even more by fooling this is actual valid asm code. [masahiro: Import Jeroen's work for U-Boot: http://patchwork.ozlabs.org/patch/375026/ Tweak sed script a little to avoid garbage '#' for GCC case, like #define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS # */ ] Signed-off-by: Jeroen Hofstee Signed-off-by: Masahiro Yamada Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke --- Changes in v2: - V1 did not work with LLVM's integrated assembler because it uses instead of around the .ascii string. Restore [:space:]. include/linux/kbuild.h | 6 +++--- scripts/Makefile.lib | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h index 22a7219..4e80f3a 100644 --- a/include/linux/kbuild.h +++ b/include/linux/kbuild.h @@ -2,14 +2,14 @@ #define __LINUX_KBUILD_H #define DEFINE(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val)) -#define BLANK() asm volatile("\n->" : : ) +#define BLANK() asm volatile("\n.ascii \"->\"" : : ) #define OFFSET(sym, str, mem) \ DEFINE(sym, offsetof(struct str, mem)) #define COMMENT(x) \ - asm volatile("\n->#" x) + asm volatile("\n.ascii \"->#" x "\"") #endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 9c20690..9e70196 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -413,10 +413,14 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ # --------------------------------------------------------------------------- # Default sed regexp - multiline due to syntax constraints +# +# Use [:space:] because LLVM's integrated assembler inserts around +# the .ascii directive whereas GCC keeps the as-is. define sed-offsets - "/^->/{s:->#\(.*\):/* \1 */:; \ + 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \ + /^->/{s:->#\(.*\):/* \1 */:; \ s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}" + s:->::; p;}' endef # Use filechk to avoid rebuilds when a header changes, but the resulting file