@@ -3613,6 +3613,9 @@ class OffloadingActionBuilder final {
36133613 // / List of objects to extract FPGA dependency info from
36143614 ActionList FPGAObjectInputs;
36153615
3616+ // / List of static archives to extract FPGA dependency info from
3617+ ActionList FPGAArchiveInputs;
3618+
36163619 // / List of CUDA architectures to use in this compilation with NVPTX targets.
36173620 SmallVector<CudaArch, 8 > GpuArchList;
36183621
@@ -4061,15 +4064,19 @@ class OffloadingActionBuilder final {
40614064 // triple calls for it (provided a valid subarch).
40624065 ActionList BEInputs;
40634066 BEInputs.push_back (BuildCodeAction);
4064- for (Action *A : FPGAObjectInputs) {
4065- // Send any known objects through the unbundler to grab the
4066- // dependency file associated.
4067+ auto unbundleAdd = [&](Action *A, types::ID T) {
40674068 ActionList AL;
40684069 AL.push_back (A);
4069- Action *UnbundleAction = C. MakeAction <OffloadUnbundlingJobAction>(
4070- AL, types::TY_FPGA_Dependencies );
4070+ Action *UnbundleAction =
4071+ C. MakeAction <OffloadUnbundlingJobAction>( AL, T );
40714072 BEInputs.push_back (UnbundleAction);
4072- }
4073+ };
4074+ // Send any known objects/archives through the unbundler to grab the
4075+ // dependency file associated.
4076+ for (Action *A : FPGAObjectInputs)
4077+ unbundleAdd (A, types::TY_FPGA_Dependencies);
4078+ for (Action *A : FPGAArchiveInputs)
4079+ unbundleAdd (A, types::TY_FPGA_Dependencies_List);
40734080 for (const auto &A : DeviceLibObjects)
40744081 BEInputs.push_back (A);
40754082 BuildCodeAction =
@@ -4194,6 +4201,7 @@ class OffloadingActionBuilder final {
41944201 Arg *SYCLAddTargets = Args.getLastArg (options::OPT_fsycl_add_targets_EQ);
41954202 bool HasValidSYCLRuntime = C.getInputArgs ().hasFlag (options::OPT_fsycl,
41964203 options::OPT_fno_sycl, false );
4204+ bool SYCLfpgaTriple = false ;
41974205 if (SYCLTargets || SYCLAddTargets) {
41984206 if (SYCLTargets) {
41994207 llvm::StringMap<StringRef> FoundNormalizedTriples;
@@ -4211,6 +4219,8 @@ class OffloadingActionBuilder final {
42114219 FoundNormalizedTriples[NormalizedName] = Val;
42124220
42134221 SYCLTripleList.push_back (TT);
4222+ if (TT.getSubArch () == llvm::Triple::SPIRSubArch_fpga)
4223+ SYCLfpgaTriple = true ;
42144224 }
42154225 }
42164226 if (SYCLAddTargets) {
@@ -4234,13 +4244,30 @@ class OffloadingActionBuilder final {
42344244 const char *SYCLTargetArch = SYCLfpga ? " spir64_fpga" : " spir64" ;
42354245 SYCLTripleList.push_back (
42364246 C.getDriver ().MakeSYCLDeviceTriple (SYCLTargetArch));
4247+ if (SYCLfpga)
4248+ SYCLfpgaTriple = true ;
42374249 }
42384250
42394251 // Set the FPGA output type based on command line (-fsycl-link).
42404252 if (auto * A = C.getInputArgs ().getLastArg (options::OPT_fsycl_link_EQ))
42414253 FPGAOutType = (A->getValue () == StringRef (" early" ))
42424254 ? types::TY_FPGA_AOCR : types::TY_FPGA_AOCX;
42434255
4256+ // Populate FPGA static archives that could contain dep files to be
4257+ // incorporated into the aoc compilation
4258+ if (SYCLfpgaTriple) {
4259+ SmallVector<const char *, 16 > LinkArgs (getLinkerArgs (C, Args));
4260+ for (const StringRef &LA : LinkArgs) {
4261+ if (isStaticArchiveFile (LA) && hasOffloadSections (C, LA, Args)) {
4262+ const llvm::opt::OptTable &Opts = C.getDriver ().getOpts ();
4263+ Arg *InputArg = MakeInputArg (Args, Opts, Args.MakeArgString (LA));
4264+ Action *Current =
4265+ C.MakeAction <InputAction>(*InputArg, types::TY_Archive);
4266+ FPGAArchiveInputs.push_back (Current);
4267+ }
4268+ }
4269+ }
4270+
42444271 DeviceLinkerInputs.resize (ToolChains.size ());
42454272 return initializeGpuArchMap ();
42464273 }
@@ -5976,12 +6003,14 @@ InputInfo Driver::BuildJobsForActionNoCache(
59766003 // Do a check for a dependency file unbundle for FPGA. This is out of line
59776004 // from a regular unbundle, so just create and return the name of the
59786005 // unbundled file.
5979- if (JA->getType () == types::TY_FPGA_Dependencies) {
6006+ if (JA->getType () == types::TY_FPGA_Dependencies ||
6007+ JA->getType () == types::TY_FPGA_Dependencies_List) {
6008+ std::string Ext (types::getTypeTempSuffix (JA->getType ()));
59806009 std::string TmpFileName =
5981- C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), " d " );
6010+ C.getDriver ().GetTemporaryPath (llvm::sys::path::stem (BaseInput), Ext );
59826011 const char *TmpFile =
59836012 C.addTempFile (C.getArgs ().MakeArgString (TmpFileName));
5984- Result = InputInfo (types::TY_FPGA_Dependencies , TmpFile, TmpFile);
6013+ Result = InputInfo (JA-> getType () , TmpFile, TmpFile);
59856014 UnbundlingResults.push_back (Result);
59866015 } else {
59876016 // Now that we have all the results generated, select the one that should
0 commit comments