Skip to content

Commit 360b25b

Browse files
authored
[SYCL][Driver] -foffload-static-lib improvements when no source is given (#1072)
Provides improvements to behaviors of -foffload-static-lib when no source or object file is also provided on the command line. - Adds new -foffload-whole-static-lib option that is similar to -foffload-static-lib, except during the partial linkage stage. That is where the whole-archive is used to preserve all items in the archive before being unbundled. - Adds the arguments to -foffload-static-lib to be considered as true inputs to the compiler. This triggers proper link steps on the offload side as well as places the library directly on the link. - Moves the static-lib tests into a static-lib specific test Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 933e3eb commit 360b25b

File tree

15 files changed

+307
-209
lines changed

15 files changed

+307
-209
lines changed

clang/include/clang/Driver/Action.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ class OffloadUnbundlingJobAction final : public JobAction {
613613

614614
public:
615615
// Offloading unbundling doesn't change the type of output.
616-
OffloadUnbundlingJobAction(ActionList &Inputs);
616+
OffloadUnbundlingJobAction(Action *Input);
617+
OffloadUnbundlingJobAction(ActionList &Inputs, types::ID Type);
617618

618619
/// Register information about a dependent action.
619620
void registerDependentActionInfo(const ToolChain *TC, StringRef BoundArch,

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ def u_Group : OptionGroup<"<u group>">, Group<Link_Group>, DocFlatten;
197197
def reserved_lib_Group : OptionGroup<"<reserved libs group>">,
198198
Flags<[Unsupported]>;
199199

200+
def offload_lib_Group : OptionGroup<"<offload libs group>">;
201+
200202
// Temporary groups for clang options which we know we don't support,
201203
// but don't want to verbosely warn the user about.
202204
def clang_ignored_f_Group : OptionGroup<"<clang ignored f group>">,
@@ -1674,7 +1676,8 @@ def fobjc_nonfragile_abi : Flag<["-"], "fobjc-nonfragile-abi">, Group<f_Group>;
16741676
def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, Group<f_Group>;
16751677

16761678
def fobjc_sender_dependent_dispatch : Flag<["-"], "fobjc-sender-dependent-dispatch">, Group<f_Group>;
1677-
def foffload_static_lib_EQ : CommaJoined<["-"], "foffload-static-lib=">, Flags<[DriverOption, CoreOption]>;
1679+
def foffload_static_lib_EQ : CommaJoined<["-"], "foffload-static-lib=">, Flags<[DriverOption, CoreOption]>, Group<offload_lib_Group>;
1680+
def foffload_whole_static_lib_EQ : CommaJoined<["-"], "foffload-whole-static-lib=">, Flags<[DriverOption, CoreOption]>, Group<offload_lib_Group>;
16781681
def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;
16791682
def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
16801683
HelpText<"Parse OpenMP pragmas and generate parallel code.">;

clang/include/clang/Driver/Types.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ TYPE("tempfilelist", Tempfilelist, INVALID, "txt", phases
106106
TYPE("tempentriesfilelist", TempEntriesfilelist, INVALID, "txt", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
107107
TYPE("tempAOCOfilelist", TempAOCOfilelist, INVALID, "txt", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
108108
TYPE("archive", Archive, INVALID, "a", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
109+
TYPE("wholearchive", WholeArchive, INVALID, "a", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
109110
TYPE("fpga_aocx", FPGA_AOCX, INVALID, "aocx", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
110111
TYPE("fpga_aocr", FPGA_AOCR, INVALID, "aocr", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
111112
TYPE("fpga_aoco", FPGA_AOCO, INVALID, "aoco", phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/include/clang/Driver/Types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ namespace types {
8484
/// isFPGA - Is this FPGA input.
8585
bool isFPGA(ID Id);
8686

87+
/// isArchive - Is this an archive input.
88+
bool isArchive(ID Id);
89+
8790
/// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
8891
bool isObjC(ID Id);
8992

clang/lib/Driver/Action.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,12 @@ OffloadBundlingJobAction::OffloadBundlingJobAction(ActionList &Inputs)
421421

422422
void OffloadUnbundlingJobAction::anchor() {}
423423

424-
OffloadUnbundlingJobAction::OffloadUnbundlingJobAction(ActionList &Inputs)
425-
: JobAction(OffloadUnbundlingJobClass, Inputs, Inputs.back()->getType()) {}
424+
OffloadUnbundlingJobAction::OffloadUnbundlingJobAction(Action *Input)
425+
: JobAction(OffloadUnbundlingJobClass, Input, Input->getType()) {}
426+
427+
OffloadUnbundlingJobAction::OffloadUnbundlingJobAction(ActionList &Inputs,
428+
types:: ID Type)
429+
: JobAction(OffloadUnbundlingJobClass, Inputs, Type) {}
426430

427431
void OffloadWrapperJobAction::anchor() {}
428432

clang/lib/Driver/Driver.cpp

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,14 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
24692469
Diag(diag::note_use_dashdash);
24702470
}
24712471
}
2472+
else if (A->getOption().matches(options::OPT_offload_lib_Group)) {
2473+
// Add the foffload-static-lib library to the command line to allow
2474+
// processing when no source or object is supplied as well as proper
2475+
// host link.
2476+
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
2477+
Inputs.push_back(std::make_pair(types::TY_Object, InputArg));
2478+
A->claim();
2479+
}
24722480
}
24732481
if (CCCIsCPP() && Inputs.empty()) {
24742482
// If called as standalone preprocessor, stdin is processed
@@ -3336,7 +3344,7 @@ class OffloadingActionBuilder final {
33363344

33373345
std::string InputName = IA->getInputArg().getAsString(Args);
33383346
// Objects should already be consumed with -foffload-static-lib
3339-
if (Args.hasArg(options::OPT_foffload_static_lib_EQ) &&
3347+
if (Args.hasArg(options::OPT_offload_lib_Group) &&
33403348
IA->getType() == types::TY_Object && isObjectFile(InputName))
33413349
return ABRT_Inactive;
33423350

@@ -3870,7 +3878,7 @@ class OffloadingActionBuilder final {
38703878
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() ||
38713879
!(HostAction->getType() == types::TY_Object &&
38723880
isObjectFile(InputName) &&
3873-
Args.hasArg(options::OPT_foffload_static_lib_EQ))) {
3881+
Args.hasArg(options::OPT_offload_lib_Group))) {
38743882
ActionList HostActionList;
38753883
Action *A(HostAction);
38763884
// Only check for FPGA device information when using fpga SubArch.
@@ -3887,15 +3895,11 @@ class OffloadingActionBuilder final {
38873895
else if (hasFPGABinary(C, InputName, types::TY_FPGA_AOCR))
38883896
A = C.MakeAction<InputAction>(*InputArg, types::TY_FPGA_AOCR);
38893897
}
3890-
HostActionList.push_back(A);
3891-
if (!HostActionList.empty()) {
3892-
auto UnbundlingHostAction =
3893-
C.MakeAction<OffloadUnbundlingJobAction>(HostActionList);
3894-
UnbundlingHostAction->registerDependentActionInfo(
3898+
auto UnbundlingHostAction = C.MakeAction<OffloadUnbundlingJobAction>(A);
3899+
UnbundlingHostAction->registerDependentActionInfo(
38953900
C.getSingleOffloadToolChain<Action::OFK_Host>(),
38963901
/*BoundArch=*/StringRef(), Action::OFK_Host);
3897-
HostAction = UnbundlingHostAction;
3898-
}
3902+
HostAction = UnbundlingHostAction;
38993903
}
39003904
}
39013905

@@ -3945,11 +3949,11 @@ class OffloadingActionBuilder final {
39453949
if (!IsValid || InputActionList.empty())
39463950
return true;
39473951

3948-
auto *DeviceUnbundlingAction =
3949-
C.MakeAction<OffloadUnbundlingJobAction>(InputActionList);
3952+
auto *DeviceUnbundlingAction = C.MakeAction<OffloadUnbundlingJobAction>(
3953+
InputActionList, types::TY_Object);
39503954
DeviceUnbundlingAction->registerDependentActionInfo(
3951-
C.getSingleOffloadToolChain<Action::OFK_Host>(),
3952-
/*BoundArch=*/StringRef(), Action::OFK_Host);
3955+
C.getSingleOffloadToolChain<Action::OFK_Host>(),
3956+
/*BoundArch=*/StringRef(), Action::OFK_Host);
39533957
HostAction = DeviceUnbundlingAction;
39543958

39553959
// Register the offload kinds that are used.
@@ -4357,59 +4361,69 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
43574361
// When a static fat archive is provided, create a new unbundling step
43584362
// for all of the objects.
43594363
if (!C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() &&
4360-
Args.hasArg(options::OPT_foffload_static_lib_EQ) &&
4361-
!LinkerInputs.empty()) {
4364+
Args.hasArg(options::OPT_offload_lib_Group)) {
43624365
ActionList UnbundlerInputs;
4363-
ActionList TempLinkerInputs;
43644366
for (const auto &LI : LinkerInputs) {
43654367
// Unbundler only handles objects.
43664368
if (auto *IA = dyn_cast<InputAction>(LI)) {
43674369
std::string FileName = IA->getInputArg().getAsString(Args);
43684370
if ((IA->getType() == types::TY_Object && !isObjectFile(FileName)) ||
43694371
IA->getInputArg().getOption().hasFlag(options::LinkerInput))
4370-
// Pass the Input along to linker.
4371-
TempLinkerInputs.push_back(LI);
4372-
else
4373-
// Add to unbundler.
4374-
UnbundlerInputs.push_back(LI);
4375-
} else
4372+
// Pass the Input along to linker only.
4373+
continue;
43764374
UnbundlerInputs.push_back(LI);
4375+
}
43774376
}
4378-
LinkerInputs.clear();
4377+
const Arg *LastArg;
4378+
auto addUnbundlerInput = [&](types::ID T, const Arg *A) {
4379+
const llvm::opt::OptTable &Opts = getOpts();
4380+
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
4381+
LastArg = InputArg;
4382+
Action *Current = C.MakeAction<InputAction>(*InputArg, T);
4383+
UnbundlerInputs.push_back(Current);
4384+
};
4385+
for (const auto *A : Args.filtered(options::OPT_foffload_static_lib_EQ))
4386+
addUnbundlerInput(types::TY_Archive, A);
4387+
for (const auto *A :
4388+
Args.filtered(options::OPT_foffload_whole_static_lib_EQ))
4389+
addUnbundlerInput(types::TY_WholeArchive, A);
43794390
if (!UnbundlerInputs.empty()) {
4380-
Action *Current;
4381-
const Arg *LastArg = Args.getLastArg(options::OPT_foffload_static_lib_EQ);
4391+
Action *Current = C.MakeAction<InputAction>(*LastArg, types::TY_Archive);
43824392
OffloadBuilder.addHostDependenceToUnbundlingAction(Current,
4383-
UnbundlerInputs, LastArg);
4393+
UnbundlerInputs, LastArg);
43844394
Current = OffloadBuilder.addDeviceDependencesToHostAction(Current,
4385-
LastArg, phases::Link, PL.back(), PL);
4386-
LinkerInputs.push_back(Current);
4395+
LastArg, phases::Link, PL.back(), PL);
43874396
}
4388-
for (const auto &TLI : TempLinkerInputs)
4389-
LinkerInputs.push_back(TLI);
43904397
}
43914398
const llvm::opt::OptTable &Opts = getOpts();
4399+
auto unbundleStaticLib = [&](types::ID T, const Arg *A) {
4400+
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
4401+
Action *Current = C.MakeAction<InputAction>(*InputArg, T);
4402+
OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg, Args);
4403+
OffloadBuilder.addDeviceDependencesToHostAction(
4404+
Current, InputArg, phases::Link, PL.back(), PL);
4405+
};
43924406
for (const auto *A : Args.filtered(options::OPT_foffload_static_lib_EQ)) {
4393-
auto unbundleStaticLib = [&](types::ID T) {
4394-
Arg *InputArg = MakeInputArg(Args, Opts, A->getValue());
4395-
Action *Current = C.MakeAction<InputAction>(*InputArg, T);
4396-
OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg, Args);
4397-
OffloadBuilder.addDeviceDependencesToHostAction(
4398-
Current, InputArg, phases::Link, PL.back(), PL);
4399-
};
44004407
// In MSVC environment offload-static-libs are handled slightly different
44014408
// because of missing support for partial linking in the linker. We add an
44024409
// unbundling action for each static archive which produces list files with
44034410
// extracted objects. Device lists are then added to the appropriate device
44044411
// link actions and host list is ignored since we are adding
44054412
// offload-static-libs as normal libraries to the host link command.
44064413
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment())
4407-
unbundleStaticLib(types::TY_Archive);
4414+
unbundleStaticLib(types::TY_Archive, A);
44084415
// Pass along the -foffload-static-lib values to check if we need to
44094416
// add them for unbundling for FPGA AOT static lib usage. Uses FPGA
44104417
// aoco type to differentiate if aoco unbundling is needed.
44114418
if (Args.hasArg(options::OPT_fintelfpga))
4412-
unbundleStaticLib(types::TY_FPGA_AOCO);
4419+
unbundleStaticLib(types::TY_FPGA_AOCO, A);
4420+
}
4421+
for (const auto *A :
4422+
Args.filtered(options::OPT_foffload_whole_static_lib_EQ)) {
4423+
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment())
4424+
unbundleStaticLib(types::TY_WholeArchive, A);
4425+
if (Args.hasArg(options::OPT_fintelfpga))
4426+
unbundleStaticLib(types::TY_FPGA_AOCO, A);
44134427
}
44144428

44154429
// For an FPGA archive, we add the unbundling step above to take care of
@@ -5282,13 +5296,11 @@ InputInfo Driver::BuildJobsForActionNoCache(
52825296
bool IsFPGAObjLink = (JA->getType() == types::TY_Object &&
52835297
C.getInputArgs().hasArg(options::OPT_fintelfpga) &&
52845298
C.getInputArgs().hasArg(options::OPT_fsycl_link_EQ));
5285-
if (C.getInputArgs().hasArg(options::OPT_foffload_static_lib_EQ) &&
5299+
if (C.getInputArgs().hasArg(options::OPT_offload_lib_Group) &&
52865300
((JA->getType() == types::TY_Archive && IsMSVCEnv) ||
5287-
(UI.DependentOffloadKind != Action::OFK_Host &&
5288-
(JA->getType() == types::TY_Object && !IsMSVCEnv)))) {
5301+
(JA->getType() == types::TY_Object && !IsMSVCEnv))) {
52895302
// Host part of the unbundled static archive is not used.
5290-
if (UI.DependentOffloadKind == Action::OFK_Host &&
5291-
JA->getType() == types::TY_Archive && IsMSVCEnv)
5303+
if (UI.DependentOffloadKind == Action::OFK_Host)
52925304
continue;
52935305
// Host part of the unbundled object when -fintelfpga -fsycl-link is
52945306
// enabled is not used

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7080,14 +7080,17 @@ void OffloadBundler::ConstructJobMultipleOutputs(
70807080
InputInfo Input = Inputs.front();
70817081
const char *TypeArg = types::getTypeTempSuffix(Input.getType());
70827082
const char *InputFileName = Input.getFilename();
7083+
bool IsMSVCEnv =
7084+
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
7085+
types::ID InputType(Input.getType());
70837086

7084-
// For objects, we have initial support for fat archives (archives which
7087+
// For Linux, we have initial support for fat archives (archives which
70857088
// contain bundled objects). We will perform partial linking against the
7086-
// object and specific offload target archives which will be sent to the
7087-
// unbundler to produce a list of target objects.
7088-
if (!C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() &&
7089-
Input.getType() == types::TY_Object &&
7090-
TCArgs.hasArg(options::OPT_foffload_static_lib_EQ)) {
7089+
// specific offload target archives which will be sent to the unbundler to
7090+
// produce a list of target objects.
7091+
// FIXME: This should be a separate job in the toolchain.
7092+
if (!IsMSVCEnv && TCArgs.hasArg(options::OPT_offload_lib_Group) &&
7093+
(types::isArchive(InputType) || InputType == types::TY_Object)) {
70917094
TypeArg = "oo";
70927095
ArgStringList LinkArgs;
70937096
LinkArgs.push_back("-r");
@@ -7097,28 +7100,47 @@ void OffloadBundler::ConstructJobMultipleOutputs(
70977100
llvm::sys::path::stem(Input.getFilename()).str() + "-prelink", "o");
70987101
InputFileName = C.addTempFile(C.getArgs().MakeArgString(TmpName));
70997102
LinkArgs.push_back(InputFileName);
7100-
// Input files consist of fat libraries and the object(s) to be unbundled.
7101-
for (const auto &I : Inputs)
7102-
LinkArgs.push_back(I.getFilename());
7103+
const ToolChain *HTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
7104+
// Add crt objects
7105+
LinkArgs.push_back(TCArgs.MakeArgString(HTC->GetFilePath("crt1.o")));
7106+
LinkArgs.push_back(TCArgs.MakeArgString(HTC->GetFilePath("crti.o")));
71037107
// Add -L<dir> search directories.
71047108
TCArgs.AddAllArgs(LinkArgs, options::OPT_L);
7105-
for (const auto &A :
7106-
TCArgs.getAllArgValues(options::OPT_foffload_static_lib_EQ))
7107-
LinkArgs.push_back(TCArgs.MakeArgString(A));
7109+
7110+
// TODO - We can potentially go through the args and add the known linker
7111+
// pass through args of --whole-archive and --no-whole-archive. This
7112+
// would allow to support user commands like: -Wl,--whole-archive
7113+
// -foffload-static-lib=<lib> -Wl,--no-whole-archive
7114+
// Input files consist of fat libraries and the object(s) to be unbundled.
7115+
bool IsWholeArchive = false;
7116+
for (const auto &I : Inputs) {
7117+
if (I.getType() == types::TY_WholeArchive && !IsWholeArchive) {
7118+
LinkArgs.push_back("--whole-archive");
7119+
IsWholeArchive = true;
7120+
} else if (I.getType() == types::TY_Archive && IsWholeArchive) {
7121+
LinkArgs.push_back("--no-whole-archive");
7122+
IsWholeArchive = false;
7123+
}
7124+
LinkArgs.push_back(I.getFilename());
7125+
}
7126+
// Disable whole archive if it was enabled for the previous inputs.
7127+
if (IsWholeArchive)
7128+
LinkArgs.push_back("--no-whole-archive");
7129+
// Add crt objects
7130+
LinkArgs.push_back(TCArgs.MakeArgString(HTC->GetFilePath("crtn.o")));
71087131
const char *Exec = TCArgs.MakeArgString(getToolChain().GetLinkerPath());
71097132
C.addCommand(std::make_unique<Command>(JA, *this, Exec, LinkArgs, Inputs));
7110-
} else if (Input.getType() == types::TY_FPGA_AOCX ||
7111-
Input.getType() == types::TY_FPGA_AOCR) {
7133+
} else if (InputType == types::TY_FPGA_AOCX ||
7134+
InputType == types::TY_FPGA_AOCR) {
71127135
// Override type with archive object
71137136
if (getToolChain().getTriple().getSubArch() ==
71147137
llvm::Triple::SPIRSubArch_fpga)
71157138
TypeArg = "ao";
71167139
else
71177140
TypeArg = "aoo";
71187141
}
7119-
if (Input.getType() == types::TY_FPGA_AOCO ||
7120-
(C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() &&
7121-
Input.getType() == types::TY_Archive))
7142+
if (InputType == types::TY_FPGA_AOCO ||
7143+
(IsMSVCEnv && types::isArchive(InputType)))
71227144
TypeArg = "aoo";
71237145

71247146
// Get the type.
@@ -7133,12 +7155,12 @@ void OffloadBundler::ConstructJobMultipleOutputs(
71337155
// FPGA device triples are 'transformed' for the bundler when creating
71347156
// aocx or aocr type bundles. Also, we only do a specific target
71357157
// unbundling, skipping the host side or device side.
7136-
if (types::isFPGA(Input.getType())) {
7158+
if (types::isFPGA(InputType)) {
71377159
if (getToolChain().getTriple().getSubArch() ==
71387160
llvm::Triple::SPIRSubArch_fpga &&
71397161
Dep.DependentOffloadKind == Action::OFK_SYCL) {
71407162
llvm::Triple TT;
7141-
TT.setArchName(types::getTypeName(Input.getType()));
7163+
TT.setArchName(types::getTypeName(InputType));
71427164
TT.setVendorName("intel");
71437165
TT.setOS(getToolChain().getTriple().getOS());
71447166
TT.setEnvironment(llvm::Triple::SYCLDevice);
@@ -7152,10 +7174,10 @@ void OffloadBundler::ConstructJobMultipleOutputs(
71527174
Triples += Dep.DependentToolChain->getTriple().normalize();
71537175
}
71547176
continue;
7155-
} else if (Input.getType() == types::TY_Archive ||
7156-
(Input.getType() == types::TY_Object &&
7157-
TCArgs.hasArg(options::OPT_fintelfpga) &&
7158-
TCArgs.hasArg(options::OPT_fsycl_link_EQ))) {
7177+
} else if (types::isArchive(InputType) || (InputType == types::TY_Object &&
7178+
((!IsMSVCEnv && TCArgs.hasArg(options::OPT_offload_lib_Group)) ||
7179+
(TCArgs.hasArg(options::OPT_fintelfpga) &&
7180+
TCArgs.hasArg(options::OPT_fsycl_link_EQ))))) {
71597181
// Do not extract host part if we are unbundling archive on Windows
71607182
// because it is not needed. Static offload libraries are added to the
71617183
// host link command just as normal libraries. Do not extract the host

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
366366
for (const auto *A : Args.filtered(options::OPT_foffload_static_lib_EQ))
367367
CmdArgs.push_back(
368368
Args.MakeArgString(Twine("-defaultlib:") + A->getValue()));
369+
for (const auto *A : Args.filtered(options::OPT_foffload_whole_static_lib_EQ))
370+
CmdArgs.push_back(
371+
Args.MakeArgString(Twine("-wholearchive:") + A->getValue()));
369372

370373
if (!llvm::sys::Process::GetEnv("LIB")) {
371374
// If the VC environment hasn't been configured (perhaps because the user

clang/lib/Driver/Types.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ bool types::isFPGA(ID Id) {
235235
}
236236
}
237237

238+
bool types::isArchive(ID Id) {
239+
switch (Id) {
240+
default:
241+
return false;
242+
case TY_Archive:
243+
case TY_WholeArchive:
244+
return true;
245+
}
246+
}
247+
238248
bool types::isSrcFile(ID Id) {
239249
return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID;
240250
}

0 commit comments

Comments
 (0)