All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Roeder <tmroeder@google.com>
To: Derrick McKee <derrick.mckee@gmail.com>
Cc: linux-kbuild@vger.kernel.org
Subject: Re: Adding new build target
Date: Fri, 7 Jun 2019 10:20:15 -0700	[thread overview]
Message-ID: <20190607172015.GA165542@google.com> (raw)
In-Reply-To: <CAJoBWHw2yPgT_25UVF_3tTx6_FfZMBbDqVW5TASb4aPu2JKHZg@mail.gmail.com>

On Fri, Jun 07, 2019 at 12:58:33PM -0400, Derrick McKee wrote:
> Hi all,
> 
> Now that the kernel can be built with clang, I'd like to implement a
> new build target to generate LLVM bytecode for all C source files
> involved for a specific build configuration.  I am thinking that this
> should be very simple if I know the make variables that captures the
> needed information.  Specifically, I think I just need to perform the
> following command for all C files:
> 
> clang -emit-llvm -c <appropriate CFLAGS and include paths> <source
> file> -o <corresponding object file location>.bc
> 
> My problem is that I don't know how to get the info in the brackets,
> but I am thinking that I should make a new build target `bytecode`.
> Any help would be appreciated.  Thanks.

I know this isn't exactly what you're asking for, but one way to get
kernel object files as bitcode is to add -save-temps=obj to KCFLAGS.
That gives you bitcode for each object file, and you can pull them
together into a single object using llvm-link.

Note that at least when I was experimenting with this, I also needed to
turn off some warnings, because setting -save-temps=obj changes the way
that clang builds the objects. In particular, I needed to set

	-Wno-constant-logical-operand
	-Wno-parentheses-equality
	-Wno-pointer-bool-conversion
	-Wno-self-assign

> 
> Derrick McKee

  reply	other threads:[~2019-06-07 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 16:58 Adding new build target Derrick McKee
2019-06-07 17:20 ` Tom Roeder [this message]
2019-06-18 15:03 ` 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=20190607172015.GA165542@google.com \
    --to=tmroeder@google.com \
    --cc=derrick.mckee@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    /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.