This is an archive of the discontinued LLVM Phabricator instance.

[llvm-lib] Add /WX, warn by default on empty inputs, add opt-out
ClosedPublic

Authored by thakis on Apr 11 2022, 8:07 AM.

Details

Summary

lib.exe by default exits successfully without writing an output
file when no inputs are passed. llvm-lib has the same behavior,
for compatibility.

This behavior interacts poorly with build systems: If a static
library target had no inputs, llvm-lib would not produce an output
file, causing ninja (or make, or a similar system) to successfully
run that step, but then re-run it on the next build.

After this patch, llvm-lib emits a warning in this case, that with
/WX can be turned into an error. That way, ninja (or make, or...)
will mark the initial build as failed.

People who don't like the warning can use /ignore:emptyoutput to
suppress it.

The warning also points out the existing flag /llvmlibempty which
forces creation of an empty .lib file (this is an extension to lib.exe).

Diff Detail

Event Timeline

thakis created this revision.Apr 11 2022, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 8:07 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
thakis requested review of this revision.Apr 11 2022, 8:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 8:07 AM
hans accepted this revision.Apr 11 2022, 9:07 AM

Nice!

Were there no other warnings that need to handle /ignore and /WX?

This revision is now accepted and ready to land.Apr 11 2022, 9:07 AM

Thanks!

Before this change, every diag that llvm-lib emitted was fatal. So this is the only diag that needs WX / ignore.

This revision was landed with ongoing or failed builds.Apr 11 2022, 10:15 AM
This revision was automatically updated to reflect the committed changes.