Support cross compilation to non-windows targets

Don't have --host/$HOST imply targeting Windows, but actually inspect
the target triple where necessary.
This commit is contained in:
Martin Storsjö committed 2023-04-26 19:18:24 +03:00
1 parent c49af4399a
commit 06f44cda62
4 files changed
+57 -24

No files matched your search

+13 -2
View File
@@ -89,10 +89,21 @@ fi
if [ -n "$HOST" ]; then
BUILDDIR=$BUILDDIR-$HOST
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Windows"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=$HOST-gcc"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=$HOST-g++"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_RC_COMPILER=$HOST-windres"
case $HOST in
*-mingw32)
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Windows"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_RC_COMPILER=$HOST-windres"
;;
*-linux*)
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Linux"
;;
*)
echo "Unrecognized host $HOST"
exit 1
;;
esac
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH=$LLVM_DIR"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER"
+26 -12
View File
@@ -122,16 +122,19 @@ fi
[ -z "$CHECKOUT_ONLY" ] || exit 0
case $(uname) in
MINGW*)
TARGET_WINDOWS=1
;;
*)
if [ -n "$HOST" ]; then
if [ -n "$HOST" ]; then
case $HOST in
*-mingw32)
TARGET_WINDOWS=1
fi
;;
esac
;;
esac
else
case $(uname) in
MINGW*)
TARGET_WINDOWS=1
;;
esac
fi
if command -v ninja >/dev/null; then
CMAKE_GENERATOR="Ninja"
@@ -153,10 +156,21 @@ fi
CMAKEFLAGS="$LLVM_CMAKEFLAGS"
if [ -n "$HOST" ]; then
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Windows"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=$HOST-gcc"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=$HOST-g++"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_RC_COMPILER=$HOST-windres"
case $HOST in
*-mingw32)
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Windows"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_RC_COMPILER=$HOST-windres"
;;
*-linux*)
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Linux"
;;
*)
echo "Unrecognized host $HOST"
exit 1
;;
esac
native=""
for dir in llvm-project/llvm/build/bin llvm-project/llvm/build-asserts/bin; do
@@ -185,7 +199,7 @@ if [ -n "$HOST" ]; then
BUILDDIR=$BUILDDIR-$HOST
if [ -n "$WITH_PYTHON" ]; then
if [ -n "$WITH_PYTHON" ] && [ -n "$TARGET_WINDOWS" ]; then
# The python3-config script requires executing with bash. It outputs
# an extra trailing space, which the extra 'echo' layer gets rid of.
EXT_SUFFIX="$(echo $(bash $PREFIX/python/bin/python3-config --extension-suffix))"
+5 -1
View File
@@ -62,7 +62,11 @@ fi
if [ -n "$HOST" ]; then
CONFIGFLAGS="$CONFIGFLAGS --host=$HOST"
CROSS_NAME=-$HOST
EXEEXT=.exe
case $HOST in
*-mingw32)
EXEEXT=.exe
;;
esac
else
case $(uname) in
MINGW*)
+13 -9
View File
@@ -44,14 +44,18 @@ if [ -n "$HOST" ] && [ -z "$CC" ]; then
fi
: ${CC:=cc}
case $(uname) in
MINGW*)
EXEEXT=.exe
;;
esac
if [ -n "$HOST" ]; then
EXEEXT=.exe
case $HOST in
*-mingw32)
EXEEXT=.exe
;;
esac
else
case $(uname) in
MINGW*)
EXEEXT=.exe
;;
esac
fi
if [ -n "$MACOS_REDIST" ]; then
@@ -70,7 +74,7 @@ fi
mkdir -p "$PREFIX/bin"
cp wrappers/*-wrapper.sh "$PREFIX/bin"
if [ -n "$HOST" ]; then
if [ -n "$HOST" ] && [ -n "$EXEEXT" ]; then
# TODO: If building natively on msys, pick up the default HOST value from there.
WRAPPER_FLAGS="$WRAPPER_FLAGS -DDEFAULT_TARGET=\"$HOST\""
for i in wrappers/*-wrapper.sh; do
@@ -94,7 +98,7 @@ for arch in $ARCHS; do
ln -sf clang-target-wrapper$CTW_SUFFIX $arch-w64-$target_os-$exec$CTW_LINK_SUFFIX
done
for exec in addr2line ar ranlib nm objcopy readelf size strings strip llvm-ar llvm-ranlib; do
if [ -n "$HOST" ]; then
if [ -n "$EXEEXT" ]; then
link_target=llvm-wrapper
else
case $exec in