linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vinícius Tinti" <viniciustinti@gmail.com>
To: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Vinícius Tinti" <viniciustinti@gmail.com>,
	"Behan Webster" <behanw@converseincode.com>
Subject: [PATCH] kbuild: add support to generate LLVM bitcode files
Date: Fri, 18 Jul 2014 22:34:37 -0300	[thread overview]
Message-ID: <1405733677-16650-1-git-send-email-viniciustinti@gmail.com> (raw)

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


             reply	other threads:[~2014-07-19  1:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-19  1:34 Vinícius Tinti [this message]
2014-07-20 10:02 ` [PATCH] kbuild: add support to generate LLVM bitcode files 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             ` [PATCH v3] " Vinícius Tinti

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=1405733677-16650-1-git-send-email-viniciustinti@gmail.com \
    --to=viniciustinti@gmail.com \
    --cc=behanw@converseincode.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).