@@ -11005,13 +11005,6 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11005
11005
if (Args.hasArg (options::OPT_v))
11006
11006
CmdArgs.push_back (" --wrapper-verbose" );
11007
11007
11008
- // TODO(NOM2): Pass following options to clang-linker-wrapper.
11009
- // Please refer to sycl/doc/design/OffloadDesign.md for details.
11010
- // sycl-device-libraries
11011
- // sycl-device-library-location
11012
- // sycl-post-link-options
11013
- // llvm-spirv-options
11014
-
11015
11008
if (const Arg *A = Args.getLastArg (options::OPT_g_Group)) {
11016
11009
if (!A->getOption ().matches (options::OPT_g0))
11017
11010
CmdArgs.push_back (" --device-debug" );
@@ -11044,12 +11037,14 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11044
11037
// Add any SYCL offloading specific options to the clang-linker-wrapper
11045
11038
if (C.hasOffloadToolChain <Action::OFK_SYCL>()) {
11046
11039
// -sycl-device-libraries=<comma separated list> contains all of the SYCL
11047
- // device specific libraries that are needed. This provides the list of
11048
- // files file only.
11049
- // TODO: This generic list will be populated with only device binaries
11050
- // for spir/spirv. Other targets (AOT and others) can represent a different
11051
- // set of device libraries. We will cross that bridge when we begin to
11052
- // enable the other possible targets.
11040
+ // device specific libraries that are needed. This generic list will be
11041
+ // populated with device binaries for all target triples in the current
11042
+ // compilation flow.
11043
+
11044
+ // Create a comma separated list to pass along to the linker wrapper.
11045
+ SmallString<256 > LibList;
11046
+ // TODO: TargetTriple should not be used here for creating linker wrapper
11047
+ // options. It should also not be passed to the linker wrapper.
11053
11048
llvm::Triple TargetTriple;
11054
11049
auto ToolChainRange = C.getOffloadToolChains <Action::OFK_SYCL>();
11055
11050
for (auto &I :
@@ -11058,38 +11053,24 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
11058
11053
if (TC->getTriple ().isSPIROrSPIRV () &&
11059
11054
TC->getTriple ().getSubArch () == llvm::Triple::NoSubArch) {
11060
11055
TargetTriple = TC->getTriple ();
11061
- break ;
11056
+ SmallVector<std::string, 8 > SYCLDeviceLibs;
11057
+ bool IsSPIR = TargetTriple.isSPIROrSPIRV ();
11058
+ bool IsSpirvAOT = TargetTriple.isSPIRAOT ();
11059
+ bool UseJitLink =
11060
+ IsSPIR &&
11061
+ Args.hasFlag (options::OPT_fsycl_device_lib_jit_link,
11062
+ options::OPT_fno_sycl_device_lib_jit_link, false );
11063
+ bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
11064
+ SYCLDeviceLibs = SYCL::getDeviceLibraries (C, TargetTriple, UseAOTLink);
11065
+ for (const auto &AddLib : SYCLDeviceLibs) {
11066
+ if (LibList.size () > 0 )
11067
+ LibList += " ," ;
11068
+ LibList += AddLib;
11069
+ }
11062
11070
}
11063
11071
}
11064
- // Pass the device triple to the linker wrapper tool for SYCL offload.
11065
- // Only spir64 or spirv64 is currently passed.
11066
- // TODO(NOM1): Support target triples in a more generic way.
11067
- // TODO(NOM3): Investigate why passing spirv64-unknown-unknown does not
11068
- // work.
11069
- if (TargetTriple.isSPIR ())
11070
- CmdArgs.push_back (" --triple=spir64" );
11071
- else if (TargetTriple.isSPIRV ())
11072
- CmdArgs.push_back (" --triple=spirv64" );
11073
-
11074
- SmallVector<std::string, 8 > SYCLDeviceLibs;
11075
- auto IsSPIR = TargetTriple.isSPIROrSPIRV ();
11076
- bool IsSpirvAOT = TargetTriple.isSPIRAOT ();
11077
- bool UseJitLink =
11078
- IsSPIR &&
11079
- Args.hasFlag (options::OPT_fsycl_device_lib_jit_link,
11080
- options::OPT_fno_sycl_device_lib_jit_link, false );
11081
- bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
11082
- SYCLDeviceLibs = SYCL::getDeviceLibraries (C, TargetTriple, UseAOTLink);
11083
- // Create a comma separated list to pass along to the linker wrapper.
11084
- SmallString<256 > LibList;
11085
- for (const auto &AddLib : SYCLDeviceLibs) {
11086
- if (LibList.size () > 0 )
11087
- LibList += " ," ;
11088
- LibList += AddLib;
11089
- }
11090
11072
// -sycl-device-libraries=<libs> provides a comma separate list of
11091
11073
// libraries to add to the device linking step.
11092
- // SYCL device libraries can be found.
11093
11074
if (LibList.size ())
11094
11075
CmdArgs.push_back (
11095
11076
Args.MakeArgString (Twine (" -sycl-device-libraries=" ) + LibList));
0 commit comments