Contents

RapidNJ for M1 macs

Contents

RapidNJ is a really nice program for making neighbour-joining trees from distance matrices or alignment data.

If you try and compile on an M1 Mac however, you’ll get errors that look like this:

In file included from src/main.cpp:1:
In file included from src/stdinclude.h:9:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/emmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
#error "This header is only meant to be used on x86 and x64 architecture"

These Intel intrinsics in emmintrin.h aren’t supported on ARM CPUs, such as the M1/M2 seen in recent Macbooks. Fortunately there’s an easy enough three step solution, thanks to sse2neon:

  1. Save this file in the src/ dir: https://github.com/DLTcollab/sse2neon/blob/master/sse2neon.h
  2. In src/stdinclude.h and src/distanceCalculation/bitDistanceProtein.cpp change the line #include <emmintrin.h> at the top to #include "sse2neon.h"
  3. Change the following in Makefile:
-OPTIMIZATION_LEVEL=-O3 -msse2
+OPTIMIZATION_LEVEL=-O3 -march=armv8-a+fp+simd+crypto+crc

Then you can run make and you get the binary in bin/rapidnj.

I’ve also forked the repo and made these changes, so you can just run make after cloning, without having to do the steps above.