-
Notifications
You must be signed in to change notification settings - Fork 787
[Driver][SYCL] Remove partial-link path when dealing with fat static … #2867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bader
merged 2 commits into
intel:sycl
from
mdtoguchi:remove-partial-link-static-lib-linux
Dec 9, 2020
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4605,41 +4605,27 @@ class OffloadingActionBuilder final { | |||||
!InputArg->getOption().hasFlag(options::LinkerInput) && | ||||||
!types::isSrcFile(HostAction->getType())) { | ||||||
std::string InputName = InputArg->getAsString(Args); | ||||||
// Do not create an unbundling action for an object when we know a fat | ||||||
// static library is being used. A separate unbundling action is created | ||||||
// for all objects and the fat static library. | ||||||
// But in MSVC environment static offload archives are handled differently | ||||||
// due to absence of partial linking support in the linker. Instead of | ||||||
// partially linking input objects and static archives and then unbundling | ||||||
// result we are unbundling all objects and offload archives to extract | ||||||
// device parts. Therefore, in case on MSVC environment unbundling action | ||||||
// for objects is still needed. | ||||||
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() || | ||||||
ActionList HostActionList; | ||||||
Action *A(HostAction); | ||||||
// Only check for FPGA device information when using fpga SubArch. | ||||||
if (Args.hasArg(options::OPT_fintelfpga) && | ||||||
!(HostAction->getType() == types::TY_Object && | ||||||
isObjectFile(InputName) && | ||||||
C.getDriver().getOffloadStaticLibSeen())) { | ||||||
ActionList HostActionList; | ||||||
Action *A(HostAction); | ||||||
// Only check for FPGA device information when using fpga SubArch. | ||||||
if (Args.hasArg(options::OPT_fintelfpga) && | ||||||
!(HostAction->getType() == types::TY_Object && | ||||||
isObjectFile(InputName))) { | ||||||
// Type FPGA aoco is a special case for -foffload-static-lib. | ||||||
if (HostAction->getType() == types::TY_FPGA_AOCO) { | ||||||
if (!hasFPGABinary(C, InputName, types::TY_FPGA_AOCO)) | ||||||
return false; | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCO); | ||||||
} else if (hasFPGABinary(C, InputName, types::TY_FPGA_AOCX)) | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCX); | ||||||
else if (hasFPGABinary(C, InputName, types::TY_FPGA_AOCR)) | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCR); | ||||||
} | ||||||
auto UnbundlingHostAction = C.MakeAction<OffloadUnbundlingJobAction>(A); | ||||||
UnbundlingHostAction->registerDependentActionInfo( | ||||||
C.getSingleOffloadToolChain<Action::OFK_Host>(), | ||||||
/*BoundArch=*/StringRef(), Action::OFK_Host); | ||||||
HostAction = UnbundlingHostAction; | ||||||
isObjectFile(InputName))) { | ||||||
// Type FPGA aoco is a special case for -foffload-static-lib. | ||||||
if (HostAction->getType() == types::TY_FPGA_AOCO) { | ||||||
if (!hasFPGABinary(C, InputName, types::TY_FPGA_AOCO)) | ||||||
return false; | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCO); | ||||||
} else if (hasFPGABinary(C, InputName, types::TY_FPGA_AOCX)) | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCX); | ||||||
else if (hasFPGABinary(C, InputName, types::TY_FPGA_AOCR)) | ||||||
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCR); | ||||||
} | ||||||
auto UnbundlingHostAction = C.MakeAction<OffloadUnbundlingJobAction>(A); | ||||||
UnbundlingHostAction->registerDependentActionInfo( | ||||||
C.getSingleOffloadToolChain<Action::OFK_Host>(), | ||||||
/*BoundArch=*/StringRef(), Action::OFK_Host); | ||||||
HostAction = UnbundlingHostAction; | ||||||
} | ||||||
|
||||||
assert(HostAction && "Invalid host action!"); | ||||||
|
@@ -5096,84 +5082,9 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, | |||||
OffloadBuilder.appendTopLevelLinkAction(Actions); | ||||||
|
||||||
// Go through all of the args, and create a Linker specific argument list. | ||||||
// When dealing with fat static archives, this is fed into the partial link | ||||||
// step on Linux or each archive is individually addressed on Windows. | ||||||
// When dealing with fat static archives each archive is individually | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit town:
Suggested change
|
||||||
// unbundled. | ||||||
SmallVector<const char *, 16> LinkArgs(getLinkerArgs(C, Args)); | ||||||
// When a static fat archive is provided, create a new unbundling step | ||||||
// for all of the objects. | ||||||
if (!C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() && | ||||||
C.getDriver().getOffloadStaticLibSeen()) { | ||||||
ActionList UnbundlerInputs; | ||||||
for (const auto &LI : LinkerInputs) { | ||||||
// Unbundler only handles objects. | ||||||
if (auto *IA = dyn_cast<InputAction>(LI)) { | ||||||
std::string FileName = IA->getInputArg().getAsString(Args); | ||||||
if ((IA->getType() == types::TY_Object && !isObjectFile(FileName)) || | ||||||
IA->getInputArg().getOption().hasFlag(options::LinkerInput)) | ||||||
// Pass the Input along to linker only. | ||||||
continue; | ||||||
} | ||||||
UnbundlerInputs.push_back(LI); | ||||||
} | ||||||
const Arg *LastArg = nullptr; | ||||||
auto addUnbundlerInput = [&](types::ID T, const StringRef &A) { | ||||||
const llvm::opt::OptTable &Opts = getOpts(); | ||||||
Arg *InputArg = MakeInputArg(Args, Opts, C.getArgs().MakeArgString(A)); | ||||||
LastArg = InputArg; | ||||||
Action *Current = C.MakeAction<InputAction>(*InputArg, T); | ||||||
UnbundlerInputs.push_back(Current); | ||||||
}; | ||||||
bool IsWholeArchive = false; | ||||||
for (StringRef LA : LinkArgs) { | ||||||
if (isStaticArchiveFile(LA)) { | ||||||
addUnbundlerInput( | ||||||
IsWholeArchive ? types::TY_WholeArchive : types::TY_Archive, LA); | ||||||
continue; | ||||||
} | ||||||
if (optionMatches("-no-whole-archive", LA.str())) { | ||||||
IsWholeArchive = false; | ||||||
continue; | ||||||
} | ||||||
if (optionMatches("-whole-archive", LA.str())) { | ||||||
IsWholeArchive = true; | ||||||
continue; | ||||||
} | ||||||
if (isObjectFile(LA.str())) { | ||||||
// Add any objects to the unbundler step. These objects are passed | ||||||
// directly to the linker, so the driver does not know about them. | ||||||
// FIXME - Better process objects passed to the linker. We are only | ||||||
// adding these objects to the unbundler step, but these objects can | ||||||
// potentially be fat objects that should be processed by the driver. | ||||||
addUnbundlerInput(types::TY_Object, LA); | ||||||
continue; | ||||||
} | ||||||
} | ||||||
|
||||||
if (!UnbundlerInputs.empty() && !PL.empty()) { | ||||||
Action *PartialLink = | ||||||
C.MakeAction<PartialLinkJobAction>(UnbundlerInputs, types::TY_Object); | ||||||
if (!LastArg) { | ||||||
auto *TA = dyn_cast<Action>(UnbundlerInputs.back()); | ||||||
assert(TA->getKind() == Action::InputClass || | ||||||
TA->getKind() == Action::OffloadClass); | ||||||
|
||||||
// If the Action is of OffloadAction type, use the HostAction of the | ||||||
// specific Offload Action to set LastArg | ||||||
if (auto *OA = dyn_cast<OffloadAction>(UnbundlerInputs.back())) | ||||||
LastArg = | ||||||
&(dyn_cast<InputAction>(OA->getHostDependence())->getInputArg()); | ||||||
else if (auto *IA = dyn_cast<InputAction>(UnbundlerInputs.back())) | ||||||
// else set the LastArg based on Last InputAction | ||||||
LastArg = &(IA->getInputArg()); | ||||||
} | ||||||
Action *Current = C.MakeAction<InputAction>(*LastArg, types::TY_Object); | ||||||
ActionList AL; | ||||||
AL.push_back(PartialLink); | ||||||
OffloadBuilder.addHostDependenceToUnbundlingAction(Current, AL, LastArg); | ||||||
Current = OffloadBuilder.addDeviceDependencesToHostAction(Current, | ||||||
LastArg, phases::Link, PL.back(), PL); | ||||||
} | ||||||
} | ||||||
const llvm::opt::OptTable &Opts = getOpts(); | ||||||
auto unbundleStaticLib = [&](types::ID T, const StringRef &A) { | ||||||
Arg *InputArg = MakeInputArg(Args, Opts, Args.MakeArgString(A)); | ||||||
|
@@ -5191,14 +5102,12 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, | |||||
// as they have already been unbundled and processed for linking. | ||||||
if (hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCX)) | ||||||
continue; | ||||||
// In MSVC environment offload-static-libs are handled slightly different | ||||||
// because of missing support for partial linking in the linker. We add an | ||||||
// unbundling action for each static archive which produces list files with | ||||||
// extracted objects. Device lists are then added to the appropriate device | ||||||
// link actions and host list is ignored since we are adding | ||||||
// offload-static-libs as normal libraries to the host link command. | ||||||
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() && | ||||||
hasOffloadSections(C, LA, Args)) | ||||||
// For offload-static-libs we add an unbundling action for each static | ||||||
// archive which produces list files with extracted objects. Device lists | ||||||
// are then added to the appropriate device link actions and host list is | ||||||
// ignored since we are adding offload-static-libs as normal libraries to | ||||||
// the host link command. | ||||||
if (hasOffloadSections(C, LA, Args)) | ||||||
unbundleStaticLib(types::TY_Archive, LA); | ||||||
// Pass along the static libraries to check if we need to add them for | ||||||
// unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to | ||||||
|
@@ -6160,14 +6069,11 @@ InputInfo Driver::BuildJobsForActionNoCache( | |||||
// unbundling action does not change the type of the output which can | ||||||
// cause a overwrite. | ||||||
InputInfo CurI; | ||||||
bool IsMSVCEnv = | ||||||
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(); | ||||||
bool IsFPGAObjLink = (JA->getType() == types::TY_Object && | ||||||
C.getInputArgs().hasArg(options::OPT_fintelfpga) && | ||||||
C.getInputArgs().hasArg(options::OPT_fsycl_link_EQ)); | ||||||
if (C.getDriver().getOffloadStaticLibSeen() && | ||||||
(JA->getType() == types::TY_Archive || | ||||||
(JA->getType() == types::TY_Object && !IsMSVCEnv))) { | ||||||
JA->getType() == types::TY_Archive) { | ||||||
// Host part of the unbundled static archive is not used. | ||||||
if (UI.DependentOffloadKind == Action::OFK_Host) | ||||||
continue; | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.