Skip to content

Commit d31dc46

Browse files
committed
build-llvm: Use symlinks in the llvm/tools directory instead of LLVM_ENABLE_PROJECTS
This makes cmake use relative paths to all source files, allowing ccache to reuse compilation results from different source trees in different directories. Keep using LLVM_ENABLE_PROJECTS on msys, where symlinks aren't supported.
1 parent 0f9d9f1 commit d31dc46

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

build-llvm.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,38 @@ if [ -n "$FULL_LLVM" ]; then
106106
fi
107107

108108
cd llvm-project/llvm
109+
110+
case $(uname) in
111+
MINGW*)
112+
EXPLICIT_PROJECTS=1
113+
;;
114+
*)
115+
# If we have working symlinks, hook up other tools by symlinking them
116+
# into tools, instead of using LLVM_ENABLE_PROJECTS. This way, all
117+
# source code is under the directory tree of the toplevel cmake file
118+
# (llvm-project/llvm), which makes cmake use relative paths to all source
119+
# files. Using relative paths makes for identical compiler output from
120+
# different source trees in different locations (for cases where e.g.
121+
# path names are included, in assert messages), allowing ccache to speed
122+
# up compilation.
123+
cd tools
124+
for p in clang lld; do
125+
if [ ! -e $p ]; then
126+
ln -s ../../$p .
127+
fi
128+
done
129+
cd ..
130+
;;
131+
esac
132+
109133
mkdir -p $BUILDDIR
110134
cd $BUILDDIR
111135
cmake \
112136
${CMAKE_GENERATOR+-G} "$CMAKE_GENERATOR" \
113137
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
114138
-DCMAKE_BUILD_TYPE=Release \
115139
-DLLVM_ENABLE_ASSERTIONS=$ASSERTS \
116-
-DLLVM_ENABLE_PROJECTS="clang;lld" \
140+
${EXPLICIT_PROJECTS+-DLLVM_ENABLE_PROJECTS="clang;lld"} \
117141
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
118142
-DLLVM_INSTALL_TOOLCHAIN_ONLY=$TOOLCHAIN_ONLY \
119143
-DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil;llvm-objcopy;llvm-strip;llvm-cov;llvm-profdata;llvm-addr2line" \

0 commit comments

Comments
 (0)