Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile on macOS, ARM64 #126

Closed
victorlin opened this issue Mar 15, 2023 · 7 comments
Closed

Unable to compile on macOS, ARM64 #126

victorlin opened this issue Mar 15, 2023 · 7 comments

Comments

@victorlin
Copy link

I am following the compilation guide.

cmake is successful, however make -j gives several warnings/errors. Some notable lines (full output):

clang: error: the clang compiler does not support '-march=native'

clang: warning: argument unused during compilation: '-msse3' [-Wunused-command-line-argument]

vectorclass/vectorclass.h:38:4: error: Please compile for the SSE2 instruction set or higher

vectorclass/vectormath_common.h:65:8: error: unknown type name 'Vec2d'

vectorclass/instrset_detect.cpp:26:10: error: couldn't allocate output register for constraint 'a'

/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/xmmintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"

/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:54:12: error: invalid conversion between vector type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size

Is there something I am missing here?

@victorlin
Copy link
Author

I can confirm all the requirements are met:

  • C++

    details
    % which c++
    /usr/bin/c++
    
  • CMake version >= 2.8.10

    details
    % cmake --version
    cmake version 3.26.0
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).
    
  • Boost library

    details

    From the output of cmake:

    -- Found Boost: /opt/homebrew/Caskroom/miniconda/base/envs/build-iqtree/lib/cmake/Boost-1.81.0/BoostConfig.cmake (found version "1.81.0")  
    
  • Eigen3 library

    details
    % brew info eigen 
    ==> eigen: stable 3.4.0 (bottled), HEAD
    C++ template library for linear algebra
    https://eigen.tuxfamily.org/
    Conflicts with:
      freeling (because freeling ships its own copy of eigen)
    /opt/homebrew/Cellar/eigen/3.4.0_1 (546 files, 8.4MB) *
      Poured from bottle on 2023-03-15 at 16:19:46
    
  • OpenMP library

    details
    % brew info libomp
    ==> libomp: stable 15.0.5 (bottled) [keg-only]
    LLVM's OpenMP runtime library
    https://openmp.llvm.org/
    /opt/homebrew/Cellar/libomp/15.0.5 (7 files, 1.6MB)
      Poured from bottle on 2022-11-28 at 17:19:46
    

@victorlin
Copy link
Author

Oh, I just realized I am using an older version (2.1.2, the latest GitHub Release) which does not include 44bfe3d. I tried using v2.2.2.3 but am now facing a cmake error. I will investigate more tomorrow.

@bqminh
Copy link
Member

bqminh commented Mar 16, 2023 via email

@corneliusroemer
Copy link
Contributor

corneliusroemer commented May 26, 2023

I managed to compile (on arm 12/13) with the following homebrew recipe (should make it possible to reproduce for anyone without differing local setup): https://github.com/Homebrew/homebrew-core/blob/573b15f29e31ba4143ae8137111cf87a3f181829/Formula/iqtree2.rb

The gist is:

    inreplace "CMakeLists.txt", "--target=arm64-apple-macos10.5", "-mmacosx-version-min=10.7"
    inreplace "CMakeLists.txt", "--target=arm64-apple-macos12.0.1", "-mmacosx-version-min=12.0.1"
    mkdir "build" do
      system "cmake", "..", "-DIQTREE_FLAGS=omp", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"
      system "make", "-j"
      bin.install "iqtree2"
    end

But compared with using the official osx-64 binary, iqtree seems to get stuck a lot in substitution model fitting with errors/warnings like:

ERROR: Numerical underflow (lh-derivative). Run again with the safe likelihood kernel via -safe option

Running the official osx-64 binary, I don't get any such warning.

@thomaskf
Copy link
Collaborator

thomaskf commented May 27, 2023 via email

@iqtree
Copy link
Collaborator

iqtree commented Mar 28, 2024

We now added support for Apple M chips in v2.3.X

@corneliusroemer
Copy link
Contributor

Thank you, that's great! I managed to compile after experimenting a bit. This is the recipe that worked in the end. Could you check whether that's the same you use? I couldn't find up to date documentation on how exactly you build on arm macs.

This worked for me:

gh repo clone iqtree/iqtree2
cd iqtree2
git submodule init
git submodule update
mkdir build
cd build
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-Dthread_local=" ..
make -j

Also see my docs PR at iqtree/iqtree.github.io#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants