|
From: Chris C. <ca...@al...> - 2020-12-30 17:19:48
|
Here is a small update to that patch. With this applied against present git (0cd273551):
- a plain "make all" on an ARM Mac will produce an arm64 MLton
- you can alternatively build an amd64 MLton using "arch -x86_64 make all"
You'll see that I added a couple of lines to mlton-script for amd64-darwin as well as the arm64 ones - that's partly for symmetry and partly because I think these are necessary if you ever want to use an installed arm64 MLton to build a new amd64 one (I've just checked this and it does work as you'd hope).
The only small disappointment is that the arm64 build is actually slower to compile an SML program than an amd64 MLton with the amd64 codegen on the same hardware, even though the latter compiler is running in Rosetta. It does compile faster than the amd64 MLton with C codegen, but the C codegen is (on this platform at least) substantially slower than the amd64 one, and having the MLton binary be native isn't enough to make up the difference. The generated code has been faster for the things I've checked so far though, so I'm ok with the tradeoff.
I'm happy with this for my own purposes as it stands - many thanks for the help!
Chris
diff --git a/bin/mlton-script b/bin/mlton-script
index 2e9f0d78d..4a69d0835 100644
--- a/bin/mlton-script
+++ b/bin/mlton-script
@@ -93,6 +93,8 @@ doit "$lib" \
'-mieee -mbwx -mtune=ev6 -mfp-rounding-mode=d' \
-target-cc-opt amd64 '-m64' \
-target-cc-opt aix '-maix64' \
+ -target-cc-opt amd64-darwin '-arch x86_64' \
+ -target-cc-opt arm64-darwin '-arch arm64' \
-target-cc-opt ia64-hpux "-mlp64" \
-target-cc-opt ia64 "-mtune=itanium2" \
-target-cc-opt sparc '-m32 -mcpu=v8 -Wa,-xarch=v8plusa' \
@@ -101,6 +103,8 @@ doit "$lib" \
-target-link-opt alpha \
'-mieee -mbwx -mtune=ev6 -mfp-rounding-mode=d' \
-target-link-opt aix '-maix64' \
+ -target-link-opt amd64-darwin '-arch x86_64' \
+ -target-link-opt arm64-darwin '-arch arm64' \
-target-link-opt ia64-hpux "-mlp64" \
-target-link-opt linux '-Wl,-znoexecstack' \
-target-link-opt mingw \
diff --git a/bin/platform b/bin/platform
index fed549259..999be668b 100755
--- a/bin/platform
+++ b/bin/platform
@@ -88,12 +88,15 @@ i?86_64)
amd64)
HOST_ARCH=amd64
;;
-arm*)
- HOST_ARCH=arm
+arm64)
+ HOST_ARCH=arm64
;;
aarch64)
HOST_ARCH=arm64
;;
+arm*)
+ HOST_ARCH=arm
+;;
parisc*)
HOST_ARCH=hppa
;;
diff --git a/mlton/control/control-flags.sml b/mlton/control/control-flags.sml
index 23a3f7388..04107c820 100644
--- a/mlton/control/control-flags.sml
+++ b/mlton/control/control-flags.sml
@@ -219,7 +219,7 @@ val chunkMustRToSingOpt = control {name = "chunkMustRToSingOpt",
default = true,
toString = Bool.toString}
val chunkTailCall = control {name = "chunkTailCall",
- default = true,
+ default = false,
toString = Bool.toString}
val closureConvertGlobalize = control {name = "closureConvertGlobalize",
diff --git a/runtime/platform/darwin.c b/runtime/platform/darwin.c
index b3e8e13b4..0ddf80c03 100644
--- a/runtime/platform/darwin.c
+++ b/runtime/platform/darwin.c
@@ -38,6 +38,12 @@ static void catcher (__attribute__ ((unused)) int signo,
#else
GC_handleSigProf ((code_pointer) ucp->uc_mcontext->ss.rip);
#endif
+#elif (defined(__aarch64__))
+#if __DARWIN_UNIX03
+ GC_handleSigProf ((code_pointer) ucp->uc_mcontext->__ss.__pc);
+#else
+ GC_handleSigProf ((code_pointer) ucp->uc_mcontext->ss.pc);
+#endif
#else
#error Unsupported darwin CPU architecture
#endif
|