plasma-umass / Mesh

A memory allocator that automatically reduces the memory footprint of C/C++ applications.
Apache License 2.0
1.75k stars 73 forks source link

Support for ARM64 #50

Open drake7707 opened 5 years ago

drake7707 commented 5 years ago

I tested a building and running it on an ODROID N2, which is an ARM64 and it seems to work but I needed to do a few small changes, I had to disable modern_cpu manually because the current statement threw an 'Index out of range' and I had to change the unistd_64 import to unistd as it didn't exist.

Linux odroid 4.9.187-53 #1 SMP PREEMPT Fri Aug 9 06:12:18 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

Diff:

diff --git a/configure b/configure
index 0e84ff6..4ea969f 100755
--- a/configure
+++ b/configure
@@ -46,9 +46,10 @@ modern_cpu = True
 if system() == 'Linux':
     # we need to check if the CPU is recent enough to use popcnt and
     # AVX instructions
-    cpuinfo = slurp('/proc/cpuinfo').splitlines()
-    flags = [l for l in cpuinfo if l.startswith('flags')][0]
-    modern_cpu = 'popcnt' in flags and 'avx' in flags
+    #cpuinfo = slurp('/proc/cpuinfo').splitlines()
+    #flags = [l for l in cpuinfo if l.startswith('flags')][0]
+    #modern_cpu = 'popcnt' in flags and 'avx' in flags
+    modern_cpu = 0

 if modern_cpu:
     c.append('cflags', '-march=westmere')
diff --git a/src/meshable_arena.cc b/src/meshable_arena.cc
index b325531..023b2a5 100644
--- a/src/meshable_arena.cc
+++ b/src/meshable_arena.cc
@@ -15,7 +15,7 @@
 #include <unistd.h>

 //#include <sys/memfd.h>
-#include <asm/unistd_64.h>
+#include <asm/unistd.h>
 #include <linux/memfd.h>
 #endif

I think these same changes are required for an 64-bit OS on a raspberry PI.

bpowers commented 5 years ago

ah, this is great, thanks! I'll look at incorporating into the standard build system

tuyend97 commented 3 years ago

Hi can you let me know how you can build it on linux with architecture arm by cross compile

kov commented 2 years ago

Any plans to support this? I would love to use mesh on my Linux VM in my Apple Silicon macbook pro (and possibly on my graviton 2 aws vps too).