This is an archive of the discontinued LLVM Phabricator instance.

Create a Cross-Compilation CMake toolchain file for NonWindows -> Windows
ClosedPublic

Authored by zturner on Nov 8 2017, 12:41 PM.

Details

Summary

This allows building LLVM for windows on a non-Windows host, provided you have the proper headers and libraries on your system.

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Nov 8 2017, 12:41 PM
smeenai edited edge metadata.Nov 8 2017, 1:08 PM

Thanks for productionizing this! It'll be awesome to have it in-tree.

llvm/cmake/platforms/WinMsvc.cmake
13 ↗(On Diff #122144)

to a folder

29 ↗(On Diff #122144)

x64 is an MSVC 2017 thing; 2015 used amd64. I think it's perfectly fine to only care about 2017, but it's probably worth noting. (People using 2015 can just create a symlink or rename their folder or something.)

89 ↗(On Diff #122144)

I'd add an explanatory comment about why you need to do this seemingly weird thing.

90 ↗(On Diff #122144)

This is the nittiest of all nits, but it seems to be more common in LLVM's cmake to not have spaces after if, foreach, etc. I like having the space personally, but when in Rome ...

104 ↗(On Diff #122144)

I think a brief comment about why this is required would be useful.

121 ↗(On Diff #122144)

In general I prefer SEND_ERROR, so that all errors are output at once, whereas with FATAL_ERROR you have to whack them one at a time.

131 ↗(On Diff #122144)

Nit: this conditional should be moved up to where the MSVC_INCLUDE and MSVC_LIB variables are set, or those should be moved down here.

153 ↗(On Diff #122144)

Serus on IRC introduced me to the existence of -imsvc, which should be equivalent but is more concise.

The other big advantage of -imsvc is that we could make those directories be ordered after the resource dir (if they aren't already), which would save us from having to write out the resource dir manually. I think in general it's more correct for -imsvc to be ordered after the resource dir anyway.

167 ↗(On Diff #122144)

You can get rid of the "If you don't care about preserving ..." part, since if we're doing this in LLVM we definitely care.

zturner updated this revision to Diff 122274.Nov 9 2017, 10:55 AM

Updated with the suggestions. The -imsvc argument is nice, and allows us to get rid of manually specifying the resource directory, which was one of the FIXMEs I had before. So that is now fixed.

smeenai accepted this revision.Nov 9 2017, 12:25 PM

Awesome!

llvm/cmake/platforms/WinMsvc.cmake
7 ↗(On Diff #122274)

An even nittier nit: this line has quotes and none of the others do

10 ↗(On Diff #122274)

"wnindows sdk version folder name" might be clearer (otherwise "folder" could be the path). It's explained pretty clearly below as well though.

180 ↗(On Diff #122274)

Did you miss the comment about getting rid of the "If you don't care about preserving ..." part, or did you decide to keep it? Either way is fine; I just wanted to make sure the comment didn't go unnoticed.

This revision is now accepted and ready to land.Nov 9 2017, 12:25 PM
This revision was automatically updated to reflect the committed changes.