@@ -11299,6 +11299,15 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1129911299 // Create a comma separated list to pass along to the linker wrapper.
1130011300 SmallString<256 > LibList;
1130111301 SmallString<256 > BCLibList;
11302+
11303+ // Lambda to append items to BCLibList with comma separation
11304+ auto appendToBCLibList = [&BCLibList](const llvm::Triple &Triple,
11305+ const Twine &Path) {
11306+ if (BCLibList.size () > 0 )
11307+ BCLibList += " ," ;
11308+ BCLibList += (Twine (Triple.str ()) + " =" + Path).str ();
11309+ };
11310+
1130211311 llvm::Triple TargetTriple;
1130311312 auto ToolChainRange = C.getOffloadToolChains <Action::OFK_SYCL>();
1130411313 for (auto &I :
@@ -11316,15 +11325,23 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1131611325 SYCLDeviceLibs = SYCL::getDeviceLibraries (C, TargetTriple, UseAOTLink);
1131711326 for (const auto &AddLib : SYCLDeviceLibs) {
1131811327 if (llvm::sys::path::extension (AddLib) == " .bc" ) {
11319- if (BCLibList. size () > 0 )
11320- BCLibList += " , " ;
11321- BCLibList += Twine (TC->getTriple (). str () + " = " + AddLib). str ( );
11328+ SmallString< 256 > LibPath (DeviceLibDir);
11329+ llvm::sys::path::append (LibPath, AddLib) ;
11330+ appendToBCLibList (TC->getTriple (), LibPath );
1132211331 continue ;
1132311332 }
11333+
1132411334 if (LibList.size () > 0 )
1132511335 LibList += " ," ;
1132611336 LibList += AddLib;
1132711337 }
11338+
11339+ if (TC->getTriple ().isNVPTX ()) {
11340+ if (const char *LibSpirvFile = SYCLInstallation.findLibspirvPath (
11341+ TC->getTriple (), Args, *TC->getAuxTriple ())) {
11342+ appendToBCLibList (TC->getTriple (), LibSpirvFile);
11343+ }
11344+ }
1132811345 }
1132911346 // -sycl-device-libraries=<libs> provides a comma separate list of
1133011347 // libraries to add to the device linking step.
@@ -11334,7 +11351,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1133411351
1133511352 if (BCLibList.size ())
1133611353 CmdArgs.push_back (
11337- Args.MakeArgString (Twine (" -- sycl-bc-device-libraries=" ) + BCLibList));
11354+ Args.MakeArgString (Twine (" -sycl-bc-device-libraries=" ) + BCLibList));
1133811355
1133911356 // -sycl-device-library-location=<dir> provides the location in which the
1134011357 // SYCL device libraries can be found.
0 commit comments