clang newbie queries

Hi

I am considering using clang/LLVM for C++.

1) From the wiki docs, I read that clang is a frontend for the C++ compiler (amongst others) in LLVM which is the backend. However, I find that after installing the "clang for LLVM" binary on Windows, that there is no frontend. Can anyone clarify how I can get the frontend? Do I need to build the clang source for this?

2) I understand that clang compiles to bitcode. How can I compile directly to binary (exe) format?

Thanks
Steven
1. IIRC there's a clang.exe in the installation directory. That's the front-end (and the back-end as well, presumably).

2. Clang itself compiles to an intermediate representation that it passes to LLVM. LLVM uses the IR to perform optimizations and generate object code, which will be later be passed to a linker, which will generate the final executable.
Thanks for the clarification.

Can the clang intermediate representation be decompiled, so as to expose the source?

How can the final binaries be generated either directly from the source (bypassing the IR) or from the IR itself, so that the exes might be directly run without requiring LLVM/clang on the machine?

Thanks
Steven
Can the clang intermediate representation be decompiled, so as to expose the source?
The intermediate representation normally only exists in memory for the duration of the compilation process.

How can the final binaries be generated either directly from the source (bypassing the IR) or from the IR itself, so that the exes might be directly run without requiring LLVM/clang on the machine?
This is how Clang works. Despite its name, LLVM is not a virtual machine like the JVM is. As used by Clang, the LLVM works primarily as a second optimizer pass and as a machine code generator.
In other words, Clang works just like any other traditional C/++ compiler. Even the IR step is not unique to Clang. GCC also has an IR step, and I think any compiler structured as a front-end/back-end pair needs one.
Topic archived. No new replies allowed.