================
@@ -187,26 +189,59 @@ static Error executeCommands(StringRef ExecutablePath,
return Error::success();
}
-static Expected<SmallVector<std::string>> getInput(const ArgList &Args) {
- // Collect all input bitcode files to be passed to the linking stage.
- SmallVector<std::string> BitcodeFiles;
- auto Inputs = Args.filtered(OPT_INPUT);
- if (Inputs.empty())
- return createStringError("No input files provided");
- for (const opt::Arg *Arg : Inputs) {
- StringRef Filename = Arg->getValue();
- if (!sys::fs::exists(Filename) || sys::fs::is_directory(Filename))
- return createStringError("Input file '" + Filename + "' does not exist");
- file_magic Magic;
- if (auto EC = identify_magic(Filename, Magic))
- return createStringError("Failed to open file " + Filename);
- // TODO: Current use case involves LLVM IR bitcode files as input.
- // This will be extended to support SPIR-V IR files.
- if (Magic != file_magic::bitcode)
- return createStringError("Unsupported file type for '" + Filename + "'");
- BitcodeFiles.push_back(std::string(Filename));
+static Expected<SmallVector<std::unique_ptr<MemoryBuffer>>>
+getInput(const ArgList &Args) {
+ // Build input descriptors for the shared archive resolver
+ SmallVector<offloading::InputDesc> InputDescs;
+ bool WholeArchive = false;
+ for (const opt::Arg *Arg : Args.filtered(
+ OPT_INPUT, OPT_library, OPT_whole_archive, OPT_no_whole_archive)) {
+ if (Arg->getOption().matches(OPT_whole_archive) ||
+ Arg->getOption().matches(OPT_no_whole_archive)) {
+ WholeArchive = Arg->getOption().matches(OPT_whole_archive);
+ continue;
+ }
+
+ offloading::InputDesc Desc;
+ Desc.Value = Arg->getValue();
+ Desc.Kind = Arg->getOption().matches(OPT_library)
+ ? offloading::InputDesc::Library
+ : offloading::InputDesc::File;
+ Desc.WholeArchive = WholeArchive;
+ InputDescs.push_back(Desc);
}
- return BitcodeFiles;
+
+ if (InputDescs.empty())
+ return createStringError(inconvertibleErrorCode(),
+ "No input files provided");
+
+ // Gather search paths and forced undefined symbols
+ SmallVector<StringRef> LibraryPaths;
+ for (const opt::Arg *Arg : Args.filtered(OPT_library_path))
+ LibraryPaths.push_back(Arg->getValue());
+
+ std::vector<std::string> ForcedUndefStorage = Args.getAllArgValues(OPT_u);
+ SmallVector<StringRef> ForcedUndefs(ForcedUndefStorage.begin(),
+ ForcedUndefStorage.end());
+
+ // Build the Inputs structure
+ offloading::Inputs Inputs;
+ Inputs.Order = InputDescs;
+ Inputs.SearchPaths = LibraryPaths;
+ Inputs.ForcedUndefs = ForcedUndefs;
+ Inputs.Root = "";
+
+ // Resolve archive members (no fat binary predicate for SYCL)
+ Expected<offloading::ResolvedInputs> ResolvedOrErr =
+ offloading::resolveArchiveMembers(Inputs);
+ if (!ResolvedOrErr)
+ return ResolvedOrErr.takeError();
+
+ if (ResolvedOrErr->Buffers.empty())
+ return createStringError(inconvertibleErrorCode(),
+ "No input files could be resolved");
----------------
bader wrote:
Added in c34b9a6a9b92eec6b7ab85086fb3736b0b1c8efe.
https://github.com/llvm/llvm-project/pull/201253
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits