Skip to content

Add support for VS2015#4879

Merged
MartinNowak merged 5 commits intodlang:masterfrom
rainers:link_vs2015
Aug 27, 2015
Merged

Add support for VS2015#4879
MartinNowak merged 5 commits intodlang:masterfrom
rainers:link_vs2015

Conversation

@rainers
Copy link
Member

@rainers rainers commented Aug 11, 2015

  • detect linking against VS2015 or later by checking library search paths
  • add UCRT lib path for VS2015
  • add "stdio_msvc14_64.obj" or "stdio_msvc12_64.obj" to link command line accordingly
  • add "legacy_stdio_definitions.lib" to link command line for VS2015.

needs dlang/druntime#1341
needs dlang/druntime#1360.

@MartinNowak
Copy link
Member

This is missing a magicport.json addition of version function detectMSVC14, but with that I can convert the PR according to #4922 (comment), and it looks like it would compile.
Maybe you just want to reset your branch to my HEAD, https://github.com/MartinNowak/dmd/tree/pr/4879.

@rainers
Copy link
Member Author

rainers commented Aug 23, 2015

Maybe you just want to reset your branch to my HEAD, https://github.com/MartinNowak/dmd/tree/pr/4879.

Will do.

I am not sure the automatic adding of an object file is the best possible solution, but I don't know a better one so far. I expected some discussion ;-)

It works for the usual cases, but there are some downsides to this approach:

  • you currently cannot disable it, so you cannot link to libraries built differently using dmd.
  • the detection comes with a little magic (search legacy_stdio_definitions.lib in the same folder as libcmt.lib)
  • rebuilds internals of how MS link finds libraries, this might fail if another linker is used.
  • some build scripts might need to be adopted if they call the linker directly (Visual D does this usually).

@MartinNowak
Copy link
Member

At least it doesn't require any change when using dmd.

@rainers
Copy link
Member Author

rainers commented Aug 23, 2015

Maybe you just want to reset your branch to my HEAD, https://github.com/MartinNowak/dmd/tree/pr/4879.

Will do.

Done.

@rainers
Copy link
Member Author

rainers commented Aug 23, 2015

BTW: if dmd is supposed to also work without $(VCInstallDir)\vcvarsall.bat being run before, the installer will have to detect the UCRT folder and version. This is a bit ugly as it involves reading the registry and finding the newest directory in the UCRT lib/include folder.

@MartinNowak
Copy link
Member

BTW: if dmd is supposed to also work without $(VCInstallDir)\vcvarsall.bat being run before, the installer will have to detect the UCRT folder and version. This is a bit ugly as it involves reading the registry and finding the newest directory in the UCRT lib/include folder.

Think I already did that MartinNowak/installer@45790b7 MartinNowak@8af60f3.

@MartinNowak
Copy link
Member

Auto-merge toggled on

@yebblies
Copy link
Contributor

Auto-merge toggled off

@MartinNowak
Copy link
Member

link.d(942): Error: cannot implicitly convert expression (exists(liblegacy)) of type int to bool

@rainers
Copy link
Member Author

rainers commented Aug 24, 2015

Rebased and fixed.

@MartinNowak
Copy link
Member

Auto-merge toggled on

@yebblies
Copy link
Contributor

Still failing.

@yebblies
Copy link
Contributor

Auto-merge toggled off

@MartinNowak
Copy link
Member

LINK : fatal error LNK1181: cannot open input file 'stdio_msvc12_64.obj'

The druntime lib dir isn't in the libpath, you need to copy the objects to phobos or change the libpath.

@MartinNowak
Copy link
Member

The druntime lib dir isn't in the libpath, you need to copy the objects to phobos or change the libpath.

The nicest solution would still be to put both obj files into the library and somehow let dmd tell the linker which one to pick.

@rainers
Copy link
Member Author

rainers commented Aug 26, 2015

The nicest solution would still be to put both obj files into the library and somehow let dmd tell the linker which one to pick.

See dlang/druntime#1360. It should be compatible with linking against older VS versions without the changes here, but I'll have to update this PR for VS2015.

@rainers
Copy link
Member Author

rainers commented Aug 27, 2015

It should be compatible with linking against older VS versions without the changes here, but I'll have to update this PR for VS2015.

Updated to work with dlang/druntime#1360 instead.

@MartinNowak
Copy link
Member

Auto-merge toggled on

MartinNowak added a commit that referenced this pull request Aug 27, 2015
@MartinNowak MartinNowak merged commit 3b76b8c into dlang:master Aug 27, 2015
@thewilsonator thewilsonator mentioned this pull request Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants