@@ -6258,6 +6258,19 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
62586258 if (Args.hasFlag (options::OPT_fsycl_esimd, options::OPT_fno_sycl_esimd,
62596259 false ))
62606260 CmdArgs.push_back (" -fsycl-explicit-simd" );
6261+
6262+ if (!D.IsCLMode ()) {
6263+ // SYCL library is guaranteed to work correctly only with dynamic
6264+ // MSVC runtime.
6265+ llvm::Triple AuxT = C.getDefaultToolChain ().getTriple ();
6266+ if (Args.hasFlag (options::OPT_fsycl_device_only, OptSpecifier (), false ))
6267+ AuxT = llvm::Triple (llvm::sys::getProcessTriple ());
6268+ if (AuxT.isWindowsMSVCEnvironment ()) {
6269+ CmdArgs.push_back (" -D_MT" );
6270+ CmdArgs.push_back (" -D_DLL" );
6271+ CmdArgs.push_back (" --dependent-lib=msvcrt" );
6272+ }
6273+ }
62616274 }
62626275 if (IsSYCLOffloadDevice && JA.getType () == types::TY_SYCL_Header) {
62636276 // Generating a SYCL Header
@@ -6275,20 +6288,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
62756288 CmdArgs.push_back (" -D__ENABLE_USM_ADDR_SPACE__" );
62766289 }
62776290
6278- if ((IsSYCL || UseSYCLTriple) && !D.IsCLMode ()) {
6279- // SYCL library is guaranteed to work correctly only with dynamic
6280- // MSVC runtime.
6281- llvm::Triple AuxT = C.getDefaultToolChain ().getTriple ();
6282- if (Args.hasFlag (options::OPT_fsycl_device_only, OptSpecifier (), false ))
6283- AuxT = llvm::Triple (llvm::sys::getProcessTriple ());
6284- if (AuxT.isWindowsMSVCEnvironment ()) {
6285- CmdArgs.push_back (" -D_MT" );
6286- CmdArgs.push_back (" -D_DLL" );
6287- if (IsSYCL && !IsSYCLOffloadDevice && SYCLDeviceInput)
6288- CmdArgs.push_back (" --dependent-lib=msvcrt" );
6289- }
6290- }
6291-
62926291 if (IsHIP)
62936292 CmdArgs.push_back (" -fcuda-allow-variadic-functions" );
62946293
0 commit comments