Jason Thomas via llvm-dev
2019-Oct-10 09:39 UTC
[llvm-dev] Is it possible to generate a whole kernel bitcode for Linux using clang?
Hello, With clang/llvm 9.0 adding support for ASM GOTOs, it is now possible to compile the latest Linux kernel with clang without any modification. However, is it possible to generate a single bitcode for the whole Linux kernel? Earlier approaches would involve hacks, like compiling separate bitcode files and then linking with llvm-link, or using wllvm, or using some other wrapper. Frequently, the resulting bitcode was not functional due to different parts being missing. Did that situation change at all? Can we generate a function, monolithic, self-contained bitcode using something like libLTO? Any help would be appreciated. -- JT -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191010/165642d9/attachment.html>
Tim Northover via llvm-dev
2019-Oct-10 09:54 UTC
[llvm-dev] Is it possible to generate a whole kernel bitcode for Linux using clang?
Hi Jason, On Thu, 10 Oct 2019 at 10:39, Jason Thomas via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Frequently, the resulting bitcode was not functional due to different parts being missing. Did that situation change at all? Can we generate a function, monolithic, self-contained bitcode using something like libLTO? Any help would be appreciated.You can get the linker to emit the last bitcode that exists (e.g. via --plugin-opt save-temps or emit-llvm I think), but it still won't be self contained for something like a kernel. There's no representation in IR for objects that come from .s files or the linker script for a start. Cheers. Tim.
Jason Thomas via llvm-dev
2019-Oct-10 15:23 UTC
[llvm-dev] Is it possible to generate a whole kernel bitcode for Linux using clang?
Hi Tim, Now I understand why it can't be a self-contained IR. However, just to emit the bitcode of individual files, I tried compiling with make CC=clang HOSTCC=clang CFLAGS=" -g -flto -std=gnu99 " LDFLAGS=" -flto -fuse-ld=gold -Wl,-plugin-opt=save-temps" menuconfig make CC=clang HOSTCC=clang CFLAGS=" -g -flto -std=gnu99 " LDFLAGS=" -flto -fuse-ld=gold -Wl,-plugin-opt=save-temps" -j8 The compilation with clang is still going on. But, it doesn't look like it generates the IR at all. Whatever *.o files the build is producing are native ELF files. On Thu, 10 Oct 2019 at 02:54, Tim Northover <t.p.northover at gmail.com> wrote:> Hi Jason, > > On Thu, 10 Oct 2019 at 10:39, Jason Thomas via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Frequently, the resulting bitcode was not functional due to different > parts being missing. Did that situation change at all? Can we generate a > function, monolithic, self-contained bitcode using something like libLTO? > Any help would be appreciated. > > You can get the linker to emit the last bitcode that exists (e.g. via > --plugin-opt save-temps or emit-llvm I think), but it still won't be > self contained for something like a kernel. There's no representation > in IR for objects that come from .s files or the linker script for a > start. > > Cheers. > > Tim. >-- JT -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191010/5abd97ad/attachment.html>