diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 5d66605c257d..a80214e1e663 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -8098,7 +8098,9 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_g_Group)) CmdArgs.push_back("-debug"); - bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd); + bool DLL = Args.hasArg(options::OPT__SLASH_LD, + options::OPT__SLASH_LDd, + options::OPT_shared); if (DLL) { CmdArgs.push_back(Args.MakeArgString("-dll")); diff --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c new file mode 100644 index 000000000000..a93ecaf9b638 --- /dev/null +++ b/clang/test/Driver/msvc-link.c @@ -0,0 +1,12 @@ +// RUN: %clang -target i686-pc-windows-msvc -### %s 2>&1 | FileCheck --check-prefix=BASIC %s +// BASIC: "link.exe" +// BASIC: "-out:a.exe" +// BASIC: "-defaultlib:libcmt" +// BASIC: "-nologo" + +// RUN: %clang -target i686-pc-windows-msvc -shared -o a.dll -### %s 2>&1 | FileCheck --check-prefix=DLL %s +// DLL: "link.exe" +// DLL: "-out:a.dll" +// DLL: "-defaultlib:libcmt" +// DLL: "-nologo" +// DLL: "-dll"