diff options
| author | Martin Storsjo <martin@martin.st> | 2018-07-10 10:46:51 +0000 |
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2018-07-10 10:46:51 +0000 |
| commit | 006bffe25aa2808231998b6ff84801638dc33d44 (patch) | |
| tree | f4b8cc17e2b9f60d4d18b601d6038a5ff2102d11 /clang/lib/Driver | |
| parent | 995e596168551b879f736004e8aa40a6e09b915e (diff) | |
| download | bcm5719-llvm-006bffe25aa2808231998b6ff84801638dc33d44.tar.gz bcm5719-llvm-006bffe25aa2808231998b6ff84801638dc33d44.zip | |
[MinGW] Skip adding default win32 api libraries if -lwindowsapp is specified
In this setup, skip adding all the default windows import libraries,
if linking to windowsapp (which replaces them, when targeting the
windows store/UWP api subset).
With GCC, the same is achieved by using a custom spec file, but
since clang doesn't use spec files, we have to allow other means of
overriding what default libraries to use (without going all the
way to using -nostdlib, which would exclude everything). The same
approach, in detecting certain user specified libraries and omitting
others from the defaults, was already used in SVN r314138.
Differential Revision: https://reviews.llvm.org/D49059
llvm-svn: 336655
Diffstat (limited to 'clang/lib/Driver')
| -rw-r--r-- | clang/lib/Driver/ToolChains/MinGW.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index da71a84b760..a88e00f0c8e 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -201,6 +201,14 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bdynamic"); } + bool HasWindowsApp = false; + for (auto Lib : Args.getAllArgValues(options::OPT_l)) { + if (Lib == "windowsapp") { + HasWindowsApp = true; + break; + } + } + if (!Args.hasArg(options::OPT_nostdlib)) { if (!Args.hasArg(options::OPT_nodefaultlibs)) { if (Args.hasArg(options::OPT_static)) @@ -223,15 +231,19 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_pthread)) CmdArgs.push_back("-lpthread"); - // add system libraries - if (Args.hasArg(options::OPT_mwindows)) { - CmdArgs.push_back("-lgdi32"); - CmdArgs.push_back("-lcomdlg32"); + if (!HasWindowsApp) { + // Add system libraries. If linking to libwindowsapp.a, that import + // library replaces all these and we shouldn't accidentally try to + // link to the normal desktop mode dlls. + if (Args.hasArg(options::OPT_mwindows)) { + CmdArgs.push_back("-lgdi32"); + CmdArgs.push_back("-lcomdlg32"); + } + CmdArgs.push_back("-ladvapi32"); + CmdArgs.push_back("-lshell32"); + CmdArgs.push_back("-luser32"); + CmdArgs.push_back("-lkernel32"); } - CmdArgs.push_back("-ladvapi32"); - CmdArgs.push_back("-lshell32"); - CmdArgs.push_back("-luser32"); - CmdArgs.push_back("-lkernel32"); if (Args.hasArg(options::OPT_static)) CmdArgs.push_back("--end-group"); |

