This is an archive of the discontinued LLVM Phabricator instance.

[Darwin] Use errorHandler from liblldCommon
ClosedPublic

Authored by modocache on Jun 10 2018, 7:05 PM.

Details

Summary

Error handling in liblldCore and the Darwin toolchain prints to an
output stream. A TODO in the project explained that a diagnostics
interface resembling Clang's should be added.

For now, the simple diagnostics interface defined in liblldCommon seems
like an improvement. It prints colors when they're available, uses locks
for thread-safety, and abstracts away the "error: " and newline
literal strings that litter the Darwin toolchain code.

To use the liblldCommon error handler, a link dependency is added to
the liblldDriver library.

Test Plan:

  1. check-lld
  2. Invoke ld64.lld -r in a terminal that supports color output. Confirm that "ld64.lld: error: -arch not specified and could not be inferred" is output, and that the "error:" is colored red!

Event Timeline

modocache created this revision.Jun 10 2018, 7:05 PM
modocache updated this revision to Diff 150765.Jun 11 2018, 8:11 AM

Oops! I fixed a typo in the error limit exceeded message.

smeenai resigned from this revision.Jun 11 2018, 12:29 PM

Makes sense to me, but I want @ruiu to look over it.

lib/Driver/DarwinLdDriver.cpp
327

Do you need the explicit Twine constructor calls?

ruiu accepted this revision.Jun 11 2018, 12:44 PM

LGTM

Thank you for doing this. Though we probably should discuss the future plan at some point, this seems like a pure improvement to me.

This revision is now accepted and ready to land.Jun 11 2018, 12:44 PM
modocache updated this revision to Diff 150879.Jun 11 2018, 7:08 PM

Thanks for the reviews! I'm updating this so that it no longer includes the warning I added in D47994. I'll commit in in a second.

This revision was automatically updated to reflect the committed changes.