All of lore.kernel.org
 help / color / mirror / Atom feed
* Adding new build target
@ 2019-06-07 16:58 Derrick McKee
  2019-06-07 17:20 ` Tom Roeder
  2019-06-18 15:03 ` Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Derrick McKee @ 2019-06-07 16:58 UTC (permalink / raw)
  To: linux-kbuild

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.

Derrick McKee

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding new build target
  2019-06-07 16:58 Adding new build target Derrick McKee
@ 2019-06-07 17:20 ` Tom Roeder
  2019-06-18 15:03 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Roeder @ 2019-06-07 17:20 UTC (permalink / raw)
  To: Derrick McKee; +Cc: linux-kbuild

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding new build target
  2019-06-07 16:58 Adding new build target Derrick McKee
  2019-06-07 17:20 ` Tom Roeder
@ 2019-06-18 15:03 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-06-18 15:03 UTC (permalink / raw)
  To: Derrick McKee; +Cc: Linux Kbuild mailing list

On Sat, Jun 8, 2019 at 1:58 AM Derrick McKee <derrick.mckee@gmail.com> 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.
>
> Derrick McKee

Commit 433db3e260bc supported a single target to
generate llvm bytecode,
but it is not used for the final vmlinux or modules.

For what reason,
do you need to generate llvm bytecode for every file?

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-18 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-07 16:58 Adding new build target Derrick McKee
2019-06-07 17:20 ` Tom Roeder
2019-06-18 15:03 ` Masahiro Yamada

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.