-
-
Notifications
You must be signed in to change notification settings - Fork 416
first support for VS2015 #1341
first support for VS2015 #1341
Conversation
@@ -75,6 +75,7 @@ SRCS=\ | |||
src\core\sys\windows\threadaux.d \ | |||
src\core\sys\windows\windows.d \ | |||
src\core\sys\windows\winsock2.d \ | |||
src\core\sys\windows\stdio_msvc12.d \ |
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.
msvc14 missing
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.
ATM you cannot link both stdio_msvc12 and stdio_msvc14 (this is the SRCS file). They both have to be added to MANIFEST, though.
Can't we add both version to druntime and depending on a version declaration of the compiler import the correct msvcxx modules. That way we don't need to ship multiple libraries. |
My current idea is to add the new modules as libraries or object files to the lib64 folder while phobos64.lib is independent of the VS version. There is a compile switch or some automatic detection to add the appropriate library to the link. I'm not sure if the defaultlib-mechanism is appropriate here. I suspect a solution using versions will cause a lot of confusion, because every prebuilt library needs to be compiled with the same VC version as the executable. Shipped as binaries will need two versions if all VC versions are supposed to be supported. |
It also wouldn't work for druntim/phobos as DLL. |
The defaultlib switch is fairly underpowered. |
I guess the easiest way forward is too hack support for VC detection into dmd's src/link.c. |
From ldc-developers#29 (comment)
|
….obj and stdio_msvc14.obj instead
Updated to build stdio_msvc*.d to object files. Now needs dlang/dmd#4879 |
Rather than build a whole separate library, how about adding an extra .obj file that is linked in when using older VS? |
That's actually what this PR does now in combination with dlang/dmd#4879. It drags in a few symbols that are not always necessary, though (e.g. _flsbuf, _filbuf). |
Would it help to use libs instead of objects? |
I just verified that my expectation was unfounded. The functions in the object files are generated into COMDATs, so they are only linked if referenced. |
Sharing the C runtime between phobos.dll and an application would pretty much only work if both link against the same version of the MSVCRnnn DLLs. So a phobos DLL will have to be rebuilt for every VS version. |
Auto-merge toggled on |
Update for the build script dlang/installer#139. |
https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=1706290&isPull=true
|
The compiler has to select one of the new object files: dlang/dmd#4879 |
Auto-merge toggled off |
…efore updating dmd
I have added stdio_msvc12.d to the library build so that the PR should pass the tester. It should also let the dmd PR build successfully with VS2013 or earlier. Once the latter is merged we can remove the file from the lib to also build with VS2015. |
I like the approach with the 2 object files. I've just compared it to my patch for LDC (kinke@6a1c9d3), and these are the differences. Because of the lacking version declaration, constants cannot be adjusted for VS 2015+, at least as long as one wants to keep them as compile-time constants and not as
This PR keeps defining
Scrap that. Looking at the inline definition in the 2015 stdio.h header, |
I think we should leave the constants as is ATM with comments that they apply to older version, but add alternatives with postfix
I agree, we should use the C99 compliant version of snprintf as much as possible. Forwarding might also be done through |
Cool, what a handy undocumented linker pragma. 👍
Exactly, a perfect fit!
Hmm, then people may start using them and then we won't be able to get rid of them for quite a while. It would also encourage people to start/continue writing unportable, MS-specific code. I doubt there's much code relying on these constants out there in the D wilderness anyway, so I'd prefer keeping the constants (with comments) as-is for some time until we remove VS 2013- support from druntime. Edit: #1361 |
This PR extracts internals of the VS runtime implementation of stdio into a separate module that can be implemented depending on the VS version.
This avoids having VS version specific conditionals in the public stdio module just leading to confusion when mixing prebuilt libraries with new code.
For now, this PR links the code for VS2013 or earlier versions, but the final version should put each module in a separate library. The compiler could then figure out what environment is used for linking and add the respective library to the link comand.This PR works in combination with dlang/dmd#4879 by the compiler selecting the appropriate object file for the version of the LIBCMT library that will be used by link.exe.