Commit dca5e5b4 authored by nanahira's avatar nanahira

add optimization for arm

parent 931e4fc4
Pipeline #34565 canceled with stages
in 23 seconds
......@@ -22,7 +22,7 @@ build_single_thing() {
cd "external/$lib_name"
shift
maybe_patch_configure
PKG_CONFIG_PATH="$external_built_dir/lib/pkgconfig" ./configure --prefix="$external_built_dir" --enable-static=yes --enable-shared=no "$@"
PKG_CONFIG_PATH="$external_built_dir/lib/pkgconfig" CFLAGS="$OPUS_FLAGS" CXXFLAGS="$OPUS_FLAGS" ./configure --prefix="$external_built_dir" --enable-static=yes --enable-shared=no "$@"
make -j$(nproc)
make install
cd ../..
......
......@@ -8,9 +8,9 @@ if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=linux
fi
if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
#if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
ARCHIVE_FILES+=(sound)
fi
#fi
apt update && apt -y install tar zstd
mkdir dist replay
......
......@@ -10,9 +10,9 @@ if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=linux
fi
if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
#if [[ "$TARGET_PLATFORM" != "linuxarm" ]]; then
ARCHIVE_FILES+=(sound)
fi
#fi
apt update && apt -y install tar git zstd
mkdir dist replay
......
......@@ -160,6 +160,8 @@ exec_linuxarm:
extends: .exec_linux
tags:
- arm
variables:
OPUS_FLAGS: '-fFPIC' # force position independent code for arm
._exec_macos_platform:
extends: ._exec_build
......@@ -183,8 +185,8 @@ exec_macos_platform_m1:
extends: ._exec_macos_platform
tags:
- macos-m1
variables:
MAC_ARM: 1
#variables:
# MAC_ARM: 1
exec_macos:
stage: combine
......
......@@ -271,13 +271,70 @@ end
if GetParam("winxp-support") and os.istarget("windows") then
WINXP_SUPPORT = true
end
if os.istarget("macosx") then
MAC_ARM = false
if GetParam("mac-arm") then
MAC_ARM = true
IS_ARM=false
function spawn(cmd)
local handle = io.popen(cmd)
if not handle then
return nil
end
local result = handle:read("*a")
handle:close()
if result and #result > 0 then
return result
else
return nil
end
end
function isRunningUnderRosetta()
local rosetta_result=spawn("sysctl -n sysctl.proc_translated 2>/dev/null")
return rosetta_result=(tonumber(rosetta_result) == 1)
end
function IsRunningUnderARM()
-- os.hostarch() is over premake5 beta3,
if os.hostarch then
local host_arch = os.hostarch()
local possible_archs = { "ARM", "ARM64", "loongarch64", "armv5", "armv7", "aarch64" }
for _, arch in ipairs(possible_archs) do
if host_arch:lower():match(arch:lower()) then
return true
end
end
else
-- use command 'arch' to detect the architecture on macOS or Linux
local arch_result = spawn("arch 2>/dev/null")
if arch_result then
arch_result = arch_result:lower():gsub("%s+", "")
if arch_result == "arm64" or arch_result == "aarch64" then
return true
elseif arch_result == "arm" or arch_result == "armv7" or arch_result == "armv5" then
return true -- for ARMv5, ARMv7, etc.
elseif arch_result == "loongarch64" then
return true -- for loongarch64
end
end
end
return false
end
function isARM()
if IsRunningUnderARM() then
return true
end
if os.istarget("macosx") and isRunningUnderRosetta() then
-- macOS under rosetta will report x86_64, but it is running on ARM
print("Detected running under Rosetta on macOS, treating as ARM")
return true
end
return false
end
IS_ARM=isARM() or GetParam("mac-arm") -- detect if the current system is ARM
MAC_ARM=os.istarget("macosx") and IS_ARM
workspace "YGOPro"
location "build"
language "C++"
......@@ -339,9 +396,17 @@ workspace "YGOPro"
filter { "configurations:Release", "not action:vs*" }
symbols "On"
defines "NDEBUG"
if not MAC_ARM then
if not IS_ARM then
buildoptions "-march=native"
end
if IS_ARM and not MAC_ARM then
buildoptions {
"-march=armv8-a",
"-mtune=cortex-a72",
"-fPIC",
"-Wno-psabi"
}
end
filter { "configurations:Debug", "action:vs*" }
disablewarnings { "6011", "6031", "6054", "6262" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment