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.
This commit is contained in:
Martin Storsjö committed 2024-08-30 10:52:32 +03:00
1 parent 179f412f25
commit ae5aa36b95
1 file changed
+16 -7
+16 -7
View File
@@ -81,8 +81,16 @@ else
fi fi
cd llvm-project/compiler-rt cd llvm-project/compiler-rt
# Use a staging directory in case parts of the resource dir are immutable
WORKDIR=$(mktemp -d); trap "rm -rf $WORKDIR" 0 INSTALL_PREFIX="$CLANG_RESOURCE_DIR"
if [ -h "$CLANG_RESOURCE_DIR/include" ]; then
# Symlink to system headers; use a staging directory in case parts
# of the resource dir are immutable
WORKDIR="$(mktemp -d)"; trap "rm -rf $WORKDIR" 0
INSTALL_PREFIX="$WORKDIR/install"
fi
for arch in $ARCHS; do for arch in $ARCHS; do
if [ -n "$SANITIZERS" ]; then if [ -n "$SANITIZERS" ]; then
@@ -125,23 +133,24 @@ for arch in $ARCHS; do
-DCMAKE_CXX_FLAGS_INIT="$CFGUARD_CFLAGS" \ -DCMAKE_CXX_FLAGS_INIT="$CFGUARD_CFLAGS" \
$SRC_DIR $SRC_DIR
cmake --build . ${CORES:+-j${CORES}} cmake --build . ${CORES:+-j${CORES}}
cmake --install . --prefix "${WORKDIR}/install" cmake --install . --prefix "$INSTALL_PREFIX"
mkdir -p "$PREFIX/$arch-w64-mingw32/bin" mkdir -p "$PREFIX/$arch-w64-mingw32/bin"
if [ -n "$SANITIZERS" ]; then if [ -n "$SANITIZERS" ]; then
mv "${WORKDIR}/install/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin" mv "$INSTALL_PREFIX/lib/windows/"*.dll "$PREFIX/$arch-w64-mingw32/bin"
fi fi
INSTALLED=1 INSTALLED=1
cd .. cd ..
done done
if [ "$INSTALL_PREFIX" != "$CLANG_RESOURCE_DIR" ]; then
if [ -z "$INSTALLED" ]; then if [ -z "$INSTALLED" ]; then
# Don't try to move the installed files in place, if nothing was # Don't try to move the installed files in place, if nothing was
# installed (e.g. if building with --build-sanitizers but not for x86). # installed (e.g. if building with --build-sanitizers but not for x86).
exit 0 exit 0
fi fi
if [ -h "$CLANG_RESOURCE_DIR/include" ]; then
# symlink to system headers - skip copy # symlink to system headers - skip copy
rm -rf ${WORKDIR}/install/include rm -rf "$INSTALL_PREFIX/include"
cp -r "$INSTALL_PREFIX/." $CLANG_RESOURCE_DIR
fi fi
cp -r ${WORKDIR}/install/. $CLANG_RESOURCE_DIR