From patchwork Mon Apr 24 20:04:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9697111 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 4D57D603F3 for ; Mon, 24 Apr 2017 20:05:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41B1728066 for ; Mon, 24 Apr 2017 20:05:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36470283F9; Mon, 24 Apr 2017 20:05:24 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 C5F6228066 for ; Mon, 24 Apr 2017 20:05:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S977521AbdDXUFU (ORCPT ); Mon, 24 Apr 2017 16:05:20 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:33814 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S977304AbdDXUFT (ORCPT ); Mon, 24 Apr 2017 16:05:19 -0400 Received: by mail-pg0-f50.google.com with SMTP id v1so6420959pgv.1 for ; Mon, 24 Apr 2017 13:05:19 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=HXQjxNLQ8iPei73Z1LFSF43+YcYCXjI3Znf+jWsOiTo=; b=uOJI6O8V3A0VdxLroLZxQhTphtf7ABlgLHtbQ64CJWhoI7lXQb4sZxMgIJC/0ct1s5 bUuOdOICkwGiQge1P5zR6rPLh1dxkcdpCBHNuAH4nvUfx+UswDYLjAouy4VBtZGjCHRb ZXVy2a5iMKbaMMS8B7B5Mx4bjGkWmS0eBcho9lJq15ythYou5pldQ0U8fZcD9En2+yHE 90K5AvyT8YdleYDeEDjsUoR1zQMqjz4w+wjCpPHhWGvyF2PNsGQGgIiXDB3h522JExa3 GV4Jl2GRbbgRUAo3gOfABq65xns7VhmdJVw5tY+pHrJzcCxXfUGiRGSEhIf42n8coDVZ Arbg== X-Gm-Message-State: AN3rC/4gvttiq4RO/qlUFzBf9QbbduUKjkDgxGiLvm9uctt4dsEPjkvU vJMcqexvxr8h99pS X-Received: by 10.84.191.228 with SMTP id a91mr35244133pld.62.1493064318730; Mon, 24 Apr 2017 13:05:18 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.64.162]) by smtp.gmail.com with ESMTPSA id 133sm19736010pfv.127.2017.04.24.13.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 13:05:17 -0700 (PDT) From: Matthias Kaehlcke To: Masahiro Yamada , Michal Marek , =?UTF-8?q?Vin=C3=ADcius=20Tinti?= , Behan Webster Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Grant Grundler , Greg Hackmann , Michael Davidson , Matthias Kaehlcke Subject: [PATCH v4] kbuild: Add support to generate LLVM assembly files Date: Mon, 24 Apr 2017 13:04:58 -0700 Message-Id: <20170424200458.74416-1-mka@chromium.org> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog MIME-Version: 1.0 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 Add rules to kbuild in order to generate LLVM assembly files with the .ll extension when using clang. # from c code make CC=clang kernel/pid.ll From: Vinícius Tinti Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster Signed-off-by: Matthias Kaehlcke --- Changes in v4: - changed 'bitcode' to 'assembly' - removed rule for creating LLVM assembly from machine assembly - added .ll files to clean rule - corrected example command in commit message .gitignore | 1 + Makefile | 5 +++++ scripts/Makefile.build | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index c2ed4ecb0acd..0c39aa20b6ba 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers *.dwo diff --git a/Makefile b/Makefile index e11989d36c87..1cf775d7c510 100644 --- a/Makefile +++ b/Makefile @@ -1361,6 +1361,8 @@ help: @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM assembly file' + @echo ' (requires compiler support for LLVM assembly generation)' @echo ' dir/file.lst - Build specified mixed source/assembly target only' @echo ' (requires a recent binutils and recent build (System.map))' @echo ' dir/file.ko - Build module including final link' @@ -1545,6 +1547,7 @@ clean: $(clean-dirs) -o -name '*.symtypes' -o -name 'modules.order' \ -o -name modules.builtin -o -name '.tmp_*.o.*' \ -o -name '*.c.[012]*.*' \ + -o -name '*.ll' \ -o -name '*.gcno' \) -type f -print | xargs rm -f # Generate tags for editors @@ -1648,6 +1651,8 @@ endif $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +%.ll: %.c prepare scripts FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) # Modules /: prepare scripts FORCE diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d883116ebaa4..e5f1425c601f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -177,6 +177,14 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +# LLVM assembly +# Generate .ll files from .c +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ + cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $< + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) + # C (.c) files # The C file is compiled and updated dependency information is generated. # (See cmd_cc_o_c + relevant part of rule_cc_o_c)