@@ -6769,14 +6769,26 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
67696769 bool *EmitCodeView) const {
67706770 unsigned RTOptionID = options::OPT__SLASH_MT;
67716771 bool isNVPTX = getToolChain ().getTriple ().isNVPTX ();
6772+ bool isSYCL =
6773+ Args.hasArg (options::OPT_fsycl) ||
6774+ getToolChain ().getTriple ().getEnvironment () == llvm::Triple::SYCLDevice;
6775+ // For SYCL Windows, /MD is the default.
6776+ if (isSYCL)
6777+ RTOptionID = options::OPT__SLASH_MD;
67726778
67736779 if (Args.hasArg (options::OPT__SLASH_LDd))
6774- // The /LDd option implies /MTd. The dependent lib part can be overridden,
6775- // but defining _DEBUG is sticky.
6776- RTOptionID = options::OPT__SLASH_MTd;
6780+ // The /LDd option implies /MTd (/MDd for SYCL) . The dependent lib part
6781+ // can be overridden but defining _DEBUG is sticky.
6782+ RTOptionID = isSYCL ? options::OPT__SLASH_MDd : options::OPT__SLASH_MTd;
67776783
6778- if (Arg *A = Args.getLastArg (options::OPT__SLASH_M_Group))
6784+ if (Arg *A = Args.getLastArg (options::OPT__SLASH_M_Group)) {
67796785 RTOptionID = A->getOption ().getID ();
6786+ if (isSYCL && (RTOptionID == options::OPT__SLASH_MT ||
6787+ RTOptionID == options::OPT__SLASH_MTd))
6788+ // Use of /MT or /MTd is not supported for SYCL.
6789+ getToolChain ().getDriver ().Diag (diag::err_drv_unsupported_opt_dpcpp)
6790+ << A->getOption ().getName ();
6791+ }
67806792
67816793 StringRef FlagForCRT;
67826794 switch (RTOptionID) {
0 commit comments