@@ -5032,24 +5032,27 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA,
50325032 if (IsMSVCHostCompiler)
50335033 HostCompileArgs.push_back (" /external:W0" );
50345034
5035- // Add default header search directories.
5036- SmallString<128 > BaseDir (C.getDriver ().Dir );
5037- llvm::sys::path::append (BaseDir, " .." , " include" );
5038- SmallString<128 > SYCLDir (BaseDir);
5039- llvm::sys::path::append (SYCLDir, " sycl" );
5040- // This is used to provide our wrappers around STL headers that provide
5041- // additional functions/template specializations when the user includes those
5042- // STL headers in their programs (e.g., <complex>).
5043- SmallString<128 > STLWrappersDir (SYCLDir);
5044- llvm::sys::path::append (STLWrappersDir, " stl_wrappers" );
5045- // Add the SYCL specific header directories as system directories for non
5046- // MSVC compilers.
5047- HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5048- HostCompileArgs.push_back (TCArgs.MakeArgString (SYCLDir));
5049- HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5050- HostCompileArgs.push_back (TCArgs.MakeArgString (STLWrappersDir));
5051- HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5052- HostCompileArgs.push_back (TCArgs.MakeArgString (BaseDir));
5035+ namespace options = clang::driver::options;
5036+ if (!TCArgs.hasArg (options::OPT_nostdlibinc, options::OPT_nostdinc)) {
5037+ // Add default header search directories.
5038+ SmallString<128 > BaseDir (C.getDriver ().Dir );
5039+ llvm::sys::path::append (BaseDir, " .." , " include" );
5040+ SmallString<128 > SYCLDir (BaseDir);
5041+ llvm::sys::path::append (SYCLDir, " sycl" );
5042+ // This is used to provide our wrappers around STL headers that provide
5043+ // additional functions/template specializations when the user includes
5044+ // those STL headers in their programs (e.g., <complex>).
5045+ SmallString<128 > STLWrappersDir (SYCLDir);
5046+ llvm::sys::path::append (STLWrappersDir, " stl_wrappers" );
5047+ // Add the SYCL specific header directories as system directories for non
5048+ // MSVC compilers.
5049+ HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5050+ HostCompileArgs.push_back (TCArgs.MakeArgString (SYCLDir));
5051+ HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5052+ HostCompileArgs.push_back (TCArgs.MakeArgString (STLWrappersDir));
5053+ HostCompileArgs.push_back (IsMSVCHostCompiler ? " /external:I" : " -isystem" );
5054+ HostCompileArgs.push_back (TCArgs.MakeArgString (BaseDir));
5055+ }
50535056
50545057 if (!OutputAdded) {
50555058 // Add output file to the command line. This is assumed to be prefaced
@@ -10257,6 +10260,18 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
1025710260 " kind=" + Kind.str (),
1025810261 };
1025910262
10263+ // When compiling like -fsycl-targets=spir64_gen -Xsycl-target-backend
10264+ // "-device pvc,bdw", the offloading arch will be "pvc,bdw", which
10265+ // contains a comma. Because the comma is used to separate fields
10266+ // within the --image option, we cannot pass arch=pvc,bdw directly.
10267+ // Instead, we pass it like arch=pvc,arch=bdw, then
10268+ // llvm-offload-binary joins them back to arch=pvc,bdw.
10269+ SmallVector<StringRef> Archs;
10270+ Arch.split (Archs, ' ,' );
10271+ if (Archs.size () > 1 ) {
10272+ Parts[2 ] = " arch=" + llvm::join (Archs, " ,arch=" );
10273+ }
10274+
1026010275 if (TC->getDriver ().isUsingOffloadLTO ())
1026110276 for (StringRef Feature : FeatureArgs)
1026210277 Parts.emplace_back (" feature=" + Feature.str ());
@@ -10280,7 +10295,13 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
1028010295 AL += " " ;
1028110296 AL += A;
1028210297 }
10283- Parts.emplace_back (C.getArgs ().MakeArgString (Twine (Opt) + AL));
10298+ // As mentioned earlier, we cannot pass a value with commas directly,
10299+ // but llvm-offload-binary joins multiple occurrences of the same
10300+ // option separated by commas, so we split the value on
10301+ // all commas and pass them as separate arguments.
10302+ for (StringRef Split : llvm::split (AL, ' ,' )) {
10303+ Parts.emplace_back (C.getArgs ().MakeArgString (Twine (Opt) + Split));
10304+ }
1028410305 };
1028510306 const ArgList &Args =
1028610307 C.getArgsForToolChain (nullptr , StringRef (), Action::OFK_SYCL);
@@ -10289,10 +10310,10 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
1028910310 static_cast <const toolchains::SYCLToolChain &>(*TC);
1029010311 SYCLTC.AddImpliedTargetArgs (TC->getTriple (), Args, BuildArgs, JA, *HostTC,
1029110312 Arch);
10292- SYCLTC.TranslateBackendTargetArgs (TC->getTriple (), Args, BuildArgs, Arch );
10313+ SYCLTC.TranslateBackendTargetArgs (TC->getTriple (), Args, BuildArgs);
1029310314 createArgString (" compile-opts=" );
1029410315 BuildArgs.clear ();
10295- SYCLTC.TranslateLinkerTargetArgs (TC->getTriple (), Args, BuildArgs, Arch );
10316+ SYCLTC.TranslateLinkerTargetArgs (TC->getTriple (), Args, BuildArgs);
1029610317 createArgString (" link-opts=" );
1029710318 }
1029810319
0 commit comments