[cc1as] Support --compress-debug-sections=zstd

`clang -gz=zstd -c a.s` generates ELFCOMPRESS_ZSTD compressed debug info
sections if compression decreases size.
This commit is contained in:
Fangrui Song 2022-09-08 16:31:45 -07:00
parent 3757ef2e66
commit 1f6a86b309
2 changed files with 11 additions and 1 deletions

View File

@ -3,4 +3,13 @@
// RUN: %clang -cc1as -triple i686 --compress-debug-sections %s -o /dev/null
// RUN: %clang -cc1as -triple i686 -compress-debug-sections=zlib %s -o /dev/null
// RUN: %if zstd %{ %clang -cc1as -triple x86_64 -compress-debug-sections=zstd %s -o /dev/null %}
// RUN: %if zstd %{ %clang -cc1as -triple x86_64 -filetype obj -compress-debug-sections=zstd %s -o %t %}
// RUN: %if zstd %{ llvm-readelf -S -x .debug_str %t | FileCheck %s --check-prefix=ZSTD %}
// ZSTD: .debug_str PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] 01 MSC 0 0 8
// ZSTD: Hex dump of section '.debug_str':
// ZSTD: 0000 02000000 00000000
.section .debug_str,"MS",@progbits,1
.asciz "perfectly compressable data sample *****************************************"

View File

@ -240,6 +240,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
.Case("none", llvm::DebugCompressionType::None)
.Case("zlib", llvm::DebugCompressionType::Zlib)
.Case("zstd", llvm::DebugCompressionType::Zstd)
.Default(llvm::DebugCompressionType::None);
}