diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua index 519bf9ec99..0dcf5562f3 100644 --- a/build/premake/premake5.lua +++ b/build/premake/premake5.lua @@ -61,7 +61,7 @@ elseif not os.istarget("windows") then end end --- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM) +-- detect CPU architecture (simplistic) arch = "x86" macos_arch = "x86_64" if _OPTIONS["android"] then @@ -71,33 +71,33 @@ elseif os.istarget("windows") then arch = "amd64" end else - arch = os.getenv("HOSTTYPE") - -- Force x86_64 on Mac OS for now, as Spidermonkey 78 isn't Apple Silicon compatible. + os.execute(cc .. " -dumpmachine > .gccmachine.tmp") + local f = io.open(".gccmachine.tmp", "r") + local machine = f:read("*line") + f:close() + -- Special handling on mac os where xcode needs special flags. if os.istarget("macosx") then - arch = "amd64" - macos_arch = "x86_64" - elseif arch == "x86_64" or arch == "amd64" then - arch = "amd64" - else - os.execute(cc .. " -dumpmachine > .gccmachine.tmp") - local f = io.open(".gccmachine.tmp", "r") - local machine = f:read("*line") - f:close() - if string.find(machine, "x86_64") == 1 or string.find(machine, "amd64") == 1 then - arch = "amd64" - elseif string.find(machine, "i.86") == 1 then - arch = "x86" - elseif string.find(machine, "arm") == 1 then - arch = "arm" - elseif string.find(machine, "aarch64") == 1 then + if string.find(machine, "arm64") then arch = "aarch64" - elseif string.find(machine, "e2k") == 1 then - arch = "e2k" - elseif string.find(machine, "ppc64") == 1 or string.find(machine, "powerpc64") == 1 then - arch = "ppc64" + macos_arch = "arm64" else - print("WARNING: Cannot determine architecture from GCC, assuming x86") + arch = "amd64" + macos_arch = "x86_64" end + elseif string.find(machine, "x86_64") == 1 or string.find(machine, "amd64") == 1 then + arch = "amd64" + elseif string.find(machine, "i.86") == 1 then + arch = "x86" + elseif string.find(machine, "arm") == 1 then + arch = "arm" + elseif string.find(machine, "aarch64") == 1 then + arch = "aarch64" + elseif string.find(machine, "e2k") == 1 then + arch = "e2k" + elseif string.find(machine, "ppc64") == 1 or string.find(machine, "powerpc64") == 1 then + arch = "ppc64" + else + print("WARNING: Cannot determine architecture from GCC, assuming x86") end end @@ -327,8 +327,8 @@ function project_set_build_flags() links { "gcov" } end - -- MacOS 10.12 only supports processors with SSE 4.1, so enable that. - if os.istarget("macosx") then + -- MacOS 10.12 only supports intel processors with SSE 4.1, so enable that. + if os.istarget("macosx") and arch == "amd64" then buildoptions { "-msse4.1" } end diff --git a/libraries/osx/build-osx-libs.sh b/libraries/osx/build-osx-libs.sh index 0e4170c00b..058d83b6f9 100755 --- a/libraries/osx/build-osx-libs.sh +++ b/libraries/osx/build-osx-libs.sh @@ -36,14 +36,14 @@ FREETYPE_VERSION="freetype-2.10.4" OGG_VERSION="libogg-1.3.3" VORBIS_VERSION="libvorbis-1.3.7" # gloox requires GnuTLS, GnuTLS requires Nettle and GMP -GMP_VERSION="gmp-6.2.0" +GMP_VERSION="gmp-6.2.1" NETTLE_VERSION="nettle-3.6" # NOTE: remember to also update LIB_URL below when changing version GLOOX_VERSION="gloox-1.0.24" GNUTLS_VERSION="gnutls-3.6.15" # OS X only includes part of ICU, and only the dylib # NOTE: remember to also update LIB_URL below when changing version -ICU_VERSION="icu4c-67_1" +ICU_VERSION="icu4c-69_1" ENET_VERSION="enet-1.3.17" MINIUPNPC_VERSION="miniupnpc-2.2.2" SODIUM_VERSION="libsodium-1.0.18" @@ -61,6 +61,7 @@ FMT_VERSION="7.1.3" export CC=${CC:="clang"} CXX=${CXX:="clang++"} export MIN_OSX_VERSION=${MIN_OSX_VERSION:="10.12"} +export ARCH=${ARCH:=""} # The various libs offer inconsistent configure options, some allow # setting sysroot and OS X-specific options, others don't. Adding to @@ -83,7 +84,7 @@ if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then fi CFLAGS="$CFLAGS $C_FLAGS -fvisibility=hidden" -CXXFLAGS="$CXXFLAGS $C_FLAGS -stdlib=libc++ -std=c++17 -msse4.1" +CXXFLAGS="$CXXFLAGS $C_FLAGS -stdlib=libc++ -std=c++17" OBJCFLAGS="$OBJCFLAGS $C_FLAGS" OBJCXXFLAGS="$OBJCXXFLAGS $C_FLAGS" @@ -94,16 +95,31 @@ ARCHLESS_CFLAGS=$CFLAGS ARCHLESS_CXXFLAGS=$CXXFLAGS ARCHLESS_LDFLAGS="$LDFLAGS -stdlib=libc++" -CFLAGS="$CFLAGS -arch x86_64" -CXXFLAGS="$CXXFLAGS -arch x86_64" +# If ARCH isn't set, select either x86_64 or arm64 +if [ -z "${ARCH}" ]; then + if [ "`uname -m`" == "arm64" ]; then + ARCH="arm64" + # Some libs want this passed to configure for cross compilation. + HOST_PLATFORM="--host=aarch64-apple-darwin" + else + CXXFLAGS="$CXXFLAGS -msse4.1" + ARCH="x86_64" + # Some libs want this passed to configure for cross compilation. + HOST_PLATFORM="--host=x86_64-apple-darwin" + fi +fi -LDFLAGS="$LDFLAGS -arch x86_64" +echo "ARCHITECTURE BREAKDOWN" +echo $ARCH +echo $HOST_PLATFORM -# Some libs want this passed to configure for cross compilation. -HOST_PLATFORM="--host=x86_64-apple-darwin" +CFLAGS="$CFLAGS -arch $ARCH" +CXXFLAGS="$CXXFLAGS -arch $ARCH" + +LDFLAGS="$LDFLAGS -arch $ARCH" # CMake doesn't seem to pick up on architecture with CFLAGS only -CMAKE_FLAGS="-DCMAKE_OSX_ARCHITECTURES=x86_64" +CMAKE_FLAGS="-DCMAKE_OSX_ARCHITECTURES=$ARCH" JOBS=${JOBS:="-j2"} @@ -830,7 +846,7 @@ echo -e "Building ICU..." LIB_VERSION="${ICU_VERSION}" LIB_ARCHIVE="$LIB_VERSION-src.tgz" LIB_DIRECTORY="icu" -LIB_URL="https://github.com/unicode-org/icu/releases/download/release-67-1/" +LIB_URL="https://github.com/unicode-org/icu/releases/download/release-69-1/" mkdir -p icu pushd icu > /dev/null @@ -1039,7 +1055,7 @@ then fi # Use the regular build script for SM. -JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ./build.sh || die "Error building spidermonkey" +JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ARCH="$ARCH" ./build.sh || die "Error building spidermonkey" popd > /dev/null diff --git a/source/graphics/Color.cpp b/source/graphics/Color.cpp index a5e4b142ea..49e6adad8f 100644 --- a/source/graphics/Color.cpp +++ b/source/graphics/Color.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -83,8 +83,9 @@ void ColorActivateFastImpl() ConvertRGBColorTo4ub = ConvertRGBColorTo4ubSSE; return; } -#endif +#elif defined(ARCH_X86_64) debug_printf("No SSE available. Slow fallback routines will be used.\n"); +#endif } /** diff --git a/source/tools/dist/build-osx-executable.sh b/source/tools/dist/build-osx-executable.sh index 13a170c44b..cb83e52bb4 100755 --- a/source/tools/dist/build-osx-executable.sh +++ b/source/tools/dist/build-osx-executable.sh @@ -2,8 +2,7 @@ # Build the Pyrogenesis executable, used to create the bundle and run the archiver. -# TODO: is there anything to do for ARM support? -export ARCH=${ARCH:="x86_64"} +export ARCH=${ARCH:=$(uname -m)} # Set mimimum required OS X version, SDK location and tools # Old SDKs can be found at https://github.com/phracker/MacOSX-SDKs