@@ -465,7 +465,7 @@ fatbinary(ArrayRef<std::pair<StringRef, StringRef>> InputFiles,
465465
466466namespace generic {
467467Expected<StringRef> clang (ArrayRef<StringRef> InputFiles, const ArgList &Args,
468- bool HasSYCLOffloadKind = false ) {
468+ uint16_t ActiveOffloadKindMask ) {
469469 llvm::TimeTraceScope TimeScope (" Clang" );
470470 // Use `clang` to invoke the appropriate device tools.
471471 Expected<std::string> ClangPath =
@@ -559,7 +559,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
559559 // required. Passing --sycl-link to clang results in a call to
560560 // clang-sycl-linker. Additional linker flags required by clang-sycl-linker
561561 // will be communicated via the -Xlinker option.
562- if (HasSYCLOffloadKind ) {
562+ if (ActiveOffloadKindMask & OFK_SYCL ) {
563563 CmdArgs.push_back (" --sycl-link" );
564564 CmdArgs.append (
565565 {" -Xlinker" , Args.MakeArgString (" -triple=" + Triple.getTriple ())});
@@ -580,7 +580,7 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args,
580580
581581Expected<StringRef> linkDevice (ArrayRef<StringRef> InputFiles,
582582 const ArgList &Args,
583- bool HasSYCLOffloadKind = false ) {
583+ uint16_t ActiveOffloadKindMask ) {
584584 const llvm::Triple Triple (Args.getLastArgValue (OPT_triple_EQ));
585585 switch (Triple.getArch ()) {
586586 case Triple::nvptx:
@@ -595,7 +595,7 @@ Expected<StringRef> linkDevice(ArrayRef<StringRef> InputFiles,
595595 case Triple::spirv64:
596596 case Triple::systemz:
597597 case Triple::loongarch64:
598- return generic::clang (InputFiles, Args, HasSYCLOffloadKind );
598+ return generic::clang (InputFiles, Args, ActiveOffloadKindMask );
599599 default :
600600 return createStringError (Triple.getArchName () +
601601 " linking is not supported" );
@@ -949,9 +949,13 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
949949 InputFiles.emplace_back (*FileNameOrErr);
950950 }
951951
952+ // Currently, SYCL device code linking process differs from generic device
953+ // code linking.
954+ // TODO: Align SYCL device code linking with generic linking.
952955 if (ActiveOffloadKindMask & OFK_SYCL) {
953956 // Link the remaining device files using the device linker.
954- auto OutputOrErr = linkDevice (InputFiles, LinkerArgs, HasSYCLOffloadKind);
957+ auto OutputOrErr =
958+ linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
955959 if (!OutputOrErr)
956960 return OutputOrErr.takeError ();
957961 // Output is a packaged object of device images. Unpackage the images and
@@ -978,11 +982,12 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles(
978982 }
979983
980984 // Exit early if no other offload kind found (other than OFK_SYCL).
981- if ((ActiveOffloadKindMask ^ OFK_SYCL) == 0 ) {
985+ if ((ActiveOffloadKindMask ^ OFK_SYCL) == 0 )
982986 return Error::success ();
983987
984988 // Link the remaining device files using the device linker.
985- auto OutputOrErr = linkDevice (InputFiles, LinkerArgs);
989+ auto OutputOrErr =
990+ linkDevice (InputFiles, LinkerArgs, ActiveOffloadKindMask);
986991 if (!OutputOrErr)
987992 return OutputOrErr.takeError ();
988993
0 commit comments