@@ -453,6 +453,13 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
453453 return LibraryList;
454454 }
455455
456+ // Ignore no-offloadlib for NativeCPU device library, it provides some
457+ // critical builtins which must be linked with user's device image.
458+ if (TargetTriple.isNativeCPU ()) {
459+ LibraryList.push_back (Args.MakeArgString (" libsycl-nativecpu_utils.bc" ));
460+ return LibraryList;
461+ }
462+
456463 using SYCLDeviceLibsList = SmallVector<StringRef, 8 >;
457464 const SYCLDeviceLibsList SYCLDeviceLibs = {" libsycl-crt" ,
458465 " libsycl-complex" ,
@@ -489,14 +496,6 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
489496 }
490497 };
491498
492- // nativecpu only needs libsycl-nativecpu_utils.
493- const SYCLDeviceLibsList SYCLNativeCpuDeviceLibs = {
494- " libsycl-nativecpu_utils" };
495- if (TargetTriple.isNativeCPU ()) {
496- addLibraries (SYCLNativeCpuDeviceLibs);
497- return LibraryList;
498- }
499-
500499 if (!NoOffloadLib)
501500 addLibraries (SYCLDeviceLibs);
502501
@@ -505,7 +504,9 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
505504 const SYCLDeviceLibsList SYCLDeviceAnnotationLibs = {
506505 " libsycl-itt-user-wrappers" , " libsycl-itt-compiler-wrappers" ,
507506 " libsycl-itt-stubs" };
508- addLibraries (SYCLDeviceAnnotationLibs);
507+ if (Args.hasFlag (options::OPT_fsycl_instrument_device_code,
508+ options::OPT_fno_sycl_instrument_device_code, true ))
509+ addLibraries (SYCLDeviceAnnotationLibs);
509510
510511 return LibraryList;
511512}
0 commit comments