-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: MSVC continued #7761
RFC: MSVC continued #7761
Conversation
The preprocessor thing is kind of a hack. We could check in the generated file if necessary. |
I think I tracked it down once via git blame to some time in 2010 (#6230 (comment)). MSVC also can't compile/preprocess from stdin, so |
From Google, it seems that it read from stdin, but it doesn't need the
Might not want to do that, since they can vary by platform. But we could just use the normal preprocessor capabilities directly (like we do with |
I updated the build script (to copy And the newlib version of getopt can't handle options with Trying to run the MSVC Julia gives some messages (Unfortunately running this same setup on AppVeyor gives a whole bunch of access violations at the same place this used to hit a stack overflow https://ci.appveyor.com/project/tkelman/julia/build/1.0.489, I suspect the VM's might not have enough memory to handle 64-bit Julia codegen) |
@@ -53,10 +53,13 @@ | |||
|
|||
#ifndef _MSC_VER | |||
.intel_syntax | |||
ENTRY(jl_longjmp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can avoid this complicating ifndef if we write this as:
#define CNAME jl_longjmp
#include "./../deps/openlibm/i387/ENTRY.h"
<function definition here>
#include "./../deps/openlibm/i387/END.h"
where ENTRY.h
is:
#define _START_ENTRY .p2align 2,0x90
#if defined(__linux__) || defined(__FreeBSD__) || defined(__ELF__)
#ifndef __APPLE__
#define EXT(csym) csym
#endif
#define HIDENAME(asmsym) .asmsym
_START_ENTRY
.globl EXT(CNAME)
.type EXT(CNAME),@function
EXT(CNAME):
#elif defined(_WIN32)
#define EXT(csym) _##csym
#define HIDENAME(asmsym) .asmsym
#ifndef _MSC_VER
.intel_syntax
.text
_START_ENTRY
.globl EXT(CNAME)
.section .drectve
.ascii " -export:" #CNAME
.section .text
.def EXT(CNAME)
.scl 2
.type 32
.endef
EXT(CNAME):
#else
.586
.model small,C
CNAME proc
#endif
#endif
and END.h
is:
#if defined(__linux__) || defined(__FreeBSD__) || defined(__ELF__)
.size CNAME, . - CNAME
#else
#ifndef _MSC_VER
.end
#else
CNAME endp
#endif
#endif
#undef CNAME
#undef CNAME
#undef _START_ENTRY
#ifndef __APPLE__
#undef EXT
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wanting to avoid having to add extra little files over in a different submodule, but yeah this version should work and might be step one of eventually attempting openlibm with MSVC. Though I think most of the assembly in openlibm is ATT syntax, not Intel, right?
that can happen if you are forcing |
Adding |
@vtjnash reminded me of this in a different issue - I think codegen might be nonfunctional with these MSVC experiments. Do we need to JIT code to a different ABI if LLVM and Julia are built with MSVC? Also, llvmcall (specifically
Any ideas? |
I switched from newlib's version of getopt to modifying musl's slightly, it handles |
Any other comments on the minor tweaks here? Suggestions for things to try to get codegen to work? musl's MIT licensed so I don't think there should be any concern adding 2 files from it, right? |
A link to musl's LICENSE file should probably go into LICENSE, then this looks good to merge |
note, your instructions in the first post are missing references to 7z and MARCH which are needed |
it would also be preferable for your msys_build.sh script to not replace binaries in /usr/bin, but simply to shadow them by downloading them to dist-extras, and pushing that onto |
Done. We aren't linking to it so much as copying and modifying a couple small pieces of its source, but whatever.
7z added. MARCH gets set in Make.user by the script, doesn't need to be set on the command line.
Done. Any ideas on what's broken about codegen? |
Interesting, the REPL actually starts and I can do some very basic things if I comment out Line 526 in a08ae29
It looks like I'm getting undefined variable errors but libuv isn't displaying them correctly for some reason? |
it seems like we are trying to free a junk Line 633 in a08ae29
but you mentioned that a |
Err, not exactly. I can try that. What I had tried earlier was taking |
ah, gotcha, so reverse my statements: It's probably not a memory issue or Julia issue, but might be happening inside libuv. it would be good to see what |
A milestone, huh?
Suggestions for how I might go about doing that? |
is the msvc llvm built with assertions. if not, could you put one up with assertions enabled? also, add |
No idea. Is that default with the cmake build? It was many months ago and I don't remember what options I used. (Part of why I like autoconf - I can at least open up config.log and reconstruct exactly what I did. Unfortunately I don't think I kept the built sources around, if there's an equivalent log file for cmake.)
I guess. LLVM takes many hours to build with MSVC, I've been avoiding doing it again.
Slow down. Are these things you're asking me to improve about the (currently hacky) way this builds, or instructions for making a debug build, or a combination of both? |
all of the above. plus suggestions to try while i wait for my build to finish. instead of |
@tkelman When running msys_build.sh, I'm getting this error when trying to extract the mingw64-prec RPM file:
|
@mossr That may be a network issue corrupting the file. However that particular file shouldn't be needed any more, are you working from latest master or one of my branches? |
Yeah, no reason not to, this was all merged into master a couple months ago and should be working fine. We don't have the MSVC build "officially" documented or given first-class fully-functional support (so this merged PR is still the main point of information for it), but it should compile to a REPL at least. We also aren't continuously testing against MSVC right now to save time on appveyor, but if someone commits some non-MSVC-friendly C it should usually be simple to fix. |
@tkelman What commit was this last confirmed to work? |
@mossr sounds like I last checked the build about 4 days ago, not sure on the exact commit though. I know I checked at 28c4357 since that was an explicit MSVC compatibility change I asked Jeff to make in #9255. I'm running some other builds right now so I can't check at today's master, but I don't expect any recent commits to have caused any problems. If they did it's usually a simple fix, so let me know what kind of errors you're hitting if any. |
Okay, looks like #9251 did actually break the MSVC build (https://ci.appveyor.com/project/tkelman/julia/build/1.0.572 cc @twadleigh), I'll see what needs to be done to fix it. |
@tkelman It's important to mention that I'm trying to use the 2010 version of MSVC. Besides adding "msvcr100" to I've ran into some issues building libuv because of a non-2013 compiler. Most of them were easy to fix, but this may result in future issues. |
@tkelman : looks like MSVC can't find |
@mossr Yeah you should've said that earlier. MSVC 2010 isn't good enough. You'll need to recompile your own LLVM, and various other C99 bits and pieces aren't going to work. If you can get MSVC 2010 to work I'd entertain a pull request, but I'm not going to work too hard to maintain it myself. I think LLVM trunk only supports 2013 at the moment, so trying to keep old MSVC versions working is probably a futile endeavor long-term. @twadleigh I fixed it with that include in c88315e, it doesn't seem to hurt the mingw case so I just did it for all windows builds. Granted there's a suitesparse change that's still awaiting a new nightly so at the moment an MSVC 2013 build will need to use a version of master before #9251 was merged. |
Well, I don't know what you guys do to build with MSVC but I simply don't manage. I hided all directories that might interfere in the path. None of them have gcc, but still the build is done with a gcc (not msvc). I can confirm that by observing the processes running in the task manager (I see Gcc, G++, cc1) |
@joa-quim you're apparently going down the wrong branch of julia/contrib/windows/msys_build.sh Lines 86 to 119 in f140ff2
USEMSVC=1 it isn't working properly.
This could be improved by migrating from a shell script to cmake for MSVC support, ref #1832 |
Yes, a cmake solution would be ideal. |
Note that there are nmake files in the repository, but they're incomplete and currently unused and unmaintained. nmake is pretty limited in syntax and annoyingly incompatible with GNU make, but the fact that there's at least something to start from whereas cmake would require porting things from scratch means someone might want to go that route instead. I'd advise against it since cmake offers advantages across all platforms (#1832 (comment)), but I wouldn't oppose pull requests to update the nmake files. |
@tkelman I built LLVM-3.3 with MSVC10 and that worked (using I now get a Julia seg. fault from
|
Hey, not bad, you got pretty far then. For reference, which commit are you building? Presumably with some local patches on top I'm guessing? Master just got some new inline assembly that'll have to be cleaned up for MSVC compatibility eventually, but I'm more concerned with just getting it to pass tests with mingw64 right now. Anyway, if you build with |
I think that's symptomatic of trying to use one of the non-existent compiler intrinsics, eg for i128 operations |
Entirely possible. I think the last time I tried with Visual Studio 2012 there were problems with infinity and nan, but those are probably fixable with smallish patches instead of switching to a newer compiler version like I did.
|
Yes, it's expecting the compiler-rt library. I think tkelman was working on building that? |
Last time I looked (pretty sure I tried both 3.3 and 3.5.0), the cmake+msvc build system wasn't fully hooked up for the builtins part of compiler-rt. You might check LLVM trunk to see if anything's any different now (but breakage for other API reasons is really common there, so beware). |
@tkelman fwiw, i think I've successfully enabled the COMDAT stuff that the MSVC link.exe needed, in bfa51bb (for llvm3.5+ / MCJIT) |
Neat. I'll try to play with that once the LLVM upgrade is done. I feel really iffy about trying to mix MSVC link.exe with the usual MinGW toolchain - there's going to be nasty path-shadowing with the posix For an MSVC build of Julia itself, we should perhaps open a new issue to bring back partial support for it. You mentioned doing something with |
the linking stage ( the assembly i wrote is essentially an optimized version of |
As we saw over in #9376 (comment), we do need a static lib of the stack-checker function, and I'm pretty sure |
msvc distributes |
declare vasprintf before using use JL_GC_PUSH1 instead of JL_GC_PUSH, latter requires C99 vararg macros use __alignof instead of __alignof__ for msvc remove define for _isnan, no longer seems to be necessary disable ASM_COPY_STACKS for MSVC Don't include valgrind.h for MSVC use _write instead of write
Following up on #6230, #6349, and others. This gets past the stack overflow when compiling
inference.jl
into the system image, but craps out atpcre.jl
because the preprocessed PCRE headers don't come out correctly from the MSVC preprocessor (it doesn't understand-dM
). Putting this up so people can look at it, I'll keep thinking about workarounds for the preprocessor issues - can probably copy some of them straight out of the MinGW binaries.How to run this, assuming you have Visual Studio 2013 (express should work) installed:
cd "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
vcvarsall x86_amd64
cd
to your MSYS installation, whichever foldersh.exe
is located in (eitherbin
orusr/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 oflink.exe
showing up first in the path)set MSYSTEM=MINGW32
sh --login
cd
to your Julia directory, checkoutthis branchlatest masterARCH=x86_64 USEMSVC=1 contrib/windows/msys_build.sh
This downloads the latest Windows nightly binary and uses as many dependencies from it as possible, and downloads an MSVC build of LLVM that I made in early April. I should update that with our latest patches, and build a 32-bit version with VS 2013 at some point.