[lld] lld: Add initial support for GNU LTO format (PR #157175)
Tulio Magno Quites Machado Filho via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 14 12:59:26 PDT 2025
================
@@ -29,32 +30,96 @@
namespace llvm::lto {
class LTO;
+struct SymbolResolution;
}
namespace lld::elf {
struct Ctx;
class BitcodeFile;
+class ELFFileBase;
class InputFile;
+class IRFile;
+class BinaryFile;
+
+class IRCompiler {
+protected:
+ Ctx &ctx;
+ llvm::DenseSet<StringRef> thinIndices;
+ llvm::DenseSet<StringRef> usedStartStop;
+ virtual void addObject(IRFile &f,
+ std::vector<llvm::lto::SymbolResolution> &r) = 0;
+
+public:
+ IRCompiler(Ctx &ctx) : ctx(ctx) {}
+ virtual ~IRCompiler() {};
+ void add(IRFile &f);
+ virtual SmallVector<std::unique_ptr<InputFile>, 0> compile() = 0;
+};
+
+class BitcodeCompiler : public IRCompiler {
+protected:
+ void addObject(IRFile &f,
+ std::vector<llvm::lto::SymbolResolution> &r) override;
-class BitcodeCompiler {
public:
BitcodeCompiler(Ctx &ctx);
- ~BitcodeCompiler();
+ ~BitcodeCompiler() {};
- void add(BitcodeFile &f);
- SmallVector<std::unique_ptr<InputFile>, 0> compile();
+ void add(BinaryFile &f);
+ SmallVector<std::unique_ptr<InputFile>, 0> compile() override;
private:
- Ctx &ctx;
std::unique_ptr<llvm::lto::LTO> ltoObj;
// An array of (module name, native relocatable file content) pairs.
SmallVector<std::pair<std::string, SmallString<0>>, 0> buf;
std::vector<std::unique_ptr<MemoryBuffer>> files;
SmallVector<std::string, 0> filenames;
- llvm::DenseSet<StringRef> usedStartStop;
std::unique_ptr<llvm::raw_fd_ostream> indexFile;
- llvm::DenseSet<StringRef> thinIndices;
};
+
+#if LLD_ENABLE_GNU_LTO
+#include <plugin-api.h>
----------------
tuliom wrote:
@tstellar Copying or re-implementing in the way that has been proposed here is not an issue if we keep things simple. In 2003, the FSF has already positioned themselves agreeing with this.
Furthermore, there is legal precedence on API usage in the Google vs. Oracle case.
The following post has a good summary on this discussion and links with more information:
https://softwareengineering.stackexchange.com/a/216480
https://github.com/llvm/llvm-project/pull/157175
More information about the llvm-commits
mailing list