[ELF] Add --compress-debug-sections=zstd
authorFangrui Song <i@maskray.me>
Fri, 9 Sep 2022 17:30:18 +0000 (10:30 -0700)
committerFangrui Song <i@maskray.me>
Fri, 9 Sep 2022 17:30:18 +0000 (10:30 -0700)
commit449f2ca146dde0ef14c9837f71d4a0be92ca4843
tree7fd4ec694ffabe904ad3e013587c430e5d995582
parentddc0465369a373f2022283905fdc7677eeaf9525
[ELF] Add --compress-debug-sections=zstd

`clang -gz=zstd a.o` passes this option to the linker. This option compresses output
debug sections with zstd and sets ch_type to ELFCOMPRESS_ZSTD. As of today, very
few DWARF consumers recognize ELFCOMPRESS_ZSTD.

Use the llvm::zstd::compress API with level llvm::zstd::DefaultCompression (5),
which we may tune after we have more experience with zstd output.
zstd has built-in parallel compression support (so we don't need to do D117853
for zlib), which is not leveraged yet.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D133548
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/ELF/OutputSections.cpp
lld/docs/ReleaseNotes.rst
lld/docs/ld.lld.1
lld/test/ELF/compress-debug-sections-zstd.s