================
@@ -341,6 +342,38 @@ static Expected<LinkResult>
linkInputs(ArrayRef<std::string> InputFiles,
// Link in library files.
for (auto &File : *BCLibFiles) {
+ // Static archives are unpacked and each bitcode member is linked
+ // individually with LinkOnlyNeeded.
+ StringRef Ext = sys::path::extension(File);
+ if (Ext == ".a" || Ext == ".lib") {
+ auto BufOrErr = MemoryBuffer::getFile(File);
+ if (std::error_code EC = BufOrErr.getError())
+ return createFileError(File, EC);
+ Expected<std::unique_ptr<object::Archive>> ArOrErr =
+ object::Archive::create((*BufOrErr)->getMemBufferRef());
+ if (!ArOrErr)
+ return ArOrErr.takeError();
+ Error ArErr = Error::success();
+ for (const auto &Child : (*ArOrErr)->children(ArErr)) {
+ Expected<MemoryBufferRef> MemOrErr = Child.getMemoryBufferRef();
+ if (!MemOrErr)
+ return MemOrErr.takeError();
+ SMDiagnostic D;
+ std::unique_ptr<Module> Mod = getLazyIRModule(
+ MemoryBuffer::getMemBuffer(*MemOrErr, /*RequiresNullTerm=*/false),
+ D, C);
+ if (!Mod) {
+ // Skip non-IR archive members (e.g. symbol index, ELF objects).
----------------
sarnex wrote:
if no other path of `clang-sycl-linker` will handle those members IMO we should
warn
https://github.com/llvm/llvm-project/pull/201253
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits