Skip to content

Commit ae5aa36

Browse files
committed
build-compiler-rt: Only use a temp directory as install prefix if necessary
This makes the build script output more legible, when the cmake install output actually shows where the files are installed in the end.
1 parent 179f412 commit ae5aa36

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

build-compiler-rt.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ else
8181
fi
8282

8383
cd llvm-project/compiler-rt
84-
# Use a staging directory in case parts of the resource dir are immutable
85-
WORKDIR=$(mktemp -d); trap "rm -rf $WORKDIR" 0
84+
85+
INSTALL_PREFIX="$CLANG_RESOURCE_DIR"
86+
87+
if [ -h "$CLANG_RESOURCE_DIR/include" ]; then
88+
# Symlink to system headers; use a staging directory in case parts
89+
# of the resource dir are immutable
90+
WORKDIR="$(mktemp -d)"; trap "rm -rf $WORKDIR" 0
91+
INSTALL_PREFIX="$WORKDIR/install"
92+
fi
93+
8694

8795
for arch in $ARCHS; do
8896
if [ -n "$SANITIZERS" ]; then
@@ -125,23 +133,24 @@ for arch in $ARCHS; do
125133
-DCMAKE_CXX_FLAGS_INIT="$CFGUARD_CFLAGS" \
126134
$SRC_DIR
127135
cmake --build . ${CORES:+-j${CORES}}
128-
cmake --install . --prefix "${WORKDIR}/install"
136+
cmake --install . --prefix "$INSTALL_PREFIX"
129137
mkdir -p "$PREFIX/$arch-w64-mingw32/bin"
130138
if [ -n "$SANITIZERS" ]; then
131-
mv "${WORKDIR}/install/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin"
139+
mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin"
132140
fi
133141
INSTALLED=1
134142
cd ..
135143
done
136144

137-
if [ -z "$INSTALLED" ]; then
138-
# Don't try to move the installed files in place, if nothing was
139-
# installed (e.g. if building with --build-sanitizers but not for x86).
140-
exit 0
141-
fi
145+
if [ "$INSTALL_PREFIX" != "$CLANG_RESOURCE_DIR" ]; then
146+
if [ -z "$INSTALLED" ]; then
147+
# Don't try to move the installed files in place, if nothing was
148+
# installed (e.g. if building with --build-sanitizers but not for x86).
149+
exit 0
150+
fi
142151

143-
if [ -h "$CLANG_RESOURCE_DIR/include" ]; then
144152
# symlink to system headers - skip copy
145-
rm -rf ${WORKDIR}/install/include
153+
rm -rf "$INSTALL_PREFIX/include"
154+
155+
cp -r "$INSTALL_PREFIX/." $CLANG_RESOURCE_DIR
146156
fi
147-
cp -r ${WORKDIR}/install/. $CLANG_RESOURCE_DIR

0 commit comments

Comments
 (0)