How to get bitcode llvm after linking?
Asked Answered
T

2

6

I am trying to get LLVM IR for a file which is linked with some static libararies.

I tried to link using llvm-link . It just copy the .bc files in one file ( not like native linking).

clang -L$(T_LIB_PATH) -lpthread -emit-llvm gives an error: emit-llvm can not be used with linking. When passing -c option, it gives warning that the linking options were not used.

My main goal is to get .bc file with all resolved symbols and references. How can I achieve that with clang version 3.4.?

Treasury answered 12/10, 2020 at 22:17 Comment(0)
H
4

You may have a look at wllvm. It is a wrapper on the compiler, which enable to build a project and extract the LLVM bitcode of the whole program.

You need to use wllvm and wllvm++ for C and C++, respectively (after setting some environment variables).

Halfbeak answered 22/10, 2020 at 19:43 Comment(1)
you are a life save :)Treasury
W
-1

Some symbols come from source code via LLVM IR. IR is short for intermediate representation. Those symbols are easy to handle, just stop in the middle of the build process.

Some others come from a library and probably were generated by some other compiler, one that never makes any IR, and in any case the compiler was run by some other people at some other location. You can't go back in time and make those people build IR for you, even if their compiler has the right options. All you can do is obtain the source code for the libraries and build your entire application from source.

Whitcomb answered 13/10, 2020 at 9:5 Comment(1)
I have all the libraries source code and I can also not link . What should be done ?Treasury

© 2022 - 2024 — McMap. All rights reserved.