akhuang created this revision. akhuang added reviewers: mstorsjo, hans. Herald added a project: All. akhuang requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. Herald added a project: clang.
The /Zl flag omits default C runtime library name from obj files. This patch just adds an equivalent clang driver flag. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D133959 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-runtime-flags.c Index: clang/test/Driver/cl-runtime-flags.c =================================================================== --- clang/test/Driver/cl-runtime-flags.c +++ clang/test/Driver/cl-runtime-flags.c @@ -97,6 +97,9 @@ // 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 +// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static \ +// RUN: -fms-omit-default-lib-name -- %s 2>&1 | FileCheck \ +// RUN: -check-prefix=CHECK-MTZl %s // CHECK-MTZl-NOT: "-D_DEBUG" // CHECK-MTZl: "-D_MT" // CHECK-MTZl-NOT: "-D_DLL" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4490,7 +4490,8 @@ llvm_unreachable("Unexpected option ID."); } - if (Args.hasArg(options::OPT__SLASH_Zl)) { + if (Args.hasArg(options::OPT__SLASH_Zl) || + Args.hasArg(options::OPT_fms_omit_default_lib_name)) { CmdArgs.push_back("-D_VC_NODEFAULTLIB"); } else { CmdArgs.push_back(FlagForCRT.data()); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2219,6 +2219,9 @@ to the cl flags /MT and /MTd which use the multithread, static version. "dll" and "dll_dbg" correspond to the cl flags /MD and /MDd which use the multithread, dll version.}]>; +def fms_omit_default_lib_name : Joined<["-"], "fms-omit-default-lib-name">, + Group<f_Group>, Flags<[NoXarchOption, CoreOption]>, + HelpText<"Omit the default C runtime library name from the .obj file.">; defm delayed_template_parsing : BoolFOption<"delayed-template-parsing", LangOpts<"DelayedTemplateParsing">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Parse templated function definitions at the end of the translation unit">,
Index: clang/test/Driver/cl-runtime-flags.c =================================================================== --- clang/test/Driver/cl-runtime-flags.c +++ clang/test/Driver/cl-runtime-flags.c @@ -97,6 +97,9 @@ // 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 +// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static \ +// RUN: -fms-omit-default-lib-name -- %s 2>&1 | FileCheck \ +// RUN: -check-prefix=CHECK-MTZl %s // CHECK-MTZl-NOT: "-D_DEBUG" // CHECK-MTZl: "-D_MT" // CHECK-MTZl-NOT: "-D_DLL" Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4490,7 +4490,8 @@ llvm_unreachable("Unexpected option ID."); } - if (Args.hasArg(options::OPT__SLASH_Zl)) { + if (Args.hasArg(options::OPT__SLASH_Zl) || + Args.hasArg(options::OPT_fms_omit_default_lib_name)) { CmdArgs.push_back("-D_VC_NODEFAULTLIB"); } else { CmdArgs.push_back(FlagForCRT.data()); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2219,6 +2219,9 @@ to the cl flags /MT and /MTd which use the multithread, static version. "dll" and "dll_dbg" correspond to the cl flags /MD and /MDd which use the multithread, dll version.}]>; +def fms_omit_default_lib_name : Joined<["-"], "fms-omit-default-lib-name">, + Group<f_Group>, Flags<[NoXarchOption, CoreOption]>, + HelpText<"Omit the default C runtime library name from the .obj file.">; defm delayed_template_parsing : BoolFOption<"delayed-template-parsing", LangOpts<"DelayedTemplateParsing">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Parse templated function definitions at the end of the translation unit">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits