Skip to content

Comments

VS detection: fallback to lld-link and the mingw libs if no SDK/VC installation found#7500

Merged
dlang-bot merged 6 commits intodlang:stablefrom
rainers:vsdetect2
Feb 18, 2018
Merged

VS detection: fallback to lld-link and the mingw libs if no SDK/VC installation found#7500
dlang-bot merged 6 commits intodlang:stablefrom
rainers:vsdetect2

Conversation

@rainers
Copy link
Member

@rainers 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

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @rainers!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@skl131313
Copy link
Contributor

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.

@PetarKirov
Copy link
Member

@skl131313 changing the meaning of existing command-line flags is not possible, since it would be a breaking change.

@skl131313
Copy link
Contributor

@ZombineDev
Not being possible and deterring from implementing something are two entirely different meanings. Breaking changes still get implemented (see integer promotion for + - ~). Optlink should be deprecated as no one is even willing to commit fixes for it and as a result is introducing limitations into DMD. This implements an alternative for it that can be shipped with DMD.

@wilzbach
Copy link
Contributor

Optlink should be deprecated as no one is even willing to commit fixes for it and as a result is introducing limitations into DMD. This implements an alternative for it that can be shipped with DMD.

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

@wilzbach wilzbach added this to the 2.078.0 milestone Dec 29, 2017
@wilzbach
Copy link
Contributor

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?

@rainers
Copy link
Member Author

rainers commented Dec 29, 2017

Yes, doesn't make much sense without also having dlang/installer#281 which is probably delayed until next release.

@wilzbach wilzbach modified the milestones: 2.078.0, 2.079.0 Dec 29, 2017
@wilzbach wilzbach changed the base branch from stable to master December 29, 2017 20:05
src/dmd/link.d Outdated
}

// try lld-link.exe alongside dmd.exe
char[MAX_PATH + 1] dmdpath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= void;

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const pathlen =

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const addpathlen =

src/dmd/mars.d Outdated
if (global.params.mscoff && !global.params.mscrtlib)
{
VSOptions vsopt;
vsopt.initialize ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space before ()

@rainers
Copy link
Member Author

rainers commented Jan 5, 2018

Rebased and addressed review comments.

@JinShil
Copy link
Contributor

JinShil commented Jan 17, 2018

Yes, doesn't make much sense without also having dlang/installer#281

Labeling as "Blocked" then.

@wilzbach
Copy link
Contributor

@rainers just saw your post on the NG: http://forum.dlang.org/post/p4883m$1nv1$1@digitalmars.com

This PR #7500 would have fixed that by changing the detection to the existence of legacy_stdio_definitions.lib in the VC library path. Unfortunately it didn't make it into the release.

So should we go ahead with this PR? It looks like this PR already makes sense - even without the installer modifications.

@wilzbach wilzbach closed this Jan 23, 2018
@wilzbach wilzbach reopened this Jan 23, 2018
@rainers
Copy link
Member Author

rainers commented Jan 23, 2018

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.

@wilzbach
Copy link
Contributor

wilzbach commented Feb 6, 2018

Let's ping @MartinNowak to get the installed updated before the 2.079 release then.

@MartinNowak MartinNowak changed the base branch from master to stable February 17, 2018 21:12
char[MAX_PATH + 1] dmdpath = void;
if (GetModuleFileNameA(null, dmdpath.ptr, dmdpath.length) <= MAX_PATH)
{
auto lldpath = FileName.replaceName(dmdpath.ptr, "lld-link.exe");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely will break if we shipped a 32-bit bin/lld.exe with a 64-bit bin64/dmd.exe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also add a 64-bit lld.exe in that case.


// 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))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the 2.079-beta1 installer that places all platform libraries alongside phobos64.lib. Was this a deliberate choice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants