SRI-CSL / whole-program-llvm

A toolkit for building whole-program LLVM bitcode files
MIT License
72 stars 11 forks source link

about compiling bitcode to executable #5

Closed bcko closed 9 years ago

bcko commented 9 years ago

Hello, @ianamason

I was able to create httpd.bc by following your instruction. However I ran into some problem in the process of making an executable from bitcode. I was wondering 1. what is going on 2. if wllvm has a feature that can do what I want to do.

My goal is to run some customized optimization on httpd.bc and then create httpd.s by using llc httpd.bc After I have httpd.s, I make some changes on assembly file and then create executable.

when I run clang httpd.s I get many errors saying

"undefined reference to 'apu_version" "undefined reference to 'aprbucket...'" clang: error: linker command failed with exit code 1

what is actually happening? am I supposed to link something in order to create final executable? does whole-program-llvm has a feature that allows you to compile from bitcode into executable?

I really appreciate your help!

ianamason commented 9 years ago

bcko,

wllvm is really just a lightweight tool for helping you produce bitcode.

What you do with the bitcode after that is really up to you. But wllvm isn't going to help much.

For example if you want to eventually get back to executables, you'll need to either link it with the native libraries, or else produce bitcode versions of the libraries and link against them.

These

"undefined reference to 'apu_version" "undefined reference to 'aprbucket...'"

means that you will need to link against the apr and apr-util libraries.

Hope that helps.

bcko commented 9 years ago

hello ianmason,

now I know what my problem is which is finding a way to link libraries. I am more hopeful now that I know what the issue is. I really appreciate your work on wllvm and your advices! I would not even have gotten to bitcode stage and know what I am supposed to do without your help. I downloaded freeBSD DVD1.iso and am stuck on how to actually install and get to ports. once I figure out how to do that I will leave some feedbacks about your readme-freeBSD.md

Thank you so much!

p.s one last question. in order to find what I need to link, is makefile a good place to look into? do you think reading about automake, libtool would help me to understand finding out what needs to be linked?

ianamason commented 9 years ago

try deleteing the executable httpd and then typing make again. should get a line that will give you hints.