This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Reject bitcode which can't be parsed.
AbandonedPublic

Authored by efriedma on Oct 1 2020, 12:18 PM.

Details

Reviewers
MaskRay
Summary

If llvm-ar is older than the compiler that produced the bitcode, we should produce an error message, instead of silently generating a corrupt archive. This has, unfortunately, bit me multiple times now.

Doing this only for bitcode for now; I'm not confident that the "magic" detection in other cases is good enough to avoid compatibility issues in other cases, and other cases are much less likely to cause trouble anyway.

Diff Detail

Event Timeline

efriedma created this revision.Oct 1 2020, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 1 2020, 12:18 PM
efriedma requested review of this revision.Oct 1 2020, 12:18 PM

D88288 landed this morning. Does that work for you?

efriedma abandoned this revision.Oct 1 2020, 12:34 PM

Sure, that works. Thanks. :)

D88288 landed this morning. Does that work for you?

Sure, that works. Thanks. :)

The test coverage from printf "\xDE\xC0\x17\x0B" > %t.o (bitcode file, rather than an unknown file) may still be useful.

The test in D88288 does %python -c "with open('input.bc', 'a') as f: f.truncate(10)", which is essentially the same idea.