[PATCH v3] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files using '.ll' suffix. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster --- .gitignore | 1 + Makefile | 6 ++ scripts/Makefile.build | 14 ++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index e213b27..823b9d6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers *.dwo diff --git a/Makefile b/Makefile index 1a60bdd..cd4a120 100644 --- a/Makefile +++ b/Makefile @@ -1250,6 +1250,8 @@ help: @echo '(default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/- Build all files in dir and below' @echo ' dir/file.[oisS] - 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' @@ -1526,6 +1528,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 bf3e677..4d97e4f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,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.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files using '.ll' suffix. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll Signed-off-by: Vinícius Tinti viniciusti...@gmail.com Signed-off-by: Behan Webster beh...@converseincode.com --- .gitignore | 1 + Makefile | 6 ++ scripts/Makefile.build | 14 ++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index e213b27..823b9d6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers *.dwo diff --git a/Makefile b/Makefile index 1a60bdd..cd4a120 100644 --- a/Makefile +++ b/Makefile @@ -1250,6 +1250,8 @@ help: @echo '(default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/- Build all files in dir and below' @echo ' dir/file.[oisS] - 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' @@ -1526,6 +1528,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 bf3e677..4d97e4f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,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.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files with the .ll extension. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster --- .gitignore | 1 + Makefile | 6 ++ scripts/Makefile.build | 14 ++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index f4c0b09..c5a7656 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers diff --git a/Makefile b/Makefile index 6b27741..7826c33 100644 --- a/Makefile +++ b/Makefile @@ -1213,6 +1213,8 @@ help: @echo '(default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/- Build all files in dir and below' @echo ' dir/file.[oisS] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM bitcode file' + @echo '(requires a 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' @@ -1483,6 +1485,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 bf3e677..4d97e4f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,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.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files with the .ll extension. # from c code CC=clang make kernel/pid.ll # from asm code CC=clang make arch/x86/kernel/preempt.ll Signed-off-by: Vinícius Tinti viniciusti...@gmail.com Signed-off-by: Behan Webster beh...@converseincode.com --- .gitignore | 1 + Makefile | 6 ++ scripts/Makefile.build | 14 ++ 3 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index f4c0b09..c5a7656 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.lzo *.patch *.gcno +*.ll modules.builtin Module.symvers diff --git a/Makefile b/Makefile index 6b27741..7826c33 100644 --- a/Makefile +++ b/Makefile @@ -1213,6 +1213,8 @@ help: @echo '(default: $$(INSTALL_MOD_PATH)/lib/firmware)' @echo ' dir/- Build all files in dir and below' @echo ' dir/file.[oisS] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM bitcode file' + @echo '(requires a 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' @@ -1483,6 +1485,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 bf3e677..4d97e4f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,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.0.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files with the .ll extension when building with Clang. # c code CC=clang make kernel/pid.ll # asm code CC=clang make arch/arm/kernel/calls.ll Signed-off-by: Vinícius Tinti Signed-off-by: Behan Webster --- Makefile | 7 +++ scripts/Makefile.build | 18 ++ 2 files changed, 25 insertions(+) diff --git a/Makefile b/Makefile index f3c543d..4eb0d14 100644 --- a/Makefile +++ b/Makefile @@ -1484,6 +1484,13 @@ endif %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +ifeq ($(COMPILER),clang) +%.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 $@) +endif + # Modules /: prepare scripts FORCE $(cmd_crmodverdir) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bf3e677..9ea19d6 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,14 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +ifeq ($(COMPILER),clang) +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ +cmd_cc_ll_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -emit-llvm -S -o $@ $< + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) +endif + # 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) @@ -315,6 +323,16 @@ quiet_cmd_asn1_compiler = ASN.1 $@ $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler $(call cmd,asn1_compiler) +# LLVM bitcode +# --- +ifeq ($(COMPILER),clang) +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) +endif + # Build the compiled-in targets # --- -- 2.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kbuild: add support to generate LLVM bitcode files
Allows kbuild to generate LLVM bitcode files with the .ll extension when building with Clang. # c code CC=clang make kernel/pid.ll # asm code CC=clang make arch/arm/kernel/calls.ll Signed-off-by: Vinícius Tinti viniciusti...@gmail.com Signed-off-by: Behan Webster beh...@converseincode.com --- Makefile | 7 +++ scripts/Makefile.build | 18 ++ 2 files changed, 25 insertions(+) diff --git a/Makefile b/Makefile index f3c543d..4eb0d14 100644 --- a/Makefile +++ b/Makefile @@ -1484,6 +1484,13 @@ endif %.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) +ifeq ($(COMPILER),clang) +%.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 $@) +endif + # Modules /: prepare scripts FORCE $(cmd_crmodverdir) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index bf3e677..9ea19d6 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -174,6 +174,14 @@ cmd_cc_symtypes_c = \ $(obj)/%.symtypes : $(src)/%.c FORCE $(call cmd,cc_symtypes_c) +ifeq ($(COMPILER),clang) +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ +cmd_cc_ll_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -emit-llvm -S -o $@ $ + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) +endif + # 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) @@ -315,6 +323,16 @@ quiet_cmd_asn1_compiler = ASN.1 $@ $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler $(call cmd,asn1_compiler) +# LLVM bitcode +# --- +ifeq ($(COMPILER),clang) +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) +endif + # Build the compiled-in targets # --- -- 2.0.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/