Frontend: add -autolink-library= option to support Windows

All modules on Windows need to link against one of {libcmtd.lib, libcmt.lib,
msvcrtd.lib, msvcrt.lib}.  In addition to being the C library, it is the
equivalent of crtbegin0.o on other targets.  It is responsible for providing the
entry point itself.  Traditionally, cl will embed the linkage requirement into
all objects based on the flags given -- one of {/MTd, /MT, /MDd, /MD}.  clang
emulates this via the `--dependent-lib=` option.  Emulate that behaviour in the
swift driver so that swift objects being compiled for Windows targets can
auto-link to the required libraries.
This commit is contained in:
Saleem Abdulrasool
2016-07-02 20:19:48 -07:00
parent 5cf6006201
commit 53b9eb46ed
3 changed files with 13 additions and 0 deletions

View File

@@ -1285,6 +1285,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.EnableReflectionNames = false;
}
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));
return false;
}