This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] - Report "no zlib available" error properly when --compress-debug-sections is used.
ClosedPublic

Authored by grimar on Mar 4 2019, 8:13 AM.

Details

Summary

If zlib is not available, and --compress-debug-sections is passed,
we want to report an error. Currently, it is only reported for
--compress_debug_sections= form of the option.

Fixes the https://bugs.llvm.org/show_bug.cgi?id=40886.

I do not think there is a way to write a test for this.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Mar 4 2019, 8:13 AM

This is for llvm-objcopy, not llvm-objdump as claimed in the header and description, right?

Can you write a test that is UNSUPPORTED if zlib IS available?

grimar retitled this revision from [llvm-objdump] - Report "no zlib available" error properly when --compress-debug-sections is used. to [llvm-objcopy] - Report "no zlib available" error properly when --compress-debug-sections is used..Mar 4 2019, 10:00 AM
grimar added a comment.Mar 5 2019, 1:01 AM

Can you write a test that is UNSUPPORTED if zlib IS available?

I think we have such a test already. It is:
https://github.com/llvm-mirror/llvm/blob/master/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test
(It does not do # REQUIRES: zlib because code report the Invalid or unsupported --compress-debug-sections format error before zlib::isAvailable() check.
What looks fine to me.)

Can you write a test that is UNSUPPORTED if zlib IS available?

I think we have such a test already. It is:
https://github.com/llvm-mirror/llvm/blob/master/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test
(It does not do # REQUIRES: zlib because code report the Invalid or unsupported --compress-debug-sections format error before zlib::isAvailable() check.
What looks fine to me.)

That isn't the same test as I meant. That checks the error message at line 475, whereas I'm looking for a test for line 483. In other words, a valid compression format, but where zlib::isAvailable fails. It may not be possible of course.

grimar added a comment.Mar 5 2019, 2:04 AM

Can you write a test that is UNSUPPORTED if zlib IS available?

I think we have such a test already. It is:
https://github.com/llvm-mirror/llvm/blob/master/test/tools/llvm-objcopy/ELF/compress-debug-sections-invalid-format.test
(It does not do # REQUIRES: zlib because code report the Invalid or unsupported --compress-debug-sections format error before zlib::isAvailable() check.
What looks fine to me.)

That isn't the same test as I meant. That checks the error message at line 475, whereas I'm looking for a test for line 483. In other words, a valid compression format, but where zlib::isAvailable fails. It may not be possible of course.

Yes, as I mentioned in the description I do not think it is possible. FWIW in LLD we do not check this error either.

jhenderson accepted this revision.Mar 5 2019, 2:21 AM

Okay, LGTM. I just verified that it works locally, when it didn't before.

By the way, is this fixing https://bugs.llvm.org/show_bug.cgi?id=40886? I think it does for me.

This revision is now accepted and ready to land.Mar 5 2019, 2:21 AM
grimar added a comment.Mar 5 2019, 2:40 AM

By the way, is this fixing https://bugs.llvm.org/show_bug.cgi?id=40886? I think it does for me.

Yes, I think so too. Since now it will emit an error saying zlib isn't available.
In the description of this patch, I wrote "sections silently remain uncompressed in the output" but I just rechecked it
and they are stripped out for me too. Perhaps I looked at the wrong console window, I am not sure. I'll fix the description.

My reason to fix it was that I couldn't reproduce an error reported in https://bugs.llvm.org/show_bug.cgi?id=40885 on windows (with zlib off).

grimar edited the summary of this revision. (Show Details)Mar 5 2019, 2:42 AM

My reason to fix it was that I couldn't reproduce an error reported in https://bugs.llvm.org/show_bug.cgi?id=40885 on windows (with zlib off).

Yes, that's how I discovered the bug this fixes actually! I just didn't have time to dig into it and fix it, so thanks. BTW, you'll definitely need zlib in order to reproduce https://bugs.llvm.org/show_bug.cgi?id=40885.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2019, 3:33 AM