@@ -1404,8 +1404,21 @@ static Error UnbundleFiles() {
1404
1404
auto Output = Worklist.find (CurTriple);
1405
1405
// The file may have more bundles for other targets, that we don't care
1406
1406
// about. Therefore, move on to the next triple
1407
- if (Output == Worklist.end ())
1408
- continue ;
1407
+ if (Output == Worklist.end ()) {
1408
+ // FIXME: temporary solution for supporting binaries produced by old
1409
+ // versions of SYCL toolchain. Old versions used triples with 'sycldevice'
1410
+ // environment component of the triple, whereas new toolchain use
1411
+ // 'unknown' value for that triple component. Here we assume that if we
1412
+ // are looking for a bundle for sycl offload kind, for the same target
1413
+ // triple there might be either one with 'sycldevice' environment or with
1414
+ // 'unknown' environment, but not both. So we will look for any of these
1415
+ // two variants.
1416
+ Output =
1417
+ Worklist.find (CurTriple.drop_back (11 /* length of "-sycldevice"*/ ));
1418
+ if (!CurTriple.startswith (" sycl-" ) ||
1419
+ !CurTriple.endswith (" -sycldevice" ) || Output == Worklist.end ())
1420
+ continue ;
1421
+ }
1409
1422
1410
1423
// Check if the output file can be opened and copy the bundle to it.
1411
1424
std::error_code EC;
@@ -1507,7 +1520,21 @@ static Expected<bool> CheckBundledSection() {
1507
1520
return std::move (Err);
1508
1521
1509
1522
StringRef triple = TargetNames.front ();
1510
- // Read all the bundles that are in the work list. If we find no bundles we
1523
+
1524
+ // FIXME: temporary solution for supporting binaries produced by old versions
1525
+ // of SYCL toolchain. Old versions used triples with 'sycldevice' environment
1526
+ // component of the triple, whereas new toolchain use 'unknown' value for that
1527
+ // triple component. Here we assume that if we are looking for a bundle for
1528
+ // sycl offload kind, for the same target triple there might be either one
1529
+ // with 'sycldevice' environment or with 'unknown' environment, but not both.
1530
+ // So we will look for any of these two variants.
1531
+ OffloadTargetInfo TI (triple);
1532
+ bool checkCompatibleTriple =
1533
+ (TI.OffloadKind == " sycl" ) &&
1534
+ (TI.Triple .getEnvironment () == Triple::UnknownEnvironment);
1535
+ TI.Triple .setEnvironmentName (" sycldevice" );
1536
+ std::string compatibleTriple = Twine (" sycl-" + TI.Triple .str ()).str ();
1537
+
1511
1538
// assume the file is meant for the host target.
1512
1539
bool found = false ;
1513
1540
while (!found) {
@@ -1519,7 +1546,9 @@ static Expected<bool> CheckBundledSection() {
1519
1546
if (!*CurTripleOrErr)
1520
1547
break ;
1521
1548
1522
- if (*CurTripleOrErr == triple) {
1549
+ if (*CurTripleOrErr == triple ||
1550
+ (checkCompatibleTriple &&
1551
+ *CurTripleOrErr == StringRef (compatibleTriple))) {
1523
1552
found = true ;
1524
1553
break ;
1525
1554
}
0 commit comments