VS detection: fallback to lld-link and the mingw libs if no SDK/VC installation found#7500
VS detection: fallback to lld-link and the mingw libs if no SDK/VC installation found#7500dlang-bot merged 6 commits intodlang:stablefrom
Conversation
rainers
commented
Dec 23, 2017
- uses lld-link.exe alongside dmd.exe if no MS link.exe found
- switches the default MS C runtime to msvcrt100 instead libcmt if no VC installation found
- adds mingw subdir of lib64/lib32mscoff as a library search path if no Windows SDK found
- uses the version of link.exe that is looks most appropriate regarding host and target architecture
- improves detection whether legacy_stdio_definitions.lib needs to be added to linker options
|
Thanks for your pull request, @rainers! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
If lld is going to be included now an alternative to optlink, changing the compiler flags to be uniform might be a good idea. So -m32 and -m64 use msvc/lld-link and then a third -m32optlink using optlink instead of having -m32mscoff. |
|
@skl131313 changing the meaning of existing command-line flags is not possible, since it would be a breaking change. |
|
@ZombineDev |
Yes, please. I don't use Windows, but I still hear from many problems about OPTLINK. As an example it only supports 32k symbols and thus we have to resort to crazy workarounds for Phobos: dlang/phobos#5939 |
|
2.078 will be released soon. Should this be part of it? I'm not sure. On one side these fixes look very important for people on Windows, on the other side there is a risk for regressions and we have already passed the beta release phase. Other opinions? |
|
Yes, doesn't make much sense without also having dlang/installer#281 which is probably delayed until next release. |
5a29ab2 to
344f57d
Compare
src/dmd/link.d
Outdated
| } | ||
|
|
||
| // try lld-link.exe alongside dmd.exe | ||
| char[MAX_PATH + 1] dmdpath; |
src/dmd/link.d
Outdated
| // so prepend it too the PATH environment variable | ||
| const char* path = getenv("PATH"); | ||
| const char* idepath = FileName.combine(VSInstallDir, r"Common7\IDE"); | ||
| auto pathlen = strlen(path); |
src/dmd/link.d
Outdated
| const char* idepath = FileName.combine(VSInstallDir, r"Common7\IDE"); | ||
| auto pathlen = strlen(path); | ||
| auto idepathlen = strlen(idepath); | ||
| auto addpathlen = strlen(addpath); |
src/dmd/mars.d
Outdated
| if (global.params.mscoff && !global.params.mscrtlib) | ||
| { | ||
| VSOptions vsopt; | ||
| vsopt.initialize (); |
|
Rebased and addressed review comments. |
Labeling as "Blocked" then. |
|
@rainers just saw your post on the NG: http://forum.dlang.org/post/p4883m$1nv1$1@digitalmars.com
So should we go ahead with this PR? It looks like this PR already makes sense - even without the installer modifications. |
|
I guess the largest side-effect would be https://github.com/dlang/dmd/pull/7500/files#diff-12efbb2a88b713dbb0fd0a64673ba132R475: if no VC is detected, the default runtime library is switched from libcmt to msvcrt100 which only exists with the updated installer. I could extract that to a different PR, though. |
|
Let's ping @MartinNowak to get the installed updated before the 2.079 release then. |
| char[MAX_PATH + 1] dmdpath = void; | ||
| if (GetModuleFileNameA(null, dmdpath.ptr, dmdpath.length) <= MAX_PATH) | ||
| { | ||
| auto lldpath = FileName.replaceName(dmdpath.ptr, "lld-link.exe"); |
There was a problem hiding this comment.
Likely will break if we shipped a 32-bit bin/lld.exe with a 64-bit bin64/dmd.exe.
There was a problem hiding this comment.
We might also add a 64-bit lld.exe in that case.
c1d979a to
e3980a8
Compare
e3980a8 to
4eb526e
Compare
|
|
||
| // try mingw fallback relative to phobos library folder that's part of LIB | ||
| Strings* libpaths = FileName.splitPath(getenv("LIB")); | ||
| if (auto p = FileName.searchPath(libpaths, r"mingw\kernel32.lib", false)) |
There was a problem hiding this comment.
This doesn't match the 2.079-beta1 installer that places all platform libraries alongside phobos64.lib. Was this a deliberate choice?