<div dir="ltr">clang-cl doesn't expose a way to get LLVM IR, but there are a couple of different ways to do what you want.<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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`.</div><div><br></div><div>If that doesn't work, you could enable LTO (-flto) and llvm-dis the object files.</div><div><br></div><div>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.</div><div><br></div><div>Hopefully one of those approaches works. :)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 28, 2019 at 10:43 AM Duncan Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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".<br>
<br>
+Reid, I assume there is an equivalent?<br>
<br>
> On 2019 Mar  27, at 18:34, Emmanuel Thivierge via libcxx-dev <<a href="mailto:libcxx-dev@lists.llvm.org" target="_blank">libcxx-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> Hi all,<br>
> <br>
> 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.<br>
> 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. <br>
> 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.<br>
> <br>
> <br>
> Thanks a lot<br>
> Emmanuel<br>
> _______________________________________________<br>
> libcxx-dev mailing list<br>
> <a href="mailto:libcxx-dev@lists.llvm.org" target="_blank">libcxx-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev</a><br>
<br>
</blockquote></div>