BACKPORT: kbuild: Add support to generate LLVM assembly files
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 Signed-off-by: Vinícius Tinti <viniciustinti@gmail.com> Signed-off-by: Behan Webster <behanw@converseincode.com> Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> (cherry picked from commit 433db3e260bc8134d4a46ddf20b3668937e12556) Signed-off-by: Greg Hackmann <ghackmann@google.com> Change-Id: I1fcc7ec14357e19e46cc2dd1772c5c258aec91d1
This commit is contained in:
parent
6602531121
commit
588ae6ad5f
3 changed files with 14 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,6 +33,7 @@
|
||||||
*.lzo
|
*.lzo
|
||||||
*.patch
|
*.patch
|
||||||
*.gcno
|
*.gcno
|
||||||
|
*.ll
|
||||||
modules.builtin
|
modules.builtin
|
||||||
Module.symvers
|
Module.symvers
|
||||||
*.dwo
|
*.dwo
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -1291,6 +1291,8 @@ help:
|
||||||
@echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
|
@echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
|
||||||
@echo ' dir/ - Build all files in dir and below'
|
@echo ' dir/ - Build all files in dir and below'
|
||||||
@echo ' dir/file.[ois] - Build specified target only'
|
@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 ' dir/file.lst - Build specified mixed source/assembly target only'
|
||||||
@echo ' (requires a recent binutils and recent build (System.map))'
|
@echo ' (requires a recent binutils and recent build (System.map))'
|
||||||
@echo ' dir/file.ko - Build module including final link'
|
@echo ' dir/file.ko - Build module including final link'
|
||||||
|
@ -1466,6 +1468,7 @@ clean: $(clean-dirs)
|
||||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
||||||
-o -name '*.symtypes' -o -name 'modules.order' \
|
-o -name '*.symtypes' -o -name 'modules.order' \
|
||||||
-o -name modules.builtin -o -name '.tmp_*.o.*' \
|
-o -name modules.builtin -o -name '.tmp_*.o.*' \
|
||||||
|
-o -name '*.ll' \
|
||||||
-o -name '*.gcno' \) -type f -print | xargs rm -f
|
-o -name '*.gcno' \) -type f -print | xargs rm -f
|
||||||
|
|
||||||
# Generate tags for editors
|
# Generate tags for editors
|
||||||
|
@ -1569,6 +1572,8 @@ endif
|
||||||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||||
%.symtypes: %.c prepare scripts FORCE
|
%.symtypes: %.c prepare scripts FORCE
|
||||||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||||
|
%.ll: %.c prepare scripts FORCE
|
||||||
|
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
/: prepare scripts FORCE
|
/: prepare scripts FORCE
|
||||||
|
|
|
@ -174,6 +174,14 @@ cmd_cc_symtypes_c = \
|
||||||
$(obj)/%.symtypes : $(src)/%.c FORCE
|
$(obj)/%.symtypes : $(src)/%.c FORCE
|
||||||
$(call cmd,cc_symtypes_c)
|
$(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
|
# C (.c) files
|
||||||
# The C file is compiled and updated dependency information is generated.
|
# The C file is compiled and updated dependency information is generated.
|
||||||
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
||||||
|
|
Loading…
Add table
Reference in a new issue