Current state of compiling for Windows on Linux (with libc++ too)?

I know there's been a lot of exciting work on getting clang to run on Windows, and (I think) work to make clang-on-Linux produce Windows binaries, but I'm not entirely sure what the current status is. I'm not terribly concerned about mimicking MSVC bugs, but it would be nice to compile some of my C++14 projects for Windows (preferably using libc++, since that's the only C++14-compliant standard lib I know of at the moment).

Is there a good place to keep track of this work? I'd be happy to help out as well, if there are any smallish tasks that need doing.

- Jim

I have not personally been focusing on this, but I know that Saleem has been doing this.

If you have a simple command line app that links against no external Windows libraries, using the mingw toolchain is the path most travelled and is probably the way to go. Just replace gcc with Clang and use --target=x86_64-pc-mingw32, or whatever is more appropriate (–target=x86_64-w64-windows-gnu). Otherwise, read on.

Fundamentally, to produce Windows executables, you generally want headers and libraries from a few places

  • The Windows SDK, which has <windows.h> and kernel32.lib so you can use system calls
  • The CRT, which has <stdio.h>, <stdlib.h>, etc. Typically people use the MSVC CRT to be C ABI compatible with other libs.
  • The C++ standar library, which has , , etc. You can use libc++ MSVC’s.

Once you have these, you will need to pass the appropriate -I and -L flags to find the headers and libs. You also need a PE-COFF linker, which can be either lld or binutils ld.bfd. I don’t know how to set this up yet.

I know there's been a lot of exciting work on getting clang to run on
Windows, and (I think) work to make clang-on-Linux produce Windows
binaries, but I'm not entirely sure what the current status is. I'm not
terribly concerned about mimicking MSVC bugs, but it would be nice to
compile some of my C++14 projects for Windows (preferably using libc++,
since that's the only C++14-compliant standard lib I know of at the moment).

How do you intend to build libc++? Do you intend to build it against MSVC
as the C library? This is certainly possible, but this isn't fully
complete yet. Getting this work completed would be a great place to
start. I would recommend that if you were to go down this route, you use
the latest SDK and Visual Studio (for MSVC). They have added many missing
pieces which are needed.

Assuming that you are fine with creating a custom environment for building,
the i686-windows-itanium target assumes that you have a Linux like sysroot
setup with the C library headers in /usr/include and an appropriately named
bfd linker in /usr/bin.

Is there a good place to keep track of this work? I'd be happy to help out
as well, if there are any smallish tasks that need doing.

There is an outstanding patch to support case insensitivity on case
sensitive file systems that Ive not had the time to give attention to.

Another aspect which matters is what architecture are you looking at?