Generate LLVM IR for httpd

六月ゝ 毕业季﹏ 提交于 2019-12-24 12:21:42

问题


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?


回答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.



来源:https://stackoverflow.com/questions/30401450/generate-llvm-ir-for-httpd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!