aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Rowe <wiremoons@users.noreply.github.com>2023-05-28 15:08:14 +0100
committerGitHub <noreply@github.com>2023-05-28 15:08:14 +0100
commitd167d18bb32cb03d82e1ff7265b6bd6248bd53d7 (patch)
treecb36d624c79956dc3c531a6b6e402c864f6e3e96
parent508d7c3336319a60ff74695d69d7ad9648c5f3b2 (diff)
Update build_odin.sh to better support optimisation on Arm CPUs
The `build_odin` flags include the option `release-native`. The current `EXTRAFLAGS` set however don't work for Arm CPUs as they dont support `-march=native`. Added code to detect CPU and either set the preferred flag for Arm CPUs (ie `-mcpu=native`) or keep the current default. Information on preferred Arm CPU optimisation flag taken from here: https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu Changes tested on an Apple Silicon M1 CPU (arm64) using HomeBrew installed llvm as follows: ``` Homebrew clang version 14.0.6 Target: arm64-apple-darwin22.5.0 Thread model: posix InstalledDir: /opt/homebrew/opt/llvm@14/bin ```
-rwxr-xr-xbuild_odin.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/build_odin.sh b/build_odin.sh
index 93d6a979c..9b90a80e2 100755
--- a/build_odin.sh
+++ b/build_odin.sh
@@ -135,7 +135,14 @@ build_odin() {
EXTRAFLAGS="-O3"
;;
release-native)
- EXTRAFLAGS="-O3 -march=native"
+ local ARCH=$(uname -m)
+ if [ "${ARCH}" == "arm64" ]; then
+ # Use preferred flag for Arm (ie arm64 / aarch64 / etc)
+ EXTRAFLAGS="-O3 -mcpu=native"
+ else
+ # Use preferred flag for x86 / amd64
+ EXTRAFLAGS="-O3 -march=native"
+ fi
;;
nightly)
EXTRAFLAGS="-DNIGHTLY -O3"