1

I am trying to compile apache2 with LLVM, to generate final binaries in LLVM IR.

I used flto option in compiling and linking and passed "also-emit-llvm" to the linker through clang. It seems to work for most steps, however I had two concerns

1) Earlier I used LLVM 3.6, whose gold plugin doesn't accept also-emit-llvm, but has emit-llvm only, basically it will emit only elf or llvm. Which the Autotools build system doesn't like. The configure and make script want binaries, while I want llvm. Any solutions to this?

2) So I shifted to LLVM 3.5.2, the build process goes well, I can generate both httpd.bc and httpd elf binaries, but the linker doesn't want to link for modules (it was able to link for binaries) Specifically, I get this error

`

/usr/share/apr-1.0/build/libtool --silent --mode=link /home/rbhatia/Desktop/llvm-newbuild/bin/clang  -pthread  -flto -o mod_authn_file.la -rpath /home/rbhatia/Desktop/httpd-2.4.12/llvm/modules -module -avoid-version  mod_authn_file.lo 
/usr/bin/ld: error: .libs/mod_authn_file.o:1:3: invalid chaenter code hereracter
/usr/bin/ld: error: .libs/mod_authn_file.o:1:3: syntax error, unexpected $end
/usr/bin/ld: error: .libs/mod_authn_file.o: not an object or archive
collect2: error: ld returned 1 exit status

`

I can see that mod_authn_file.o is a valid LLVM IR file which I can disassemble with llvm-dis. Also, just before this step, the linker is able to link httpd and httpd.bc

Any help on what the error is?

  • So, I experimented a bit. And it turns out replacing mod_authn_file.la file with mod_authn_file.a makes the command work. Can anybody explain why llvm can't create .la files in LLVM bitcode? And is there a workaround for that? – user1489092 May 22 '15 at 19:40

1 Answers1

1

Take a look at

https://github.com/SRI-CSL/whole-program-llvm

we use this tool to build quite large projects into bitcode. Our biggest so far was FreeBSD 10.0, so size is not usually an issue.

Our travis build check is actually apache, as is our tutorial. Hope that helps.

Ian A. Mason
  • 207
  • 3
  • 8