All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vinícius Tinti" <viniciustinti@gmail.com>
To: Michal Marek <mmarek@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Behan Webster <behanw@converseincode.com>,
	Zhao Gang <gamerh2o@gmail.com>, Borislav Petkov <bp@suse.de>,
	Andi Kleen <ak@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	"Vinícius Tinti" <viniciustinti@gmail.com>
Subject: [PATCH v3] kbuild: add support to generate LLVM bitcode files
Date: Thu, 11 Sep 2014 20:13:00 -0300	[thread overview]
Message-ID: <1410477180-1328-1-git-send-email-viniciustinti@gmail.com> (raw)
In-Reply-To: <CALD9WKzGmCeCPdwO4hCMtAjEjFoB8=oiQjUktT4PN4ewtDY7XA@mail.gmail.com>

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 <viniciustinti@gmail.com>
Signed-off-by: Behan Webster <behanw@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


  reply	other threads:[~2014-09-11 23:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-19  1:34 [PATCH] kbuild: add support to generate LLVM bitcode files Vinícius Tinti
2014-07-20 10:02 ` Sam Ravnborg
2014-07-20 21:04   ` Sam Ravnborg
2014-07-20 21:30     ` Sam Ravnborg
2014-07-21 22:42       ` Tinti
2014-07-22  0:35         ` Sam Ravnborg
2014-07-23 11:56         ` [PATCH v2] " Vinícius Tinti
2014-07-23 12:00           ` Tinti
2014-09-11 23:13             ` Vinícius Tinti [this message]
2017-04-04 17:27 [PATCH v3] kbuild: Add " Matthias Kaehlcke
2017-04-20 18:04 ` Matthias Kaehlcke
2017-04-21  5:02 ` Masahiro Yamada
2017-04-21 19:55   ` Matthias Kaehlcke
2017-04-23  6:57     ` Masahiro Yamada
2017-04-24  2:21     ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410477180-1328-1-git-send-email-viniciustinti@gmail.com \
    --to=viniciustinti@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=behanw@converseincode.com \
    --cc=bp@suse.de \
    --cc=gamerh2o@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.