zero9178 created this revision. zero9178 added reviewers: rnk, CaseyCarter, hans, thakis. zero9178 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Since VS 2022 17.1 MSVC predefines _MSVC_EXECUTION_CHARACTER_SET to inform the users of the execution character set defined at compile time. The value the macro expands to is a Windows Code Page Identifier which are documented here: https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers As clang currently only supports UTF-8 it is defined as 65001. If clang-cl were to support a different execution character set in the future we'd have to change the value. Fixes https://bugs.llvm.org/show_bug.cgi?id=52549 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114576 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-execution-character-set.c Index: clang/test/Driver/cl-execution-character-set.c =================================================================== --- /dev/null +++ clang/test/Driver/cl-execution-character-set.c @@ -0,0 +1,7 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// Only UTF-8 is currently supported, which has the Windows Code +// Page Identifier 65001 +// RUN: %clang_cl -### -- %s 2>&1 | FileCheck %s +// CHECK: -D_MSVC_EXECUTION_CHARACTER_SET=65001 Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7327,6 +7327,14 @@ CmdArgs.push_back("--dependent-lib=oldnames"); } + // Starting with VS 2022 17.1, MSVC predefines the below macro to inform + // users of the execution character set defined at compile time. + // The value given is the Windows Code Page Identifier: + // https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers + // + // Clang currently only supports UTF-8, so we'll use 65001 + CmdArgs.push_back("-D_MSVC_EXECUTION_CHARACTER_SET=65001"); + if (Arg *ShowIncludes = Args.getLastArg(options::OPT__SLASH_showIncludes, options::OPT__SLASH_showIncludes_user)) {
Index: clang/test/Driver/cl-execution-character-set.c =================================================================== --- /dev/null +++ clang/test/Driver/cl-execution-character-set.c @@ -0,0 +1,7 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// Only UTF-8 is currently supported, which has the Windows Code +// Page Identifier 65001 +// RUN: %clang_cl -### -- %s 2>&1 | FileCheck %s +// CHECK: -D_MSVC_EXECUTION_CHARACTER_SET=65001 Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -7327,6 +7327,14 @@ CmdArgs.push_back("--dependent-lib=oldnames"); } + // Starting with VS 2022 17.1, MSVC predefines the below macro to inform + // users of the execution character set defined at compile time. + // The value given is the Windows Code Page Identifier: + // https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers + // + // Clang currently only supports UTF-8, so we'll use 65001 + CmdArgs.push_back("-D_MSVC_EXECUTION_CHARACTER_SET=65001"); + if (Arg *ShowIncludes = Args.getLastArg(options::OPT__SLASH_showIncludes, options::OPT__SLASH_showIncludes_user)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits