@@ -10929,18 +10929,35 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1092910929 if (allowDeviceImageDependencies (TCArgs))
1093010930 addArgs (PostLinkArgs, TCArgs, {" -allow-device-image-dependencies" });
1093110931
10932- SYCLInstallationDetector SYCLInstall (TC.getDriver ());
10933- SmallVector<SmallString<128 >, 4 > SpvLocCandidates;
10934- SmallString<128 > FallbackAssertName (" libsycl-fallback-cassert.spv" );
10935- SYCLInstall.getSYCLDeviceLibPath (SpvLocCandidates, true );
10936- for (const auto &SpvLoc : SpvLocCandidates) {
10937- SmallString<128 > FullLibName (SpvLoc);
10938- llvm::sys::path::append (FullLibName, FallbackAssertName);
10939- if (llvm::sys::fs::exists (FullLibName)) {
10940- SmallString<128 > SYCLDeviceLibDir (" --device-lib-spv-dir=" );
10941- SYCLDeviceLibDir += SpvLoc.str ();
10942- addArgs (PostLinkArgs, TCArgs, {SYCLDeviceLibDir.str ()});
10943- break ;
10932+ bool DeviceLibDisable = false ;
10933+ Arg *DeviceLibArg = TCArgs.getLastArg (options::OPT_fsycl_device_lib_EQ,
10934+ options::OPT_fno_sycl_device_lib_EQ);
10935+ if (DeviceLibArg &&
10936+ DeviceLibArg->getOption ().matches (options::OPT_fno_sycl_device_lib_EQ)) {
10937+ for (StringRef Val : DeviceLibArg->getValues ()) {
10938+ if (Val == " all" ) {
10939+ DeviceLibDisable = true ;
10940+ break ;
10941+ }
10942+ }
10943+ }
10944+
10945+ // Fallback spv is NOT involved in AOT compilation or
10946+ // '-fno-sycl-device-lib=all' is applied by user explicitly.
10947+ if (!TC.getTriple ().isSPIRAOT () && !DeviceLibDisable) {
10948+ SYCLInstallationDetector SYCLInstall (TC.getDriver ());
10949+ SmallVector<SmallString<128 >, 4 > SpvLocCandidates;
10950+ SmallString<128 > FallbackAssertName (" libsycl-fallback-cassert.spv" );
10951+ SYCLInstall.getSYCLDeviceLibPath (SpvLocCandidates, true );
10952+ for (const auto &SpvLoc : SpvLocCandidates) {
10953+ SmallString<128 > FullLibName (SpvLoc);
10954+ llvm::sys::path::append (FullLibName, FallbackAssertName);
10955+ if (llvm::sys::fs::exists (FullLibName)) {
10956+ SmallString<128 > SYCLDeviceLibDir (" --device-lib-spv-dir=" );
10957+ SYCLDeviceLibDir += SpvLoc.str ();
10958+ addArgs (PostLinkArgs, TCArgs, {SYCLDeviceLibDir.str ()});
10959+ break ;
10960+ }
1094410961 }
1094510962 }
1094610963}
0 commit comments