From af1099048abb3565e0db8786a8394d5bfda8e24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 3 Dec 2019 23:27:34 +0200 Subject: [PATCH] Fix building only certain architectures when building on windows On windows, we rename clang.exe to clang-$MAJOR.exe, and later install clang.exe as a wrapper for the default architecture. But if only building certain architectures, and the host architecture isn't one of them, we shouldn't install any unprefixed clang.exe at all. --- build-compiler-rt.sh | 3 ++- build-mingw-w64.sh | 6 ++++-- install-wrappers.sh | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/build-compiler-rt.sh b/build-compiler-rt.sh index d1e4b81..7384a95 100755 --- a/build-compiler-rt.sh +++ b/build-compiler-rt.sh @@ -29,7 +29,8 @@ export PATH="$PREFIX/bin:$PATH" : ${CORES:=4} : ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}} -CLANG_VERSION=$(basename "$(dirname "$(dirname "$(dirname "$("$PREFIX/bin/clang" --print-libgcc-file-name -rtlib=compiler-rt)")")")") +ANY_ARCH=$(echo $ARCHS | awk '{print $1}') +CLANG_VERSION=$(basename "$(dirname "$(dirname "$(dirname "$("$PREFIX/bin/$ANY_ARCH-w64-mingw32-clang" --print-libgcc-file-name -rtlib=compiler-rt)")")")") if [ ! -d llvm-project/compiler-rt ] || [ -n "$SYNC" ]; then CHECKOUT_ONLY=1 ./build-llvm.sh diff --git a/build-mingw-w64.sh b/build-mingw-w64.sh index 38c8d8a..b970650 100755 --- a/build-mingw-w64.sh +++ b/build-mingw-w64.sh @@ -156,8 +156,10 @@ if [ -n "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then done fi if [ -n "$EXEEXT" ]; then - if [ -z "$HOST" ]; then + if [ -z "$HOST" ] && [ -f clang$EXEEXT ]; then HOST=$(./clang -dumpmachine | sed 's/-.*//')-w64-mingw32 fi - ln -sf $HOST-widl$EXEEXT widl$EXEEXT + if [ -n "$HOST" ]; then + ln -sf $HOST-widl$EXEEXT widl$EXEEXT + fi fi diff --git a/install-wrappers.sh b/install-wrappers.sh index fd91908..925fcbd 100755 --- a/install-wrappers.sh +++ b/install-wrappers.sh @@ -94,10 +94,17 @@ if [ -n "$EXEEXT" ]; then if [ -z "$HOST" ]; then HOST=$(./clang-$CLANG_MAJOR -dumpmachine | sed 's/-.*//')-w64-mingw32 fi - for exec in clang clang++ gcc g++ cc c99 c11 c++ addr2line ar ranlib nm objcopy strings strip windres; do - ln -sf $HOST-$exec$EXEEXT $exec$EXEEXT - done - for exec in ld objdump dlltool; do - ln -sf $HOST-$exec $exec - done + HOST_ARCH="${HOST%%-*}" + # Install unprefixed wrappers if $HOST is one of the architectures + # we are installing wrappers for. + case $ARCHS in + *$HOST_ARCH*) + for exec in clang clang++ gcc g++ cc c99 c11 c++ addr2line ar ranlib nm objcopy strings strip windres; do + ln -sf $HOST-$exec$EXEEXT $exec$EXEEXT + done + for exec in ld objdump dlltool; do + ln -sf $HOST-$exec $exec + done + ;; + esac fi