Skip to content

Commit b2048de

Browse files
authored
[Clang] [Driver] Support -fjmc for *-windows-msvc target in non cl driver modes (#107177)
Allow `-fjmc` to be used if the target triple is targeting msvc, `*-windows-msvc`, irrelevant of the driver mode used. In general the driver mode shouldn't control the target triple. Also in our custom build system I am trying to just treat clang as clang. This is because while the `cl` driver mode emulates msvc interface quite well there are still a lot of operations that are just clang specific. The optimization modes do not map directly from msvc to clang. Warnings do not map from msvc to clang. Instead of wrapping options with `/clang:` when targeting `clang-cl.exe` it is just easier to target the clang driver always irrelevant of the target triple.
1 parent c82a549 commit b2048de

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4853,7 +4853,8 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
48534853

48544854
// This controls whether or not we perform JustMyCode instrumentation.
48554855
if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
4856-
if (TC.getTriple().isOSBinFormatELF() || D.IsCLMode()) {
4856+
if (TC.getTriple().isOSBinFormatELF() ||
4857+
TC.getTriple().isWindowsMSVCEnvironment()) {
48574858
if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
48584859
CmdArgs.push_back("-fjmc");
48594860
else if (D.IsCLMode())

clang/test/Driver/clang_f_opts.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,12 @@
600600
// CHECK_NO_DISABLE_DIRECT-NOT: -fobjc-disable-direct-methods-for-testing
601601

602602
// RUN: %clang -### -S -fjmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN,CHECK_NOJMC %s
603-
// RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC %s
603+
// RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN,CHECK_NOJMC %s
604+
// RUN: %clang -### -S -fjmc -g -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
605+
// RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
604606
// RUN: %clang -### -S -fjmc -g -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
605607
// RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
606-
// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC_LTO %s
608+
// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
607609
// RUN: %clang -### -fjmc -g -flto -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC_LTO %s
608610
// RUN: %clang -### -fjmc -g -flto -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
609611
// CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored

0 commit comments

Comments
 (0)