Skip to content

Commit

Permalink
[llvm-config] Make llvm-config --system-libs obey LLVM_USE_STATIC_ZSTD (
Browse files Browse the repository at this point in the history
llvm#93754)

LLVM's build system does the right thing but LLVM_SYSTEM_LIBS ends up
containing the shared library. Emit the static library instead when
appropriate.

With LLVM_USE_STATIC_ZSTD, before:

khuey@zhadum:~/dev/llvm-project/build$ ./bin/llvm-config --system-libs
-lrt -ldl -lm -lz -lzstd -lxml2

after:

khuey@zhadum:~/dev/llvm-project/build$ ./bin/llvm-config --system-libs
-lrt -ldl -lm -lz /usr/local/lib/libzstd.a -lxml2
  • Loading branch information
khuey authored and AlexisPerry committed Jun 27, 2024
1 parent ef20d5b commit f3d77cf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,12 @@ if(LLVM_ENABLE_ZSTD)
if(NOT zstd_library)
get_property(zstd_library TARGET ${zstd_target} PROPERTY LOCATION)
endif()
get_library_name(${zstd_library} zstd_library)
set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
if (zstd_target STREQUAL zstd::libzstd_shared)
get_library_name(${zstd_library} zstd_library)
set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
else()
set(llvm_system_libs ${llvm_system_libs} "${zstd_STATIC_LIBRARY}")
endif()
endif()

set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}")
Expand Down

0 comments on commit f3d77cf

Please sign in to comment.