[libcxx-dev] libcxx to llvm ir
Reid Kleckner via libcxx-dev
libcxx-dev at lists.llvm.org
Thu Mar 28 11:16:06 PDT 2019
clang-cl doesn't expose a way to get LLVM IR, but there are a couple of
different ways to do what you want.
First, you can just use the clang driver, as long as you set the triple
right, and set up the include search paths correctly. Mainly this means
adding '-isystem' flags for everything in the INCLUDE environment variable
in a standard Visual C++ development environment. If you need to link, then
you need LIB and LIBPATH as well.
Next, you can use the "-clang:" prefix on any GCC-style driver option to
use it with clang-cl. I haven't tried, but maybe -clang:-S
-clang:-emit-llvm will do the right thing.
If that doesn't work, I do know that you can use -Fa to emit assembly as
you would with MSVC, and then pass `-Xclang -emit-llvm` to make that
assembly actually LLVM IR. The invocation would be `clang-cl foo.cpp
-Fafoo.ll -Xclang -emit-llvm`.
If that doesn't work, you could enable LTO (-flto) and llvm-dis the object
After rereading your question, I think maybe the best way forward for you
would be to configure libc++'s build to use clang-cl, and then enable LTO.
I believe our cmake scripts support the clang-cl driver better than the
clang driver on Windows.
Hopefully one of those approaches works. :)
On Thu, Mar 28, 2019 at 10:43 AM Duncan Exon Smith <dexonsmith at apple.com>
> Clang is the right tool for this. I don't know the command-line options
> for `clang-cl`, but on `clang` invocations you would do this by using "-S
> -emit-llvm" instead of "-c".
> +Reid, I assume there is an equivalent?
> > On 2019 Mar 27, at 18:34, Emmanuel Thivierge via libcxx-dev <
> libcxx-dev at lists.llvm.org> wrote:
> > Hi all,
> > I am playing with llvm orc jit and I would like to be able to use the
> STL. So I am trying to find a way to compile libcxx to llvm ir.
> > Anybody had any success and have some pointers on how to do it? So far I
> tried to figure out a way to configure cmake to make it happen.
> > I am on windows and so I fear that clang-cl might not be able to do
> this. In any case, I would appreciate any pointers.
> > Thanks a lot
> > Emmanuel
> > _______________________________________________
> > libcxx-dev mailing list
> > libcxx-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the libcxx-dev