Mantas
Mantas

Reputation: 1223

LLVM + gRPC compilation

I am creating an LLVM pass which creates some calls to functions.

Right now, I was able to do this with external file (functions.c), which contains the functions to be called.

The structure:

This is the process I'm doing now:

clang -S -emit-llvm *.c   // compile
llvm-link -S -v -o single.ll *.ll    // link to single file
opt -load build/skeleton/libSkeletonPass.so -skeletonpass single.ll -o optimised.ll     // run the pass
llc optimised.ll     // create an executable
clang optimised.s

Now, I want to change these functions.c file with gRPC methods to call methods on Bigtable. I looked into some examples (Hello World, Route Guide) and saw that the compilation and linking is done through makefiles.

EDITED:

I am using Bigtable example code and just want to adjust the existing CMakeLists.txt to do the commands above. In other words, I want to compile and link "all the Google code" and produce a single .ll file which I could run through LLVM pass.

I set

export CXX=/usr/bin/clang++ 

and added

set(CMAKE_CXX_OUTPUT_EXTENSION ".bc") 
set(CMAKE_CXX_FLAGS "-S -emit-llvm") 

options to CMakeLists.txt but it didn't produce .bc files.

Upvotes: 0

Views: 451

Answers (2)

alexoneill
alexoneill

Reputation: 538

You may have more luck talking to Bigtable using the Bigtable C++ client, since it is now GA (generally available) and fully-featured.

In particular, you may want to look at the CMakeLists.txt file there, it could have hints on the correct LLVM flags to include in your compilation.

Upvotes: 1

compor
compor

Reputation: 2339

I know of 2 alternatives:

  • use whole-program-llvm if you're using Make files and you want to extract bitcode archives, etc.

  • use llvm-ir-cmake-utils if you want to do something similar with CMake; you'll have to adjust/augment your CMakeLists.txt with the offered calls (there are examples in this repo).

Upvotes: 0

Related Questions