7

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 Answers1

12

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).

Kyle Lacy
  • 2,278
  • 1
  • 21
  • 29