Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC support tracking issue #12056

Closed
5 tasks
tkelman opened this issue Jul 8, 2015 · 55 comments
Closed
5 tasks

MSVC support tracking issue #12056

tkelman opened this issue Jul 8, 2015 · 55 comments
Labels
system:windows Affects only Windows

Comments

@tkelman
Copy link
Contributor

tkelman commented Jul 8, 2015

@kshyatt asked me to write down the current state of affairs w.r.t. building Julia using MSVC. Building master as of fdee9f4 works with VS 2013 after applying msvc-bootstrap.patch and msvc-sysimg4.patch
(or msvc-sysimg3.patch for release-0.4) using the following hacky build process that I'm not proud of, copied from the first post in #7761:

  • start a command prompt, cd "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
  • vcvarsall x86_amd64
  • cd to your MSYS installation, whichever folder sh.exe is located in (either bin or usr/bin depending whether you're using MSYS1 or a recent MSYS2 - best to use msysgit here, otherwise you'll likely get an error message due to the MSYS version of link.exe showing up first in the path, and MSYS2 has been reported not to work here)
  • set MSYSTEM=MINGW32
  • sh --login
  • cd to your Julia directory, checkout latest master (if you have an existing mingw build here, best to start from a separate clean clone)
  • make sure msys can find 7z on the path
  • ARCH=x86_64 USEMSVC=1 contrib/windows/msys_build.sh

The build process would eventually get better if we port the build system to cmake as an alternative option to GNU make, see #11754. My hacky script downloads a Julia nightly binary, which is itself compiled on our buildbots via the Cygwin cross-compilation process as documented in README.windows.md, and extracts out the MinGW-w64-built dependency dll's from it. It also downloads an MSVC 2013 binary build of LLVM 3.3 that I made some time ago.

The first patch is necessary because MSVC does not have some 128-bit integer intrinsics that are needed for Int128 support in Julia. In versions of LLVM newer than 3.3, we may be able to get those intrinsics from the compiler-rt library in LLVM. I have not managed a build of that yet myself though. The second patch is necessary to work around the lack of a comdat section in the system image object file - with LLVM 3.5 or newer that should not be necessary, we could use the MSVC linker for sys.dll with a different patch that could be merged to master.

If you can reproduce my steps above, then a failure to compile libccalltest is expected because MSVC does not support C99 complex https://connect.microsoft.com/VisualStudio/feedback/details/891891/c99-complex-number-support. The resulting MSVC-built Julia executable needs to be run as usr/bin/julia -J usr/lib/julia/sys.ji for now due to the sysimg patch.

Aside from documenting the above in a central place, the purpose of this issue is to track remaining items before we could call MSVC (and even expand to ICC + ifort on Windows) a first-class supported build platform and document it as an alternative to MinGW-w64.

Anything else I forgot? Success or failure stories are welcome if anyone wants to test this. Trying out VS 2015 and/or LLVM 3.7 or svn and determining what patches would be required to make those work would also be worth doing if anyone wants to help get this to a more usable state.

@tkelman tkelman added the system:windows Affects only Windows label Jul 8, 2015
@ViralBShah
Copy link
Member

I don't think blis and flame are realistic, given that every arch has good blas and lapack libraries. We could however just use the CBLAS interface and LAPACKe.

@ViralBShah
Copy link
Member

Perhaps explore blis and flame in a package to see how they compare?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 8, 2015

at least two of those failures appear to be related to running an unpatched version of llvm (https://github.com/JuliaLang/julia/blob/master/deps/instcombine-llvm-3.3.patch and https://github.com/JuliaLang/julia/blob/master/deps/int128-vector.llvm-3.3.patch) or the corresponding disables in codegen.cpp (set if USE_SYSTEM_LLVM is set)

the EXCEPTION_ACCESS_VIOLATION at 0x0 messages almost always mean that llvm tried to call a compiler-rt or libm function that is not supplied by msvc.

@tkelman
Copy link
Contributor Author

tkelman commented Jul 8, 2015

I don't think blis and flame are realistic, given that every arch has good blas and lapack libraries. We could however just use the CBLAS interface and LAPACKe.

At this time you're right, with the exception that MSVC is not able to compile those good blas and lapack libraries. I did make a package to try out BLIS (mostly just copy-pasting base/linalg/blas.jl with a few small tweaks) and last I checked it isn't really portable yet. The intent here is more long-term, to eventually address the fact that BLIS and FLAME are the most likely optimized BLAS and LAPACK implementations to ever be possible to compile with MSVC. This isn't Julia's problem to fix as much as it is Microsoft's if they ever want their compiler to be usable by the scientific computing community, but this should be written down explicitly.

at least two of those failures appear to be related to running an unpatched version of llvm

I may have done the MSVC build of LLVM prior to those patches. It takes a long time to build and I'm never quite sure what cmake arguments should be used so I haven't done it again.

@joa-quim
Copy link

joa-quim commented Aug 9, 2015

Tried to build but

make -C support BUILDDIR='/V/julia/src/support'
make[2]: Entering directory '/V/julia/src/support'
cl : Command line warning D9002 : ignoring unknown option '-dumpmachine'
cl : Command line error D8003 : missing source filename
 /V/julia/deps/libuv/compile cl -nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502   -I/V/julia/usr/include -I/V/julia/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c hashing.c -o /V/julia/src/support/hashing.o
hashing.c
V:\julia\src\support\hashing.c : fatal error C1083: Cannot open compiler generated file: 'V:C:/MinGW64/msys64/julia/src/support/hashing.o': Invalid argument

The real issue must come from the missing source filename because the /V/julia/src/support/hashing.o is not created

@xianyi
Copy link

xianyi commented Aug 9, 2015

I am working on using cmake for OpenBLAS on Visual Studio. Because of different assembly syntax (AT&T vs Intel), I can only support pure C kernels on Visual Studio.

@tkelman
Copy link
Contributor Author

tkelman commented Aug 9, 2015

Good to know @xianyi, it's a start anyway. Either in OpenBLAS or in BLIS, I hope someone who's heavily invested in being able to build using MSVC comes along and is able to support that effort. There might be automated ways of translating the assembly syntax, but would still need to be carefully validated.

@joa-quim I suspect the problem is related to mount points and the MSYS2 path mangling, 'V:C:/MinGW64/msys64/julia/src/support/hashing.o' looks like the cause of the issue. Instead of running this from /V/julia/, try running from /C/MinGW64/msys64/julia/.

@joa-quim
Copy link

joa-quim commented Aug 9, 2015

Hmm, V:/ is a RAM disk where I do all my buildings (including the MSVC some months ago)

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 9, 2015

make -C support BUILDDIR='/V/julia/src/support'

I believe the cygwin and msys2 syntax is /cygdrive/V/, not /V/ (which was a msys1 invention). Which shell are you using? It looks like the deps/libuv/compile wrapper script is having trouble with that path.

@tkelman
Copy link
Contributor Author

tkelman commented Aug 9, 2015

MSYS2 does not use the /cygdrive/ prefix, it follows the MSYS1 convention but via a different mount mechanism.

@joa-quim
Copy link

As a test I built julia from scratch with mingw in V: so this path issue is a MSVC building issue only.

@tkelman Do you build yours under /C/MinGW/msys64/julia/?

@joa-quim
Copy link

Also tried by setting a symbolic link in C: but same type of error

make -C support BUILDDIR='/c/jul/src/support'
make[2]: Entering directory '/c/jul/src/support'
cl : Command line warning D9002 : ignoring unknown option '-dumpmachine'
cl : Command line error D8003 : missing source filename
 /c/jul/deps/libuv/compile cl -nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502   -I/c/jul/usr/include -I/c/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c hashing.c -o /c/jul/src/support/hashing.o
hashing.c
C:\jul\src\support\hashing.c : fatal error C1083: Cannot open compiler generated file: 'C:C:/MinGW64/msys64/jul/src/support/hashing.o': Invalid argument
Makefile:43: recipe for target '/c/jul/src/support/hashing.o' failed

Don't get it why the .o is not created

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

can you add VERBOSE=1 and retry. it looks like something is going wrong with the msys path mangling and argument translation (http:https://www.mingw.org/wiki/Posix_path_conversion), but it's hard to know without seeing the command that is getting called.

@joa-quim
Copy link

The msys_build.sh already has VERBOSE=1. I even tried to set it to 2 but no more info is printed.
I think the problem comes the deps/libuv/compile script. If I remove it from CC in Make.user

override CC = /c/jul/deps/libuv/compile cl -nologo -MD -Z7

than it advances more but because it will create .obj instead of .o it later fails trying to link to the non-existent *.o

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

One other debug option then is to edit the compile (in deps/libuv) script as follows, and then change cl to cmd //c echo in the override CC. this will help increase the verbosity to show what args are actually getting to the cl program (although the compile will of course still fail, since this'll replace the compiler with echo):

diff --git a/compile b/compile
index 531136b..cb95b37 100755
--- a/compile
+++ b/compile
@@ -255,7 +255,7 @@ EOF
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cmd | echo | cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac

@joa-quim
Copy link

I am sorry but neither that makes it talk more

make -C support BUILDDIR='/c/jul/src/support'
make[2]: Entering directory '/c/jul/src/support'
cl : Command line warning D9002 : ignoring unknown option '-dumpmachine'
cl : Command line error D8003 : missing source filename
 /c/jul/deps/libuv/compile cl -nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502   -I/c/jul/usr/include -I/c/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c hashing.c -o /c/jul/src/support/hashing.o

Why is it complaining of a missing source filename?

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

you also need to redirect the CC in your Make.user script to point at cmd //c echo

@joa-quim
Copy link

Ah, better

    CC src/support/_setjmp.win64.o
Microsoft (R) Macro Assembler (x64) Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: _setjmp.win64.i
MASM : fatal error A1000:cannot open file : _setjmp.win64.i
Makefile:53: recipe for target '/c/jul/src/support/_setjmp.win64.o' failed

and indeed I don't have that file, only a _setjmp.win64.S

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

it looks like VERBOSE=1 got lost there. it would also be helpful if you could include a bit more of the output than just the last error (since we've replaced the compiler with echo, the output files like .i are not going to be generated, but it should be printing how it would have made them).

it might be helpful to try one of the c files directly, make VERBOSE=1 BUILDDIR=/c/jul/src/support /c/jul/src/support/hashing.o

@joa-quim
Copy link

Sorry, you are right. I was just looking at it and (there is indeed a path translation problem)

/c/jul> make
make: Warning: File '/c/jul/usr/bin/libgfortran-3.dll' has modification time 6055 s in the future
make[1]: Warning: File '/c/jul/usr/bin/libdSFMT.dll' has modification time 4017 s in the future
make[1]: warning:  Clock skew detected.  Your build may be incomplete.
    CC src/support/hashing.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
hashing.c -FoC:C:/MinGW64/msys64/jul/src/support/hashing.o
    CC src/support/timefuncs.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
timefuncs.c -FoC:C:/MinGW64/msys64/jul/src/support/timefuncs.o
    CC src/support/ptrhash.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
ptrhash.c -FoC:C:/MinGW64/msys64/jul/src/support/ptrhash.o
    CC src/support/operators.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
operators.c -FoC:C:/MinGW64/msys64/jul/src/support/operators.o
    CC src/support/utf8.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
utf8.c -FoC:C:/MinGW64/msys64/jul/src/support/utf8.o
    CC src/support/ios.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
ios.c -FoC:C:/MinGW64/msys64/jul/src/support/ios.o
    CC src/support/htable.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
htable.c -FoC:C:/MinGW64/msys64/jul/src/support/htable.o
    CC src/support/bitvector.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
bitvector.c -FoC:C:/MinGW64/msys64/jul/src/support/bitvector.o
    CC src/support/int2str.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
int2str.c -FoC:C:/MinGW64/msys64/jul/src/support/int2str.o
    CC src/support/libsupportinit.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
libsupportinit.c -FoC:C:/MinGW64/msys64/jul/src/support/libsupportinit.o
    CC src/support/arraylist.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
arraylist.c -FoC:C:/MinGW64/msys64/jul/src/support/arraylist.o
    CC src/support/strtod.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
strtod.c -FoC:C:/MinGW64/msys64/jul/src/support/strtod.o
    CC src/support/asprintf.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
asprintf.c -FoC:C:/MinGW64/msys64/jul/src/support/asprintf.o
    CC src/support/wsasocketpair.o
-nologo -MD -Z7 -TP -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS -DNDEBUG -c
wsasocketpair.c -FoC:C:/MinGW64/msys64/jul/src/support/wsasocketpair.o
    CC src/support/_setjmp.win64.o
-nologo -MD -Z7 -TP -EP -P -D_WIN32_WINNT=0x0502 -IC:/jul/usr/include -IC:/jul/usr/include -DLIBRARY_EXPORTS -DUTF8PROC_EXPORTS _setjmp.win64.S
    CC src/support/_setjmp.win64.o
Microsoft (R) Macro Assembler (x64) Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: _setjmp.win64.i
MASM : fatal error A1000:cannot open file : _setjmp.win64.i
Makefile:53: recipe for target '/c/jul/src/support/_setjmp.win64.o' failed
make[2]: *** [/c/jul/src/support/_setjmp.win64.o] Error 1
Makefile:100: recipe for target 'support/libsupport.a' failed

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

it looks the output path has gotten double-expanded. what shell are you using / what does uname -s report?

@joa-quim
Copy link

/c/jul> uname -s
MINGW32_NT-6.3

It's the same that use the build julia with MinGW

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

msys1 or msys2? (or from git)

@joa-quim
Copy link

msys2

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

what does cmd //c echo -o /c/foo/bar -FeC:/foo/bar -I/c/foo/bar print from the msys2 shell? that should help indicate whether msys2 has different path-munging rules than msys1 had.

@joa-quim
Copy link

it screws the path

/c/jul> cmd //c echo -o /c/foo/bar -FeC:/foo/bar -I/c/foo/bar
-o C:/foo/bar -FeC:C:/MinGW64/msys64/foo/bar -IC:/foo/bar

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 10, 2015

ok, so it's a issue specific to interacting with msys2. what does -Fe/c/foo/bar do? i'm not sure how you are supposed to escape translation on that one. in msys1, from the rules on the website linked above, it looks like the leading - should have stopped the : from being interpreted as a list of paths, but that doesn't seem to be working on msys2

@tkelman
Copy link
Contributor Author

tkelman commented Aug 12, 2015

should be fixed by 1986c50

@DemiMarie
Copy link

I think that the solution to the BLAS and LAPACK problems is to find a way to use MinGW64-compiled BLAS and LAPACK from an MSVC-compiled Julia. Trying to use an MSVC-compiled BLAS/LAPACK will likely cause a huge performance penalty (unoptimized BLAS is much slower than tuned BLAS; same for LAPACK) and make Julia much less attractive on Windows.

The only BLAS and LAPACK that play "nice" with MSVC is Intel's MKL. However, it is proprietary, and one needs an expensive license to redistribute it with applications. It gets even worse: the standard Julia distribution is under the GNU GPL (because of FFTW), and so a version linked to MKL could not be legally redistributed at all.

The same licensing issues have an additional corollary: we may need to link to msvcrt.dll, even though it is deprecated, because it comes with the OS (and thus escapes the GPL's prohibition on linking to proprietary code). Any other C runtime would be disallowed, since it would need to accompany Julia.

The other option is to ditch FFTW and find a FFT library with a better license. This still does not solve the problem of MSVC not being able to compile a decent BLAS, however – I consider requiring that users have ifort and MKL to build Julia with MSVC to be unacceptable.

As far as compiling the BLAS and LAPACK libraries: I believe that there are two options:

  1. Link BLAS and LAPACK with msvcrt.dll, and link Julia with a different CRT. This means that an ordinary MinGW64 installation can be used. However, it also means that memory must not be allocated by BLAS and LAPACK and freed by Julia, or visa versa, or that Julia must call special allocation routines (using LoadLibrary and GetProcAddress on msvcrt.dll) to allocate memory for use by BLAS and LAPACK (and only by BLAS and LAPACK).
  2. Link BLAS and LAPACK with a different CRT (probably the Universal CRT). This means that libquadmath (an LGPL dependency) will still need to use msvcrt.dll. However, libquadmath allocates no memory for outside use, and frees no memory allocated externally, so this should be OK. However, it means that Julia should statically link the GCC runtime libraries (which are usually linked with msvcrt.dll)
  3. Link Julia with msvcrt.dll. While discouraged by Microsoft, this may be the only sane option when dealing with LGPL dependencies (libquadmath), and may be the only legal option for a GPL Julia distribution until and unless Microsoft provides another CRT that does not require proprietary DLLs to be redistributed with the application.

Option 3 is the simplest, but has the problem of not playing well with embedding programs. The most likely answer to this – which is good practice anyway – is to make sure that Julia never allocates an object that must be freed by foreign code, and that Julia never needs to free an object allocated by foreign code (This is good practice on Windows in particular).

@tkelman
Copy link
Contributor Author

tkelman commented Aug 19, 2015

I think that the solution to the BLAS and LAPACK problems is to find a way to use MinGW64-compiled BLAS and LAPACK from an MSVC-compiled Julia.

That already pretty much works. All the linalg tests, and the blas tests, passed last time I ran them on an MSVC-built julia using a normal MinGW-w64-built OpenBLAS. Mixing toolchains is just messy.

Trying to use an MSVC-compiled BLAS/LAPACK will likely cause a huge performance penalty (unoptimized BLAS is much slower than tuned BLAS; same for LAPACK) and make Julia much less attractive on Windows.

Yeah, I'm not proposing using unoptimized BLAS. If @xianyi can only get pure C kernels to work at first in an MSVC-built OpenBLAS, that's a start towards the currently impossible task of building an optimized open source BLAS implementation with MSVC. Maybe BLIS or an inline generated LLVM BLAS will be the future here, we'll have to see.

Any other C runtime would be disallowed, since it would need to accompany Julia.

I believe the story on the new CRT in MSVC 2015 is going to get better here in terms of being part of the OS.

The other option is to ditch FFTW and find a FFT library with a better license

We already have a no-GPL optional build flag that disables FFTW, and plans to move FFTW out to a package before too much longer, and a PR with a pure-Julia MIT-licensed FFT implementation. Some of the Windows-only dependencies need to be tweaked to respect the no-GPL build flag though, Git (which is going to be replaced by libgit2 anyway) and busybox and possibly others.

However, it means that Julia should statically link the GCC runtime libraries

Why would an MSVC-built Julia need to link to GCC runtimes at all? libjulia and julia.exe are not linked to blas or lapack or any other Fortran dependencies, we only ever use them dynamically through ccall.

@ihnorton
Copy link
Member

This build process appears to have been broken by the usage of $(CC) ... -dumpmachine introduced in 67b0506.

@tkelman
Copy link
Contributor Author

tkelman commented Sep 22, 2015

I need a slightly modified patch for master but I tested this as recently as a day or two ago and it was still working

edited the top post with a link to the new patch, works fine at fdee9f4

@davidanthoff
Copy link
Contributor

This has some very vague info that MS seems to be working on a Clang frontend coupled with the normal MSVC backend. Probably not helpful for this issue per se, but I thought it sounded interesting.

@tkelman
Copy link
Contributor Author

tkelman commented Oct 17, 2015

#13485 caused the following errors which I cannot figure out: https://gist.github.com/tkelman/a7ca37b1d9d785d0f6fb

So I probably won't be trying to keep this working any more on master, until we update either the LLVM version or MSVC version we want to try things with. I don't have MSVC 2015 installed, but if anyone else wants to try using it, go ahead.

edit: looks like rearranging the includes can fix this, oh joy msvc

@mikewl
Copy link
Contributor

mikewl commented Oct 19, 2015

I looked at compiling LLVM with MSVC 2015. Compiler-rt built successfully, I am not too sure if builtins were included. Could not see an option to enable or disable them in the cmake gui.
C99 complex support is not really there. The header files exist but the compiler can't deal with the complex types themselves.[1]

There is a clang frontend for msvc called clang c2 which uses the clang frontend with the Microsoft backend. This is due with VS2015 update 1 which should be released around November [2]. From discussions I saw that this may provide a way to use c99/11 with the Microsoft backend. Would that not help this issue? One problem may be windows specific code but until the tool is actually released this is all speculation. [3]

[1] https://connect.microsoft.com/VisualStudio/feedback/details/1551173/msvc-2015-complex-hs-complex-i-macro-does-not-conform-to-the-standard
[2]https://github.com/CppCon/CppCon2015/tree/master/Presentations/What's%20New%20In%20VS2015
https://github.com/CppCon/CppCon2015/tree/master/Presentations/CLANG%20C2%20for%20Windows
[3] https://www.reddit.com/r/programming/comments/3dylnc/microsoft_open_sources_gdblldb_debug_engine_for/cta6y7o

@tkelman
Copy link
Contributor Author

tkelman commented Oct 22, 2015

@Mike43110 which version of LLVM did you build?

Clang/C2 may help a bit with the remaining missing C99 pieces, though I think using full Clang with the LLVM backend would be more useful as they get Windows exception handling finished and become fully usable for self-building LLVM and our other C++ deps. The question is how well is the gcc-style clang frontend supported on Windows. If there's a real advantage in debuginfo or MSVC compatibility with eventually using Clang instead of g++ we could switch the (or add alternative) Windows builds, but the Clang toolchain would have to be as easy to get and fit with the build system like g++ does now. MSVC, and the MSVC-compatible clang-cl frontend, and in all likelihood Clang/C2, all require messy build system hacks to get working right now and would eventually be better suited to build via CMake than MSYS and gmake.

What will be useful is what's mentioned at the very tail end of http:https://www.theregister.co.uk/2015/10/21/microsoft_promises_clang_for_windows_in_november_visual_c_update/

The company is also set to release a “build only” edition of Visual C++, which will install the compiler and command-line build tools without the Visual Studio IDE.

@mikewl
Copy link
Contributor

mikewl commented Oct 22, 2015

I built svn with Visual Studio 2015. Assertions off, no tests or docs built.

CMake will be very nice once clang-cl or clang c2 is ready. I will play around with it once it is released. It would be interesting comparing clang/llvm vs clang/msvc performance. CMake will probably be necessary though for building as you stated right now. I tried to get the msvc build going but I could not even get past the libuv stage. No idea why but not too bothered as there is the WIP CMake PR.

I have wondered if building llvm and clang (and lldb at some stage too) then using them to build Julia would not be a bad idea. Especially with cxx. Pkg could then also rely on clang instead of using gcc for builds unless explicitly stated. BuildExecutable also uses gcc if I am not mistaken.

On windows I can get the clang toolchain very easily (unless I am missing something right now) by just downloading the installer.

The build only toolchain did not have a timeframe. It was mentioned in the slides but I think it will be before the end of the year.

If there are any build flags needed for building a Julia compatible llvm please mention them. I can regularly build llvm with msvc on my spare PC.

@tkelman
Copy link
Contributor Author

tkelman commented Oct 22, 2015

I'm not positive what cmake flags we would need to get an msvc or windows clang built llvm set up correctly for julia. Will depend on how things look once we start looking into and fixing various test failures. Does the clang for windows toolchain work on a clean system that does not have visual studio? Does it have the clang.exe gcc style front end? Last time I checked the installer does not come with the llvm static libraries, which we could even use to avoid having to rebuild llvm. Maybe we should ask a few more times and figure out how their installer generation scripts work to help make that happen sooner.

@xianyi
Copy link

xianyi commented Oct 28, 2015

Hi all,

I released OpenBLAS 0.2.15, which supports MSVC by cmake. However, it only can build the c kernels and the performance is not good now.

@tkelman
Copy link
Contributor Author

tkelman commented Oct 30, 2015

Thanks @xianyi, we're now using 0.2.15 on master. I haven't tried the MSVC CMake build yet but when I do we'll let you know if there are any issues.

On LLVM's ability to generate native debug info, some good news: https://github.com/Microsoft/microsoft-pdb

@StefanKarpinski
Copy link
Sponsor Member

Gotta love that Microsoft is getting on the LLVM train.

@xianyi
Copy link

xianyi commented Oct 31, 2015

I hope LLVM+Visual Studio+CMake can solve the assembly issue.

@xianyi
Copy link

xianyi commented Nov 3, 2015

@davidanthoff , is it Clang/C2 release?

@davidanthoff
Copy link
Contributor

It doesn't mention it, so I assume no, but not sure.

@davidanthoff
Copy link
Contributor

http:https://blogs.msdn.com/b/vcblog/archive/2015/12/04/introducing-clang-with-microsoft-codegen-in-vs-2015-update-1.aspx

Has a walk through on how to use the Clang frontend with the MS codegen backend.

@ihnorton
Copy link
Member

ihnorton commented Dec 5, 2015

No inline assembly support (yet).

@tkelman
Copy link
Contributor Author

tkelman commented Dec 6, 2015

Other than maybe slightly better performance, I'm not sure what the benefit would be for going through Clang with Microsoft codegen if Clang with LLVM codegen is capable of the same level of support for exception handling, MSVC ABI compatibility, and MSVC debug info compatibility.

@mikewl
Copy link
Contributor

mikewl commented Dec 6, 2015

Once Clang\LLVM or Clang\MSVC are fully working would it not be possible to ignore msvc completely? Both of the available options would at least have much better C standards support than the MSVC frontend. Are there any other benefits that I am missing? I would hope being able to ignore the msvc frontend would be able to reduce the required effort to keep windows support working properly.

I did a quick test with the LLVM install sans Visual Studio. Biggest issue is that the llvm install includes no stdlib so either the msvc or mingw one has to be used on Windows. There seems otherwise to be no immediate issues.

@ViralBShah
Copy link
Member

We aren't going to be doing this and removed some very old build files for MSVC support in 584d412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

10 participants