Skip to content

Commit 778a02b

Browse files
authored
Link LLVM-based tools dynamically to LLVM (take 2) (#441)
This is a revival of #397 but only applies the logic to non-Windows platforms. Windows builds still seem to not work so Windows is not improved as a result of this change.
1 parent 2e7bb65 commit 778a02b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmake/wasi-sdk-toolchain.cmake

+13
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ set(tools
5555
c++filt
5656
llvm-config)
5757

58+
# By default link LLVM dynamically to all the various tools. This greatly
59+
# reduces the binary size of all the tools through a shared library rather than
60+
# statically linking LLVM to each individual tool. This requires a few other
61+
# install targets as well to ensure the appropriate libraries are all installed.
62+
#
63+
# Also note that the `-wasi-sdk` version suffix is intended to help prevent
64+
# these dynamic libraries from clashing with other system libraries in case the
65+
# `lib` dir gets put on `LD_LIBRARY_PATH` or similar.
66+
if(NOT WIN32)
67+
list(APPEND default_cmake_args -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_VERSION_SUFFIX=-wasi-sdk)
68+
list(APPEND tools LLVM clang-cpp)
69+
endif()
70+
5871
list(TRANSFORM tools PREPEND --target= OUTPUT_VARIABLE build_targets)
5972
list(TRANSFORM tools PREPEND --target=install- OUTPUT_VARIABLE install_targets)
6073

0 commit comments

Comments
 (0)