================
@@ -1162,6 +1281,54 @@ std::optional<std::string> searchLibrary(StringRef
Input, StringRef Root,
return searchLibraryBaseName(Input, Root, SearchPaths);
}
+/// In verbose mode we need to replay the extracted files so the user can
+/// reproduce the generated. This only prints the steps that would result in
the
+/// same output files given the input.
+Error emitExtractCommands(
+ ArrayRef<SmallVector<OffloadFile>> InputsForTarget,
+ const DenseMap<StringRef, StringRef> &SourceForImage) {
+ Expected<std::string> OffloadBinaryPath = findProgram(
+ "llvm-offload-binary", {getExecutableDir("llvm-offload-binary")});
+ if (!OffloadBinaryPath)
+ return OffloadBinaryPath.takeError();
+
+ BumpPtrAllocator Alloc;
+ StringSaver Saver(Alloc);
+ MapVector<StringRef, SmallVector<StringRef>> Commands;
+ DenseSet<StringRef> Seen;
+ for (const auto &Input : InputsForTarget) {
+ for (const OffloadFile &File : Input) {
+ const OffloadBinary &Binary = *File.getBinary();
+ StringRef Identifier = Binary.getMemoryBufferRef().getBufferIdentifier();
+ StringRef Source = SourceForImage.lookup(Identifier);
+ if (Source.empty())
+ Source = Identifier;
+
+ StringRef TripleStr = Binary.getTriple();
+ StringRef Arch = Binary.getArch();
+ StringRef Kind = getOffloadKindName(Binary.getOffloadKind());
+
+ std::string ImageArg =
----------------
yxsamliu wrote:
I think this replay command needs to specify the extracted output filename with
`file=...`. Without that, `llvm-offload-binary` chooses its default name, like
`input-triple-arch.0.o`, but the later printed `clang` command uses the
wrapper-created temp name, like `input-triple-arch.o`. Then the printed command
sequence cannot be copied and rerun as-is.
https://github.com/llvm/llvm-project/pull/204186
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits