This is an archive of the discontinued LLVM Phabricator instance.

Add support for thinlto option to emit import files for thinlink
ClosedPublic

Authored by rdhindsa on May 3 2018, 11:17 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

rdhindsa created this revision.May 3 2018, 11:17 AM
ruiu added inline comments.May 3 2018, 11:28 AM
lld/ELF/LTO.cpp
102 ↗(On Diff #145057)

I don't understand this part of code. I think OS will be closed at end of this if block, so I don't think you are writing anything to the file. Is this code correct?

rdhindsa added inline comments.May 3 2018, 12:27 PM
lld/ELF/LTO.cpp
102 ↗(On Diff #145057)

For all the bitcode files, empty import files are generated at first. For the files selected by the linker having summary, lto::createWriteIndexesThinBackend overwrites the imports files . However, for the files which are either not selected by linker or they don't have summary, we don't write anything to .imports file since they don't import anything. These files are required for distributed ThinLTO build file staging.

rdhindsa updated this revision to Diff 145084.May 3 2018, 1:25 PM

Added test to ensure that lld doesn't generate import files when thinlto-index-only is not enabled

ruiu added inline comments.May 3 2018, 1:30 PM
lld/ELF/LTO.cpp
105 ↗(On Diff #145084)

failed to write -> cannot open

for consistency with other error messages.

102 ↗(On Diff #145057)

Got it. Let's factor it out as a separate function

static void createEmptyFile(const Twine &Path);

that creates an empty file at a given path. That should make things clear.

rdhindsa updated this revision to Diff 145095.May 3 2018, 2:41 PM

Added createEmptyFile function to create empty import files. Also updated the test with error description.

I need to make similar change while creating empty index files, along with updating the description in test for it. I will add that change in next patch if that is okay.

rdhindsa marked 2 inline comments as done.May 3 2018, 3:02 PM

I will be sending another patch to address tejohnson's concerns. I think, in the meantime, we can add emit-imports option support. Or would you like me to send that patch first?

rdhindsa updated this revision to Diff 145558.May 7 2018, 3:01 PM

Rebased diff

ruiu accepted this revision.May 7 2018, 3:45 PM

I'm sorry but could you rebase again?

This revision is now accepted and ready to land.May 7 2018, 3:45 PM
rdhindsa updated this revision to Diff 145574.May 7 2018, 3:50 PM

Rebased the diff

ruiu added inline comments.May 7 2018, 4:06 PM
lld/ELF/LTO.cpp
173 ↗(On Diff #145574)

nit: remove {}

277 ↗(On Diff #145574)

OutputFileName seems a bit inaccurate as a variable name because it is not an output file name but a prefix. I'd just name Path.

287 ↗(On Diff #145574)

remove {}

rdhindsa updated this revision to Diff 145583.May 7 2018, 4:13 PM
rdhindsa marked 3 inline comments as done.
ruiu accepted this revision.May 7 2018, 4:14 PM

LGTM

This revision was automatically updated to reflect the committed changes.