[llvm] [llvm][object] Expose `writeArchiveToStream` (PR #98254)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 17:26:13 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: Jeff Niu (Mogball)
<details>
<summary>Changes</summary>
This internal helper is a useful API to have, when one wants to write an archive directly to some other preallocated stream.
---
Full diff: https://github.com/llvm/llvm-project/pull/98254.diff
2 Files Affected:
- (modified) llvm/include/llvm/Object/ArchiveWriter.h (+7)
- (modified) llvm/lib/Object/ArchiveWriter.cpp (+5-4)
``````````diff
diff --git a/llvm/include/llvm/Object/ArchiveWriter.h b/llvm/include/llvm/Object/ArchiveWriter.h
index a19f8fcc79d74..e41b3d51173d4 100644
--- a/llvm/include/llvm/Object/ArchiveWriter.h
+++ b/llvm/include/llvm/Object/ArchiveWriter.h
@@ -48,6 +48,13 @@ enum class SymtabWritingMode {
BigArchive64 // Only write the 64-bit symbol table.
};
+// Write an archive directly to an output stream.
+Error writeArchiveToStream(raw_ostream &Out,
+ ArrayRef<NewArchiveMember> NewMembers,
+ SymtabWritingMode WriteSymtab,
+ object::Archive::Kind Kind, bool Deterministic,
+ bool Thin, std::optional<bool> IsEC = std::nullopt);
+
Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
bool Deterministic, bool Thin,
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp
index 913b74c110b36..34f12cf0111cf 100644
--- a/llvm/lib/Object/ArchiveWriter.cpp
+++ b/llvm/lib/Object/ArchiveWriter.cpp
@@ -997,10 +997,11 @@ Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To) {
return std::string(Relative);
}
-static Error
-writeArchiveToStream(raw_ostream &Out, ArrayRef<NewArchiveMember> NewMembers,
- SymtabWritingMode WriteSymtab, object::Archive::Kind Kind,
- bool Deterministic, bool Thin, std::optional<bool> IsEC) {
+Error writeArchiveToStream(raw_ostream &Out,
+ ArrayRef<NewArchiveMember> NewMembers,
+ SymtabWritingMode WriteSymtab,
+ object::Archive::Kind Kind, bool Deterministic,
+ bool Thin, std::optional<bool> IsEC) {
assert((!Thin || !isBSDLike(Kind)) && "Only the gnu format has a thin mode");
SmallString<0> SymNamesBuf;
``````````
</details>
https://github.com/llvm/llvm-project/pull/98254
More information about the llvm-commits
mailing list