-
-
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
Steps towards MSVC compatibility #6230
Conversation
Great to have you working on this! |
Some progress here: after updating the nmake files a bit, MSVC can build flisp but has trouble with In parallel pursuing the gmake approach (just to see which gets further sooner), there is some trouble at The way the makefiles worked out, nmake is doing flisp first and gmake is doing libuv first. It may be that flisp line endings and libuv linking are problems both methods would run into, not sure. |
My initial guess is that Windows is doing a
Again just an initial guess, but the error message looks like you are building against the upstream master libuv, rather than julia's custom-patched libuv |
I was doing I may have screwed up which libuv branch the submodule was pointing to, I'll look into it. |
Yep, I had the submodule wrong, sorry. What do we make of this? https://ci.appveyor.com/project/tkelman/julia/build/1.0.170
This is with the gmake approach, but nmake-compiled flisp has the same issue if you try to run unittest.lsp manually. |
This smells like windows I had similar issues when playing around with |
And out of curious, you still use the C compiler right? I thought that flisp would already require C++ wham using MSVC |
C for libuv, C++ ( I was able to turn off the line endings error by adding
to With nmake I need to find a MSVC-compiled binary download of LLVM and get it installed in appveyor.yml. |
That last commit touches almost every C file, adding Two of the remaining undefined references are
@vtjnash, can you help on this one? The other two are confusing, looks like maybe a problem with C vs C++ linkage?
|
This is pretty exciting. Cool! |
@tkelman for the first one, you could try changing the order of the object files so setjmp and longjmp are first (see eg: http://blogs.msdn.com/b/vcblog/archive/2009/07/21/linker-warning-lnk4221-and-some-tips-to-avoid-it.aspx) For the last two, I think you need to link Shell32.lib and Winmm.lib |
I tried changing the order around, same warning about no public symbols. If I use Will try adding shell32.lib and winmm.lib to OSLIBS, thanks for that. Edit: indeed that worked, now we're down to just the assembly functions. |
shouldn't it be possible to use the MinGW compiled object files for the |
Assembly files are, by virtue of not using a compiler, compiler independent. One of the things the CNAME macro does is add the dllexport flag. Perhaps ml uses a different name for this command, or can't handle multiple commands on one line |
why would microsoft pick |
Hah, that explains it. If I manually split up the I thought having
|
maybe we should just copy all of that template code into the individual files and provide translations of each line |
Maybe? I haven't tried yet, but it may end up being necessary to get openlibm compiling here too, since it's linked statically into the REPL exe's (on Windows anyway). |
It's not technically necessary to have libopenlibm, it just makes the math more accurate. I was hoping to get both working by patching the bsd_asm header as I did, but now I'm somewhat at a loss |
I may have it,
gives me an External for This was thanks to http://kipirvine.com/asm/gettingStartedVS2012/index.htm: |
Awesome. We could probably use an include file as a multiline macro, if you would like to make this general for openlibm too (thanks to your picture above for the idea) |
Good idea, my first cut in e97ef83 is very preliminary but I believe it gives a successfully linked I don't have a local copy of MSVC 2012 to match the version of LLVM I'm downloading, but anyone who does should be able to replicate this from my It got out of |
Not sure is this helps, but the fenv functions are provided by openlibm It look like cl doesnt understand the -dM option we use to invoke the preprocessing step only (in $(CPP)). But that should be roughly the same as how we preprocessing the .S files |
I don't think you have the right value for HUGE_VALF, but otherwise looks good |
Thanks for looking it over. HUGE_VALF should be a single-precision positive infinity, right? Largest representable single is around 3.4e38? |
So, tried to figure out what the According to http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html,
Any way to get |
This is really awesome. Have you tried to take the MSVC libjulia.dll and replace it with one in a MinGW build, in order to see if julia can already be executed? |
@tkelman Sorry, I forgot about that. I am currently uploading to https://dl.dropboxusercontent.com/u/10376457/llvm3.3msvc.zip Its the release build and only the folder with the *.lib + the include folder. |
Thanks, cool I'll give it a try. Is it 32 or 64 bit? I have the infrastructure in place in my |
Its up now. And its 64bit |
Or more precisely: I think its 64 bit :-) |
Rebased for the removal of readline, and squashed a few of the minor changes to get rid of some places where I changed my mind on how to do things (couldn't get rc to work right in place of windres, travesty of travesties that the MSVC julia exe doesn't have an icon right now). MSVC appears to be miscompiling something in flisp, but I don't know what. 64 bit is awaiting confirmation on exception-handling enums in headers. The setjmp/longjmp assembly could be fixed quick-and-dirty here, or more elegantly (but more work that hasn't been done yet) in the preprocessor macros over in openlibm. I've had to introduce MSVC-only dependencies, not included in the PR at this point (the getopt port, and |
Add USEMSVC variable to Make.inc for handling different flags and toolchain Fix LLVM header problem in codegen.cpp due to define on min/max Use __cpuid intrinsic for msvc instead of inline assembly Add explicit casts, fixup ifdefs (_WIN32 instead of __WIN32__)
patch utf8proc so it can compile in either C or C++ mode dont define USE_COMPUTED_GOTO for MSVC (might be an odd double-definition problem from some header) add utf8proc info to src/flisp/Windows.mk (needs some improvement on handling of utf8proc version number and assumption of cl vs icl) add strtod to Windows.mk add DLLEXPORT before jl_init_frontend(void) modify OSLIBS and CONFIGURE_COMMON for msvc
compile basename and dirname for msvc disable line endings error define HUGE_VALF if needed add shell32.lib and winmm.lib to OSLIBS modify preprocessing for MSVC add include path to openlibm for fenv.h
in order to compile Julia with a C++ compiler (specifically MSVC)
skip flisp unit test with msvc (for now?) skip a few headers (will need to find replacements for these)
explicit casts and fix ifdefs (__WIN32__ => _WIN32) remove unistd header already included in repl.h remove DLLEXPORT from repl.h use hex code for escape put back getopt.h define dirname and PATH_MAX for repl fix LDFLAGS that MSVC doesn't understand skip julia_res.o with msvc extern C linkage on repl
crashes immediately, but it's a start extern C on basename, dirname, jlapi DLLEXPORT on basename, dirname add export to link command for jl_setjmp and jl_longjmp get uv to export symbols
@vtjnash Do we actually expect the |
…broken for me right now, so this only works for libjulia-release
we have full control over _exception_handler, so no, that value will never occur. |
I see that travis passed the last build, so is this ready to merge? |
I'm happy with it at the moment, so unless anyone has any review comments, yes? |
Steps towards MSVC compatibility
Awesome 👍 |
I added this for MSVC in #6230 but it's not actually necessary with MSVC 2013. Maybe it was a 2012-or-earlier thing that got fixed as they added support for more of C99. In a `NO_GIT` build openlibm will be at a different location, so let's not hard-code it.
Add USEMSVC variable to Make.inc for handling different flags and toolchain
Fix LLVM header problem in codegen.cpp due to define on min/max
Use
__cpuid
intrinsic for msvc instead of inline assemblyAdd explicit casts, fixup ifdefs (
_WIN32
instead of__WIN32__
)The changes to the Makefiles assume you're using the
compile
andar-lib
wrapper scripts from Automake, explicitly overridingCC
andAR
. This gets to flisp and then runs into trouble: https://ci.appveyor.com/project/tkelman/julia/build/1.0.127