Skip to content

Commit

Permalink
Link LLVM-based tools dynamically to LLVM
Browse files Browse the repository at this point in the history
I noticed that WebAssembly#388 increased the size of the Windows distribution by
200M+ and my guess for that is that all the symlinks which point to
clang get copied as real files (due to symlinks not always working on
Windows). To help counteract that this commit enables the
`LLVM_LINK_LLVM_DYLIB=ON` option when building LLVM and Clang. That
should build a `libLLVM.so` which helps reduce the size of all the tools
since they no longer all statically link LLVM. Locally the size of a
full build is ~100M less as a result of this change. On Windows where
all the binaries are copied around it should hopefully help much more.

I've additionally taken a leaf out of rust-lang/rust's book of building
LLVM to pass the `LLVM_VERSION_SUFFIX` option here too. That I believe
helps avoid `libLLVM.so` conflicting with a system-installed
`libLLVM.so` by accident by ensuring there's a suffix present on the
binaries built for wasi-sdk.
  • Loading branch information
alexcrichton committed Mar 9, 2024
1 parent e62ec5d commit 81bb62c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ build/llvm.BUILT:
-DCLANG_LINKS_TO_CREATE="$(call join-with,;,$(CLANG_LINKS_TO_CREATE))" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_VERSION_SUFFIX=-wasi-sdk \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON \
Expand Down Expand Up @@ -118,6 +120,8 @@ build/llvm.BUILT:
install-objdump \
install-objcopy \
install-c++filt \
install-LLVM \
install-clang-cpp \
llvm-config
touch build/llvm.BUILT

Expand Down

0 comments on commit 81bb62c

Please sign in to comment.