From ca44a1166050b87a7faffcc4e587470849fb98c0 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Mon, 11 Mar 2019 12:51:20 +0100 Subject: [PATCH] Add wrappers that target Universal Windows --- install-wrappers.sh | 25 ++++++++++++++----------- wrappers/clang-target-wrapper.c | 12 ++++++++++++ wrappers/clang-target-wrapper.sh | 11 +++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/install-wrappers.sh b/install-wrappers.sh index 5b77a6b..180a4d1 100755 --- a/install-wrappers.sh +++ b/install-wrappers.sh @@ -11,6 +11,7 @@ mkdir -p "$PREFIX" PREFIX="$(cd "$PREFIX" && pwd)" : ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}} +: ${TARGET_OSES:=${TOOLCHAIN_TARGET_OSES-mingw32 mingw32uwp}} if [ -n "$HOST" ] && [ -z "$CC" ]; then CC=$HOST-gcc @@ -49,17 +50,19 @@ else fi cd $PREFIX/bin for arch in $ARCHS; do - for exec in clang clang++ gcc g++ cc c99 c11 c++; do - ln -sf clang-target-wrapper$CTW_SUFFIX $arch-w64-mingw32-$exec$CTW_LINK_SUFFIX - done - for exec in ar ranlib nm objcopy strings strip; do - ln -sf llvm-$exec$EXEEXT $arch-w64-mingw32-$exec$EXEEXT || true - done - for exec in windres; do - ln -sf $exec-wrapper$EXEEXT $arch-w64-mingw32-$exec$EXEEXT - done - for exec in ld objdump dlltool; do - ln -sf $exec-wrapper.sh $arch-w64-mingw32-$exec + for target_os in $TARGET_OSES; do + for exec in clang clang++ gcc g++ cc c99 c11 c++; do + ln -sf clang-target-wrapper$CTW_SUFFIX $arch-w64-$target_os-$exec$CTW_LINK_SUFFIX + done + for exec in ar ranlib nm objcopy strings strip; do + ln -sf llvm-$exec$EXEEXT $arch-w64-$target_os-$exec$EXEEXT || true + done + for exec in windres; do + ln -sf $exec-wrapper$EXEEXT $arch-w64-$target_os-$exec$EXEEXT + done + for exec in ld objdump dlltool; do + ln -sf $exec-wrapper.sh $arch-w64-$target_os-$exec + done done done if [ -n "$EXEEXT" ]; then diff --git a/wrappers/clang-target-wrapper.c b/wrappers/clang-target-wrapper.c index 2e8a61b..ee673b2 100644 --- a/wrappers/clang-target-wrapper.c +++ b/wrappers/clang-target-wrapper.c @@ -257,6 +257,9 @@ int _tmain(int argc, TCHAR* argv[]) { dash = _tcschr(arch, '-'); if (dash) *dash = '\0'; + TCHAR *target_os = _tcsrchr(target, '-'); + if (target_os) + target_os++; // Check if trying to compile Ada; if we try to do this, invoking clang // would end up invoking -gcc with the same arguments, which ends @@ -293,6 +296,15 @@ int _tmain(int argc, TCHAR* argv[]) { // Dwarf is the default here. } + if (target_os && !_tcscmp(target_os, _T("mingw32uwp"))) { + // the UWP target is for Windows 10 + exec_argv[arg++] = _T("-D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00"); + // the UWP target can only use Windows Store APIs + exec_argv[arg++] = _T("-DWINAPI_FAMILY=WINAPI_FAMILY_APP"); + // the Windows Store API only supports Windows Unicode (some rare ANSI ones are available) + exec_argv[arg++] = _T("-DUNICODE"); + } + exec_argv[arg++] = _T("-target"); exec_argv[arg++] = target; exec_argv[arg++] = _T("-rtlib=compiler-rt"); diff --git a/wrappers/clang-target-wrapper.sh b/wrappers/clang-target-wrapper.sh index 528f52c..f4dc702 100755 --- a/wrappers/clang-target-wrapper.sh +++ b/wrappers/clang-target-wrapper.sh @@ -8,6 +8,7 @@ if [ "$TARGET" = "$BASENAME" ]; then TARGET=$DEFAULT_TARGET fi ARCH="${TARGET%%-*}" +TARGET_OS="${TARGET##*-}" # Check if trying to compile Ada; if we try to do this, invoking clang # would end up invoking -gcc with the same arguments, which ends @@ -52,6 +53,16 @@ aarch64) # Dwarf is the default here. ;; esac +case $TARGET_OS in +mingw32uwp) + # the UWP target is for Windows 10 + FLAGS="$FLAGS -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00" + # the UWP target can only use Windows Store APIs + FLAGS="$FLAGS -DWINAPI_FAMILY=WINAPI_FAMILY_APP" + # the Windows Store API only supports Windows Unicode (some rare ANSI ones are available) + FLAGS="$FLAGS -DUNICODE" + ;; +esac FLAGS="$FLAGS -target $TARGET" FLAGS="$FLAGS -rtlib=compiler-rt"