5
votes

Clang can accept source files through a pipe if a language is specified with the -x flag.

cat hello_world.c | clang -x c -o hello_world

Clang can also compile LLVM IR and bitcode to object files

clang hello_world.c -S -emit-llvm && clang -o hello_world hello_world.ll

I want to compile LLVM IR or bitcode passed via a pipe. However, I can't find any documentation on exactly what parameters the -x option accepts. I can use c, c++, but clang doesn't recognize llvm or bitcode.

What can I give to -x so Clang will accept IR or bitcode?

1

1 Answers

11
votes

The language flag you're looking for is ir. For example:

clang hello_world.c -S -emit-llvm -o - | clang -x ir -o hello_world -

works for me (clang version 3.5, trunk 200156).