Skip to content
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

Windows: Suppress noisy linker warning when linking against shared druntime/Phobos #3928

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions driver/linker-msvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
args.push_back(global.params.symdebug ? "/OPT:NOICF" : "/OPT:ICF");
}

const bool willLinkAgainstSharedDefaultLibs =
!defaultLibNames.empty() && linkAgainstSharedDefaultLibs();
if (willLinkAgainstSharedDefaultLibs) {
// Suppress linker warning LNK4217 wrt. 'importing locally defined symbol'
// (dllimport of symbol dllexported from the same binary), because there
// might be *many* of those (=> instantiated globals) if compiled without
// -linkonce-templates.
args.push_back("/IGNORE:4217");
}

// add C runtime libs
addMscrtLibs(useInternalToolchain, args);

Expand All @@ -151,8 +161,7 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath,
// add precompiled rt.dso object file (in lib directory) when linking
// against shared druntime
const auto &libDirs = ConfigFile::instance.libDirs();
if (!defaultLibNames.empty() && linkAgainstSharedDefaultLibs() &&
!libDirs.empty()) {
if (willLinkAgainstSharedDefaultLibs && !libDirs.empty()) {
args.push_back((llvm::Twine(libDirs[0]) + "/ldc_rt.dso.obj").str());
}

Expand Down