Skip to content

Commit 052c18b

Browse files
botaneggsegoon
authored andcommitted
feat build: add USERVER_ENABLE_DEBUG_INFO_COMPRESSION flag
Tests: протестировано CI Pull Request resolved: <#879> commit_hash:900d1e02940798d442b8765c99f21f3f77db8b40
1 parent 737c58a commit 052c18b

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

cmake/SetupDebugInfoCompression.cmake

+22-2
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,25 @@ function(setup_compiler_debug_info_compression)
3434
endif()
3535
endfunction()
3636

37-
setup_linker_debug_info_compression()
38-
setup_compiler_debug_info_compression()
37+
38+
set(USERVER_DEBUG_INFO_COMPRESSION "auto" CACHE STRING "Linker and compiler debug info compression algorithm (z, zstd, none, auto)")
39+
40+
if(USERVER_DEBUG_INFO_COMPRESSION STREQUAL "z")
41+
message(STATUS "Using compiler debug info compression: z")
42+
add_compile_options("-gz")
43+
message(STATUS "Using linker debug info compression: z")
44+
add_link_options("-gz")
45+
elseif(USERVER_DEBUG_INFO_COMPRESSION STREQUAL "zstd")
46+
message(STATUS "Using linker debug info compression: zstd")
47+
add_link_options("-gz=zstd")
48+
message(STATUS "Using compiler debug info compression: zstd")
49+
add_compile_options("-gz=zstd")
50+
elseif(USERVER_DEBUG_INFO_COMPRESSION STREQUAL "none")
51+
message(STATUS "Using linker debug info compression: none")
52+
message(STATUS "Using compiler debug info compression: none")
53+
elseif(USERVER_DEBUG_INFO_COMPRESSION STREQUAL "auto")
54+
setup_linker_debug_info_compression()
55+
setup_compiler_debug_info_compression()
56+
else()
57+
message(FATAL_ERROR "Unknown USERVER_DEBUG_INFO_COMPRESSION value")
58+
endif()

scripts/docs/en/userver/build/options.md

+23-22
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,29 @@ The exact format of setting cmake options varies depending on the method of buil
152152

153153
### CMake options for various compilation modes
154154

155-
| Option | Description | Default |
156-
|----------------------------------------|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
157-
| `USERVER_CHECK_PACKAGE_VERSIONS` | Check package versions | `ON` |
158-
| `USERVER_SANITIZE` | Build with sanitizers support, allows combination of values via 'val1 val2'. Available: `addr`, `mem`, `ub` | (no sanitizers) |
159-
| `USERVER_SANITIZE_BLACKLIST` | Path to file that is passed to the -fsanitize-blacklist option | (no blacklist) |
160-
| `USERVER_USE_LD` | Linker to use, e.g. `gold` or `lld` | `lld` for Clang, system linker otherwise (typically GNU ld) |
161-
| `USERVER_USE_STATIC_LIBS` | Tries to find all dependencies as static libraries | `ON` for `Clang` not older than `14` version |
162-
| `USERVER_USE_CCACHE` | Use ccache if present, disable for benchmarking build times | `ON` |
163-
| `USERVER_LTO` | Use link time optimizations (SEE NOTE BELOW) | `OFF` |
164-
| `USERVER_LTO_CACHE` | Use LTO cache if present, disable for benchmarking build times | `ON` |
165-
| `USERVER_LTO_CACHE_DIR` | LTO cache directory | `${CMAKE_CURRENT_BINARY_DIR}/.ltocache` |
166-
| `USERVER_LTO_CACHE_SIZE_MB` | LTO cache size limit in MB | `6000` |
167-
| `USERVER_PGO_GENERATE` | Generate PGO profile | `OFF` |
168-
| `USERVER_PGO_USE` | Path to PGO profile file | (no path) |
169-
| `USERVER_COMPILATION_TIME_TRACE` | Generate Clang compilation time trace | `OFF` |
170-
| `USERVER_NO_WERROR` | Do not treat warnings as errors | `ON` |
171-
| `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` | Logs of this and below levels are removed from binary. Possible values: trace, info, debug, warning, error | `OFF` |
172-
| `USERVER_PIP_USE_SYSTEM_PACKAGES` | Use system python packages inside venv. Useful for Docker, CI and other controlled environments | `OFF` |
173-
| `USERVER_PIP_OPTIONS` | Options for all pip calls. Useful for passing `--no-index` option to prevent network usage | (no options) |
174-
| `USERVER_INSTALL` | Build userver for further installation | `OFF` |
175-
| `USERVER_CONAN` | Build userver using Conan packages | `ON` if build is launched from Conan, `OFF` otherwise |
176-
| `USERVER_CHAOTIC_FORMAT` | Whether to format generated code if FORMAT option is missing | `ON` |
155+
| Option | Description | Default |
156+
|-----------------------------------------|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
157+
| `USERVER_CHECK_PACKAGE_VERSIONS` | Check package versions | `ON` |
158+
| `USERVER_SANITIZE` | Build with sanitizers support, allows combination of values via 'val1 val2'. Available: `addr`, `mem`, `ub` | (no sanitizers) |
159+
| `USERVER_SANITIZE_BLACKLIST` | Path to file that is passed to the -fsanitize-blacklist option | (no blacklist) |
160+
| `USERVER_USE_LD` | Linker to use, e.g. `gold` or `lld` | `lld` for Clang, system linker otherwise (typically GNU ld) |
161+
| `USERVER_USE_STATIC_LIBS` | Tries to find all dependencies as static libraries | `ON` for `Clang` not older than `14` version |
162+
| `USERVER_USE_CCACHE` | Use ccache if present, disable for benchmarking build times | `ON` |
163+
| `USERVER_LTO` | Use link time optimizations (SEE NOTE BELOW) | `OFF` |
164+
| `USERVER_LTO_CACHE` | Use LTO cache if present, disable for benchmarking build times | `ON` |
165+
| `USERVER_LTO_CACHE_DIR` | LTO cache directory | `${CMAKE_CURRENT_BINARY_DIR}/.ltocache` |
166+
| `USERVER_LTO_CACHE_SIZE_MB` | LTO cache size limit in MB | `6000` |
167+
| `USERVER_ENABLE_DEBUG_INFO_COMPRESSION` | Enable linker and compiler debug info compression | `ON` |
168+
| `USERVER_PGO_GENERATE` | Generate PGO profile | `OFF` |
169+
| `USERVER_PGO_USE` | Path to PGO profile file | (no path) |
170+
| `USERVER_COMPILATION_TIME_TRACE` | Generate Clang compilation time trace | `OFF` |
171+
| `USERVER_NO_WERROR` | Do not treat warnings as errors | `ON` |
172+
| `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` | Logs of this and below levels are removed from binary. Possible values: trace, info, debug, warning, error | `OFF` |
173+
| `USERVER_PIP_USE_SYSTEM_PACKAGES` | Use system python packages inside venv. Useful for Docker, CI and other controlled environments | `OFF` |
174+
| `USERVER_PIP_OPTIONS` | Options for all pip calls. Useful for passing `--no-index` option to prevent network usage | (no options) |
175+
| `USERVER_INSTALL` | Build userver for further installation | `OFF` |
176+
| `USERVER_CONAN` | Build userver using Conan packages | `ON` if build is launched from Conan, `OFF` otherwise |
177+
| `USERVER_CHAOTIC_FORMAT` | Whether to format generated code if FORMAT option is missing | `ON` |
177178

178179
@warning Using LTO can lead to [some problems](https://github.com/userver-framework/userver/issues/242). We don't recommend using `USERVER_LTO`.
179180

0 commit comments

Comments
 (0)