@@ -10960,13 +10960,6 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
10960
10960
if (Args.hasArg (options::OPT_v))
10961
10961
CmdArgs.push_back (" --wrapper-verbose" );
10962
10962
10963
- // TODO(NOM2): Pass following options to clang-linker-wrapper.
10964
- // Please refer to sycl/doc/design/OffloadDesign.md for details.
10965
- // sycl-device-libraries
10966
- // sycl-device-library-location
10967
- // sycl-post-link-options
10968
- // llvm-spirv-options
10969
-
10970
10963
if (const Arg *A = Args.getLastArg (options::OPT_g_Group)) {
10971
10964
if (!A->getOption ().matches (options::OPT_g0))
10972
10965
CmdArgs.push_back (" --device-debug" );
@@ -10999,12 +10992,14 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
10999
10992
// Add any SYCL offloading specific options to the clang-linker-wrapper
11000
10993
if (C.hasOffloadToolChain <Action::OFK_SYCL>()) {
11001
10994
// -sycl-device-libraries=<comma separated list> contains all of the SYCL
11002
- // device specific libraries that are needed. This provides the list of
11003
- // files file only.
11004
- // TODO: This generic list will be populated with only device binaries
11005
- // for spir/spirv. Other targets (AOT and others) can represent a different
11006
- // set of device libraries. We will cross that bridge when we begin to
11007
- // enable the other possible targets.
10995
+ // device specific libraries that are needed. This generic list will be
10996
+ // populated with device binaries for all target triples in the current
10997
+ // compilation flow.
10998
+
10999
+ // Create a comma separated list to pass along to the linker wrapper.
11000
+ SmallString<256 > LibList;
11001
+ // TODO: TargetTriple should not be used here for creating linker wrapper
11002
+ // options. It should also not be passed to the linker wrapper.
11008
11003
llvm::Triple TargetTriple;
11009
11004
auto ToolChainRange = C.getOffloadToolChains <Action::OFK_SYCL>();
11010
11005
for (auto &I :
@@ -11013,38 +11008,24 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11013
11008
if (TC->getTriple ().isSPIROrSPIRV () &&
11014
11009
TC->getTriple ().getSubArch () == llvm::Triple::NoSubArch) {
11015
11010
TargetTriple = TC->getTriple ();
11016
- break ;
11011
+ SmallVector<std::string, 8 > SYCLDeviceLibs;
11012
+ auto IsSPIR = TargetTriple.isSPIROrSPIRV ();
11013
+ bool IsSpirvAOT = TargetTriple.isSPIRAOT ();
11014
+ bool UseJitLink =
11015
+ IsSPIR &&
11016
+ Args.hasFlag (options::OPT_fsycl_device_lib_jit_link,
11017
+ options::OPT_fno_sycl_device_lib_jit_link, false );
11018
+ bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
11019
+ SYCLDeviceLibs = SYCL::getDeviceLibraries (C, TargetTriple, UseAOTLink);
11020
+ for (const auto &AddLib : SYCLDeviceLibs) {
11021
+ if (LibList.size () > 0 )
11022
+ LibList += " ," ;
11023
+ LibList += AddLib;
11024
+ }
11017
11025
}
11018
11026
}
11019
- // Pass the device triple to the linker wrapper tool for SYCL offload.
11020
- // Only spir64 or spirv64 is currently passed.
11021
- // TODO(NOM1): Support target triples in a more generic way.
11022
- // TODO(NOM3): Investigate why passing spirv64-unknown-unknown does not
11023
- // work.
11024
- if (TargetTriple.isSPIR ())
11025
- CmdArgs.push_back (" --triple=spir64" );
11026
- else if (TargetTriple.isSPIRV ())
11027
- CmdArgs.push_back (" --triple=spirv64" );
11028
-
11029
- SmallVector<std::string, 8 > SYCLDeviceLibs;
11030
- auto IsSPIR = TargetTriple.isSPIROrSPIRV ();
11031
- bool IsSpirvAOT = TargetTriple.isSPIRAOT ();
11032
- bool UseJitLink =
11033
- IsSPIR &&
11034
- Args.hasFlag (options::OPT_fsycl_device_lib_jit_link,
11035
- options::OPT_fno_sycl_device_lib_jit_link, false );
11036
- bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
11037
- SYCLDeviceLibs = SYCL::getDeviceLibraries (C, TargetTriple, UseAOTLink);
11038
- // Create a comma separated list to pass along to the linker wrapper.
11039
- SmallString<256 > LibList;
11040
- for (const auto &AddLib : SYCLDeviceLibs) {
11041
- if (LibList.size () > 0 )
11042
- LibList += " ," ;
11043
- LibList += AddLib;
11044
- }
11045
11027
// -sycl-device-libraries=<libs> provides a comma separate list of
11046
11028
// libraries to add to the device linking step.
11047
- // SYCL device libraries can be found.
11048
11029
if (LibList.size ())
11049
11030
CmdArgs.push_back (
11050
11031
Args.MakeArgString (Twine (" -sycl-device-libraries=" ) + LibList));
0 commit comments