forked from OSchip/llvm-project
[clang-cl] Implement support for the /Zl flag
The flag allows users to specify that they do not want the object file to have any implicit /defaultlib directives. This fixes PR24236. llvm-svn: 243097
This commit is contained in:
parent
eb85c8fb09
commit
e2afb47d1e
|
@ -243,6 +243,8 @@ def _SLASH_vmv : CLFlag<"vmv">,
|
|||
def _SLASH_volatile_ms : Option<["/", "-"], "volatile:ms", KIND_FLAG>,
|
||||
Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>,
|
||||
HelpText<"Volatile loads and stores have acquire and release semantics">;
|
||||
def _SLASH_Zl : CLFlag<"Zl">,
|
||||
HelpText<"Don't mention any default libraries in the object file">;
|
||||
|
||||
// Ignored:
|
||||
|
||||
|
@ -333,5 +335,4 @@ def _SLASH_Zc : CLJoined<"Zc:">;
|
|||
def _SLASH_Ze : CLFlag<"Ze">;
|
||||
def _SLASH_Zg : CLFlag<"Zg">;
|
||||
def _SLASH_ZI : CLFlag<"ZI">;
|
||||
def _SLASH_Zl : CLFlag<"Zl">;
|
||||
def _SLASH_ZW : CLJoined<"ZW">;
|
||||
|
|
|
@ -5098,39 +5098,46 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
|
|||
if (Arg *A = Args.getLastArg(options::OPT__SLASH_M_Group))
|
||||
RTOptionID = A->getOption().getID();
|
||||
|
||||
StringRef FlagForCRT;
|
||||
switch (RTOptionID) {
|
||||
case options::OPT__SLASH_MD:
|
||||
if (Args.hasArg(options::OPT__SLASH_LDd))
|
||||
CmdArgs.push_back("-D_DEBUG");
|
||||
CmdArgs.push_back("-D_MT");
|
||||
CmdArgs.push_back("-D_DLL");
|
||||
CmdArgs.push_back("--dependent-lib=msvcrt");
|
||||
FlagForCRT = "--dependent-lib=msvcrt";
|
||||
break;
|
||||
case options::OPT__SLASH_MDd:
|
||||
CmdArgs.push_back("-D_DEBUG");
|
||||
CmdArgs.push_back("-D_MT");
|
||||
CmdArgs.push_back("-D_DLL");
|
||||
CmdArgs.push_back("--dependent-lib=msvcrtd");
|
||||
FlagForCRT = "--dependent-lib=msvcrtd";
|
||||
break;
|
||||
case options::OPT__SLASH_MT:
|
||||
if (Args.hasArg(options::OPT__SLASH_LDd))
|
||||
CmdArgs.push_back("-D_DEBUG");
|
||||
CmdArgs.push_back("-D_MT");
|
||||
CmdArgs.push_back("--dependent-lib=libcmt");
|
||||
FlagForCRT = "--dependent-lib=libcmt";
|
||||
break;
|
||||
case options::OPT__SLASH_MTd:
|
||||
CmdArgs.push_back("-D_DEBUG");
|
||||
CmdArgs.push_back("-D_MT");
|
||||
CmdArgs.push_back("--dependent-lib=libcmtd");
|
||||
FlagForCRT = "--dependent-lib=libcmtd";
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Unexpected option ID.");
|
||||
}
|
||||
|
||||
// This provides POSIX compatibility (maps 'open' to '_open'), which most
|
||||
// users want. The /Za flag to cl.exe turns this off, but it's not
|
||||
// implemented in clang.
|
||||
CmdArgs.push_back("--dependent-lib=oldnames");
|
||||
if (Args.hasArg(options::OPT__SLASH_Zl)) {
|
||||
CmdArgs.push_back("-D_VC_NODEFAULTLIB");
|
||||
} else {
|
||||
CmdArgs.push_back(FlagForCRT.data());
|
||||
|
||||
// This provides POSIX compatibility (maps 'open' to '_open'), which most
|
||||
// users want. The /Za flag to cl.exe turns this off, but it's not
|
||||
// implemented in clang.
|
||||
CmdArgs.push_back("--dependent-lib=oldnames");
|
||||
}
|
||||
|
||||
// Both /showIncludes and /E (and /EP) write to stdout. Allowing both
|
||||
// would produce interleaved output, so ignore /showIncludes in such cases.
|
||||
|
|
|
@ -84,3 +84,12 @@
|
|||
|
||||
// RUN: %clang_cl /MD /MT -### -- %s 2>&1 | FileCheck -check-prefix=MTOVERRIDE %s
|
||||
// MTOVERRIDE: "--dependent-lib=libcmt"
|
||||
|
||||
// RUN: %clang_cl -### /Zl -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTZl %s
|
||||
// RUN: %clang_cl -### /MT /Zl -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTZl %s
|
||||
// CHECK-MTZl-NOT: "-D_DEBUG"
|
||||
// CHECK-MTZl: "-D_MT"
|
||||
// CHECK-MTZl-NOT: "-D_DLL"
|
||||
// CHECK-MTZl-SAME: "-D_VC_NODEFAULTLIB"
|
||||
// CHECK-MTZl-NOT: "--dependent-lib=libcmt"
|
||||
// CHECK-MTZl-NOT: "--dependent-lib=oldnames"
|
||||
|
|
Loading…
Reference in New Issue