From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755150AbdDDR1g (ORCPT ); Tue, 4 Apr 2017 13:27:36 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:35304 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754650AbdDDR1d (ORCPT ); Tue, 4 Apr 2017 13:27:33 -0400 From: Matthias Kaehlcke To: Michal Marek , Emese Revfy , Kees Cook , Behan Webster , "Luis R . Rodriguez" , =?UTF-8?q?Vin=C3=ADcius=20Tinti?= , Kyeongmin Cho Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Grant Grundler , Michael Davidson , Greg Hackmann , Peter Foley , Matthias Kaehlcke Subject: [PATCH v3] kbuild: Add support to generate LLVM bitcode files Date: Tue, 4 Apr 2017 10:27:06 -0700 Message-Id: <20170404172706.171971-1-mka@chromium.org> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinícius Tinti Add rules to kbuild in order to generate LLVM bitcode files with the .ll extension when using clang. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll From: Vinícius Tinti Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster Signed-off-by: Matthias Kaehlcke --- Resending, original v3 patch: https://patchwork.kernel.org/patch/4891071/ .gitignore | 1 + Makefile | 6 ++++++ scripts/Makefile.build | 14 ++++++++++++++ 3 files changed, 21 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..d998ce363335 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 bitcode file' + @echo ' (requires compiler support for LLVM bitcode 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' @@ -1648,6 +1650,10 @@ 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 $@) +%.ll: %.S 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..e5a28da2e6fa 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -177,6 +177,20 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +# LLVM bitcode +# Generate .ll files from .s and .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) + +quiet_cmd_as_ll_S = CPP $(quiet_modtag) $@ + cmd_as_ll_S = $(CPP) $(a_flags) -o $@ $< + +$(obj)/%.ll: $(src)/%.S FORCE + $(call if_changed_dep,as_ll_S) + # 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) -- 2.12.2.715.g7642488e1d-goog