@@ -4605,41 +4605,27 @@ class OffloadingActionBuilder final {
4605
4605
!InputArg->getOption ().hasFlag (options::LinkerInput) &&
4606
4606
!types::isSrcFile (HostAction->getType ())) {
4607
4607
std::string InputName = InputArg->getAsString (Args);
4608
- // Do not create an unbundling action for an object when we know a fat
4609
- // static library is being used. A separate unbundling action is created
4610
- // for all objects and the fat static library.
4611
- // But in MSVC environment static offload archives are handled differently
4612
- // due to absence of partial linking support in the linker. Instead of
4613
- // partially linking input objects and static archives and then unbundling
4614
- // result we are unbundling all objects and offload archives to extract
4615
- // device parts. Therefore, in case on MSVC environment unbundling action
4616
- // for objects is still needed.
4617
- if (C.getDefaultToolChain ().getTriple ().isWindowsMSVCEnvironment () ||
4608
+ ActionList HostActionList;
4609
+ Action *A (HostAction);
4610
+ // Only check for FPGA device information when using fpga SubArch.
4611
+ if (Args.hasArg (options::OPT_fintelfpga) &&
4618
4612
!(HostAction->getType () == types::TY_Object &&
4619
- isObjectFile (InputName) &&
4620
- C.getDriver ().getOffloadStaticLibSeen ())) {
4621
- ActionList HostActionList;
4622
- Action *A (HostAction);
4623
- // Only check for FPGA device information when using fpga SubArch.
4624
- if (Args.hasArg (options::OPT_fintelfpga) &&
4625
- !(HostAction->getType () == types::TY_Object &&
4626
- isObjectFile (InputName))) {
4627
- // Type FPGA aoco is a special case for -foffload-static-lib.
4628
- if (HostAction->getType () == types::TY_FPGA_AOCO) {
4629
- if (!hasFPGABinary (C, InputName, types::TY_FPGA_AOCO))
4630
- return false ;
4631
- A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCO);
4632
- } else if (hasFPGABinary (C, InputName, types::TY_FPGA_AOCX))
4633
- A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCX);
4634
- else if (hasFPGABinary (C, InputName, types::TY_FPGA_AOCR))
4635
- A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCR);
4636
- }
4637
- auto UnbundlingHostAction = C.MakeAction <OffloadUnbundlingJobAction>(A);
4638
- UnbundlingHostAction->registerDependentActionInfo (
4639
- C.getSingleOffloadToolChain <Action::OFK_Host>(),
4640
- /* BoundArch=*/ StringRef (), Action::OFK_Host);
4641
- HostAction = UnbundlingHostAction;
4613
+ isObjectFile (InputName))) {
4614
+ // Type FPGA aoco is a special case for -foffload-static-lib.
4615
+ if (HostAction->getType () == types::TY_FPGA_AOCO) {
4616
+ if (!hasFPGABinary (C, InputName, types::TY_FPGA_AOCO))
4617
+ return false ;
4618
+ A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCO);
4619
+ } else if (hasFPGABinary (C, InputName, types::TY_FPGA_AOCX))
4620
+ A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCX);
4621
+ else if (hasFPGABinary (C, InputName, types::TY_FPGA_AOCR))
4622
+ A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCR);
4642
4623
}
4624
+ auto UnbundlingHostAction = C.MakeAction <OffloadUnbundlingJobAction>(A);
4625
+ UnbundlingHostAction->registerDependentActionInfo (
4626
+ C.getSingleOffloadToolChain <Action::OFK_Host>(),
4627
+ /* BoundArch=*/ StringRef (), Action::OFK_Host);
4628
+ HostAction = UnbundlingHostAction;
4643
4629
}
4644
4630
4645
4631
assert (HostAction && " Invalid host action!" );
@@ -5096,84 +5082,9 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
5096
5082
OffloadBuilder.appendTopLevelLinkAction (Actions);
5097
5083
5098
5084
// Go through all of the args, and create a Linker specific argument list.
5099
- // When dealing with fat static archives, this is fed into the partial link
5100
- // step on Linux or each archive is individually addressed on Windows .
5085
+ // When dealing with fat static archives each archive is individually
5086
+ // unbundled .
5101
5087
SmallVector<const char *, 16 > LinkArgs (getLinkerArgs (C, Args));
5102
- // When a static fat archive is provided, create a new unbundling step
5103
- // for all of the objects.
5104
- if (!C.getDefaultToolChain ().getTriple ().isWindowsMSVCEnvironment () &&
5105
- C.getDriver ().getOffloadStaticLibSeen ()) {
5106
- ActionList UnbundlerInputs;
5107
- for (const auto &LI : LinkerInputs) {
5108
- // Unbundler only handles objects.
5109
- if (auto *IA = dyn_cast<InputAction>(LI)) {
5110
- std::string FileName = IA->getInputArg ().getAsString (Args);
5111
- if ((IA->getType () == types::TY_Object && !isObjectFile (FileName)) ||
5112
- IA->getInputArg ().getOption ().hasFlag (options::LinkerInput))
5113
- // Pass the Input along to linker only.
5114
- continue ;
5115
- }
5116
- UnbundlerInputs.push_back (LI);
5117
- }
5118
- const Arg *LastArg = nullptr ;
5119
- auto addUnbundlerInput = [&](types::ID T, const StringRef &A) {
5120
- const llvm::opt::OptTable &Opts = getOpts ();
5121
- Arg *InputArg = MakeInputArg (Args, Opts, C.getArgs ().MakeArgString (A));
5122
- LastArg = InputArg;
5123
- Action *Current = C.MakeAction <InputAction>(*InputArg, T);
5124
- UnbundlerInputs.push_back (Current);
5125
- };
5126
- bool IsWholeArchive = false ;
5127
- for (StringRef LA : LinkArgs) {
5128
- if (isStaticArchiveFile (LA)) {
5129
- addUnbundlerInput (
5130
- IsWholeArchive ? types::TY_WholeArchive : types::TY_Archive, LA);
5131
- continue ;
5132
- }
5133
- if (optionMatches (" -no-whole-archive" , LA.str ())) {
5134
- IsWholeArchive = false ;
5135
- continue ;
5136
- }
5137
- if (optionMatches (" -whole-archive" , LA.str ())) {
5138
- IsWholeArchive = true ;
5139
- continue ;
5140
- }
5141
- if (isObjectFile (LA.str ())) {
5142
- // Add any objects to the unbundler step. These objects are passed
5143
- // directly to the linker, so the driver does not know about them.
5144
- // FIXME - Better process objects passed to the linker. We are only
5145
- // adding these objects to the unbundler step, but these objects can
5146
- // potentially be fat objects that should be processed by the driver.
5147
- addUnbundlerInput (types::TY_Object, LA);
5148
- continue ;
5149
- }
5150
- }
5151
-
5152
- if (!UnbundlerInputs.empty () && !PL.empty ()) {
5153
- Action *PartialLink =
5154
- C.MakeAction <PartialLinkJobAction>(UnbundlerInputs, types::TY_Object);
5155
- if (!LastArg) {
5156
- auto *TA = dyn_cast<Action>(UnbundlerInputs.back ());
5157
- assert (TA->getKind () == Action::InputClass ||
5158
- TA->getKind () == Action::OffloadClass);
5159
-
5160
- // If the Action is of OffloadAction type, use the HostAction of the
5161
- // specific Offload Action to set LastArg
5162
- if (auto *OA = dyn_cast<OffloadAction>(UnbundlerInputs.back ()))
5163
- LastArg =
5164
- &(dyn_cast<InputAction>(OA->getHostDependence ())->getInputArg ());
5165
- else if (auto *IA = dyn_cast<InputAction>(UnbundlerInputs.back ()))
5166
- // else set the LastArg based on Last InputAction
5167
- LastArg = &(IA->getInputArg ());
5168
- }
5169
- Action *Current = C.MakeAction <InputAction>(*LastArg, types::TY_Object);
5170
- ActionList AL;
5171
- AL.push_back (PartialLink);
5172
- OffloadBuilder.addHostDependenceToUnbundlingAction (Current, AL, LastArg);
5173
- Current = OffloadBuilder.addDeviceDependencesToHostAction (Current,
5174
- LastArg, phases::Link, PL.back (), PL);
5175
- }
5176
- }
5177
5088
const llvm::opt::OptTable &Opts = getOpts ();
5178
5089
auto unbundleStaticLib = [&](types::ID T, const StringRef &A) {
5179
5090
Arg *InputArg = MakeInputArg (Args, Opts, Args.MakeArgString (A));
@@ -5191,14 +5102,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
5191
5102
// as they have already been unbundled and processed for linking.
5192
5103
if (hasFPGABinary (C, LA.str (), types::TY_FPGA_AOCX))
5193
5104
continue ;
5194
- // In MSVC environment offload-static-libs are handled slightly different
5195
- // because of missing support for partial linking in the linker. We add an
5196
- // unbundling action for each static archive which produces list files with
5197
- // extracted objects. Device lists are then added to the appropriate device
5198
- // link actions and host list is ignored since we are adding
5199
- // offload-static-libs as normal libraries to the host link command.
5200
- if (C.getDefaultToolChain ().getTriple ().isWindowsMSVCEnvironment () &&
5201
- hasOffloadSections (C, LA, Args))
5105
+ // For offload-static-libs we add an unbundling action for each static
5106
+ // archive which produces list files with extracted objects. Device lists
5107
+ // are then added to the appropriate device link actions and host list is
5108
+ // ignored since we are adding offload-static-libs as normal libraries to
5109
+ // the host link command.
5110
+ if (hasOffloadSections (C, LA, Args))
5202
5111
unbundleStaticLib (types::TY_Archive, LA);
5203
5112
// Pass along the static libraries to check if we need to add them for
5204
5113
// unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to
@@ -6160,14 +6069,11 @@ InputInfo Driver::BuildJobsForActionNoCache(
6160
6069
// unbundling action does not change the type of the output which can
6161
6070
// cause a overwrite.
6162
6071
InputInfo CurI;
6163
- bool IsMSVCEnv =
6164
- C.getDefaultToolChain ().getTriple ().isWindowsMSVCEnvironment ();
6165
6072
bool IsFPGAObjLink = (JA->getType () == types::TY_Object &&
6166
6073
C.getInputArgs ().hasArg (options::OPT_fintelfpga) &&
6167
6074
C.getInputArgs ().hasArg (options::OPT_fsycl_link_EQ));
6168
6075
if (C.getDriver ().getOffloadStaticLibSeen () &&
6169
- (JA->getType () == types::TY_Archive ||
6170
- (JA->getType () == types::TY_Object && !IsMSVCEnv))) {
6076
+ JA->getType () == types::TY_Archive) {
6171
6077
// Host part of the unbundled static archive is not used.
6172
6078
if (UI.DependentOffloadKind == Action::OFK_Host)
6173
6079
continue ;
0 commit comments