@@ -6786,13 +6786,10 @@ class OffloadingActionBuilder final {
67866786 // Do not use unbundler if the Host does not depend on device action.
67876787 // Now that we have unbundled the object, when doing -fsycl-link we
67886788 // want to continue the host link with the input object.
6789- // For unbundling of an FPGA AOCX binary, we want to link with the original
6790- // FPGA device archive.
67916789 if ((OffloadKind == Action::OFK_None && CanUseBundler) ||
67926790 (Args.hasArg (options::OPT_fsycl_link_EQ) && !HasFPGATarget) ||
67936791 (HasFPGATarget && ((Args.hasArg (options::OPT_fsycl_link_EQ) &&
6794- HostAction->getType () == types::TY_Object) ||
6795- HostAction->getType () == types::TY_FPGA_AOCX)))
6792+ HostAction->getType () == types::TY_Object))))
67966793 if (auto *UA = dyn_cast<OffloadUnbundlingJobAction>(HostAction))
67976794 HostAction = UA->getInputs ().back ();
67986795
@@ -7443,16 +7440,36 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
74437440
74447441 // For an FPGA archive, we add the unbundling step above to take care of
74457442 // the device side, but also unbundle here to extract the host side
7446- bool EarlyLink = false ;
7447- if (const Arg *A = Args.getLastArg (options::OPT_fsycl_link_EQ))
7448- EarlyLink = A->getValue () == StringRef (" early" );
74497443 for (auto &LI : LinkerInputs) {
74507444 Action *UnbundlerInput = nullptr ;
74517445 auto wrapObject = [&] {
7452- if (EarlyLink && Args.hasArg (options::OPT_fintelfpga)) {
7453- // Only wrap the object with -fsycl-link=early
7454- auto *BC = C.MakeAction <OffloadWrapperJobAction>(LI, types::TY_LLVM_BC);
7455- auto *ASM = C.MakeAction <BackendJobAction>(BC, types::TY_PP_Asm);
7446+ if (Args.hasArg (options::OPT_fsycl_link_EQ) &&
7447+ Args.hasArg (options::OPT_fintelfpga)) {
7448+ // Wrap the object when creating an FPGA AOCX or AOCR binary.
7449+ // When the input file is an AOCR (early) archive, the unbundled host
7450+ // binary consists of a list of objects. We cannot directly wrap that
7451+ // binary to be consumed later - this has to go through each listed
7452+ // object.
7453+ bool FPGAEarly = true ;
7454+ if (auto *A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
7455+ FPGAEarly = A->getValue () == StringRef (" early" );
7456+
7457+ Action *WrapperAction;
7458+ if ((LI->getType () == types::TY_FPGA_AOCR ||
7459+ LI->getType () == types::TY_FPGA_AOCR_EMU) &&
7460+ !FPGAEarly) {
7461+ auto *RenameAction = C.MakeAction <FileTableTformJobAction>(
7462+ LI, types::TY_Tempfilelist, types::TY_Tempfilelist);
7463+ RenameAction->addRenameColumnTform (FileTableTformJobAction::COL_ZERO,
7464+ FileTableTformJobAction::COL_CODE);
7465+ ActionList WrapperItems ({RenameAction});
7466+ WrapperAction = C.MakeAction <OffloadWrapperJobAction>(
7467+ WrapperItems, types::TY_LLVM_BC);
7468+ } else
7469+ WrapperAction =
7470+ C.MakeAction <OffloadWrapperJobAction>(LI, types::TY_LLVM_BC);
7471+ auto *ASM =
7472+ C.MakeAction <BackendJobAction>(WrapperAction, types::TY_PP_Asm);
74567473 auto *OBJ = C.MakeAction <AssembleJobAction>(ASM, types::TY_Object);
74577474 OffloadAction::HostDependence HDep (
74587475 *OBJ, *C.getSingleOffloadToolChain <Action::OFK_Host>(),
0 commit comments