ad-freiburg / loom

Software suite for the automated generation of geographically correct or schematic transit maps.
GNU General Public License v3.0
132 stars 12 forks source link

Build fails on macOS arm64 #6

Closed ivyrze closed 2 years ago

ivyrze commented 2 years ago

I'm trying to build the project from an M1-based Mac and it fails with a ton of errors relating to ia32, aka i386/x86. The GitHub Actions runner for macOS seems to be passing for the latest commit, but I believe this is because they exclusively use Intel-based runners.

The cmake build step works, the errors are on make. Here are the first few lines of output:

/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
    ~~~~~~~~~~~~~~~~~~~~^
/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);

/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
    return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);

Thanks so much for your work on this project.

patrickbr commented 2 years ago

It seems like clang is calling x86 versions of internal functions for some reason, but I am not entirely sure why. Could you go into your build folder and do a

grep -rn 'march'

and post the output here? Could you also make sure that you have the latest versions of clang and cmake on your system?

Could you also post the complete error log?

ivyrze commented 2 years ago

The grep search didn't return any matches.

These are my installed clang and cmake versions:

> clang -v
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.6.0

> cmake --version
cmake version 3.24.1

And here is the full log for both build commands: error.log.

I was able to get the build working by uninstalling everything (Homebrew, cmake, glpk) and reinstalling the x86 versions through Rosetta with arch -x86_64 [COMMAND]. Still not ideal but just confirming that it is relating to the architecture.

patrickbr commented 2 years ago

I think I found the culprit based on your error.log. There was an #include of immintrin.h in util/Misc.h, which was once used for an experimental fast inverse square root implementation. It is not used anywhere in the codebase. I removed it with the latest commit, can you check again if everything compiles now on arm64?

ivyrze commented 2 years ago

That did the trick, everything is building successfully now. Thanks again!