This is an archive of the discontinued LLVM Phabricator instance.

Do not pass archive files containing non-native object files.
ClosedPublic

Authored by ruiu on Mar 16 2017, 1:41 PM.

Details

Summary

The MSVC linker doesn't like archive files containing non-native object
files.

When we are doing an LTO build, we may create archive files containing
both LLVM bitcode files and native object files. For example, if a
project contains assembly files and C++ files, we create native object
files for the assembly files and LLVM bitcode files for the C++ files.

With the /msvclto option, LLD passes archive files to the MSVC linker.
Previously, we didn't pass archive files if they contain at least one
bitcode files. That wasn't correct because the native object files that
weren't passed to the MSVC linker may be needed to complete linking.

In this patch, we create new temporary archive files to strip bitcode
files.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Mar 16 2017, 1:41 PM
pcc added inline comments.Mar 16 2017, 1:50 PM
lld/COFF/Driver.cpp
466 ↗(On Diff #92046)

I think you will need to rebuild the archive unconditionally if it is a thin archive because the MSVC linker won't understand thin archives.

ruiu updated this revision to Diff 92054.Mar 16 2017, 2:10 PM
  • Always rebuild an archive if it's a thin archive.
pcc accepted this revision.Mar 16 2017, 2:24 PM

LGTM

This revision is now accepted and ready to land.Mar 16 2017, 2:24 PM
This revision was automatically updated to reflect the committed changes.