Skip to content

Commit f07caf2

Browse files
committed
[llvm] cmake config groundwork to have ZSTD in LLVM
- added `FindZSTD.cmake` - added a CMake option `LLVM_ENABLE_ZSTD` with behavior mirroring that of `LLVM_ENABLE_ZLIB` - likewise added have_zstd to compiler-rt/test/lit.common.cfg.py, clang-tools-extra/clangd/test/lit.cfg.py, and several lit.site.cfg.py.in files mirroring have_zlib behavior Reviewed By: leonardchan, MaskRay Differential Revision: https://reviews.llvm.org/D128465
1 parent 269d5c1 commit f07caf2

File tree

20 files changed

+85
-0
lines changed

20 files changed

+85
-0
lines changed

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ llvm_canonicalize_cmake_booleans(
2929
CLANGD_MALLOC_TRIM
3030
CLANGD_TIDY_CHECKS
3131
LLVM_ENABLE_ZLIB
32+
LLVM_ENABLE_ZSTD
3233
)
3334

3435
configure_file(

clang-tools-extra/clangd/test/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ def calculate_arch_features(arch_string):
3636

3737
if config.have_zlib:
3838
config.available_features.add('zlib')
39+
40+
if config.have_zstd:
41+
config.available_features.add('zstd')

clang-tools-extra/clangd/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ config.clangd_build_xpc = @CLANGD_BUILD_XPC@
1717
config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
1818
config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
1919
config.have_zlib = @LLVM_ENABLE_ZLIB@
20+
config.have_zstd = @LLVM_ENABLE_ZSTD@
2021

2122
# Delegate logic to lit.cfg.py.
2223
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")

clang/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ llvm_canonicalize_cmake_booleans(
1111
CLANG_SPAWN_CC1
1212
ENABLE_BACKTRACES
1313
LLVM_ENABLE_ZLIB
14+
LLVM_ENABLE_ZSTD
1415
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
1516
LLVM_ENABLE_THREADS
1617
LLVM_WITH_Z3

clang/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ config.host_cc = "@CMAKE_C_COMPILER@"
2121
config.host_cxx = "@CMAKE_CXX_COMPILER@"
2222
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
2323
config.have_zlib = @LLVM_ENABLE_ZLIB@
24+
config.have_zstd = @LLVM_ENABLE_ZSTD@
2425
config.clang_arcmt = @CLANG_ENABLE_ARCMT@
2526
config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
2627
config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@

compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ if [[ ! -d ${LLVM_BUILD} ]]; then
140140
-DLLVM_TABLEGEN=$TBLGEN \
141141
-DLLVM_DEFAULT_TARGET_TRIPLE="${TARGET_TRIPLE}" \
142142
-DLLVM_ENABLE_ZLIB=ON \
143+
-DLLVM_ENABLE_ZSTD=ON \
143144
-DLLVM_ENABLE_TERMINFO=OFF \
144145
-DLLVM_ENABLE_THREADS=OFF \
145146
$LLVM_SRC

compiler-rt/test/lit.common.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ def get_path_from_clang(args, allow_failure):
217217

218218
if config.have_zlib == "1":
219219
config.available_features.add("zlib")
220+
221+
if config.have_zstd == "1":
222+
config.available_features.add("zstd")
220223

221224
# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
222225
# in RUN lines.

compiler-rt/test/lit.common.configured.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ else:
6565
set_default("target_suffix", "-%s" % config.target_arch)
6666

6767
set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
68+
set_default("have_zstd", "@LLVM_ENABLE_ZSTD@")
6869
set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
6970

7071
# LLVM tools dir can be passed in lit parameters, so try to

flang/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ if (FLANG_STANDALONE_BUILD)
7070
if(LLVM_ENABLE_ZLIB)
7171
find_package(ZLIB REQUIRED)
7272
endif()
73+
74+
# If LLVM links to zstd we need the imported targets so we can too.
75+
if(LLVM_ENABLE_ZSTD)
76+
find_package(ZSTD REQUIRED)
77+
endif()
78+
7379
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
7480
if(CMAKE_COMPILER_IS_GNUCXX)
7581
set(USE_NO_MAYBE_UNINITIALIZED 1)

lld/ELF/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if(LLVM_ENABLE_ZLIB)
66
set(imported_libs ZLIB::ZLIB)
77
endif()
88

9+
if(LLVM_ENABLE_ZSTD)
10+
list(APPEND imported_libs zstd)
11+
endif()
12+
913
add_lld_library(lldELF
1014
AArch64ErrataFix.cpp
1115
Arch/AArch64.cpp

0 commit comments

Comments
 (0)