Hi there:

I am trying to get ISSM compiled on a new MacBook Pro with an Apple M1 Pro chip. However, I'm running into issues right off the bat. I am running macOS Monterey (Version 12.1).

When trying to install autotools packages using the install-mac.sh script, I can successfully install m4, autoconf, and automake. However, I get a "Version mismatch error" when Libtool is attempted:

libtool: Version mismatch error. This is libtool 2.4.2, revision 1.3337,
libtool: but the definition of this LT_INIT comes from revision .
libtool: You should recreate aclocal.m4 with macros from revision 1.3337
libtool: of libtool 2.4.2 and run autoconf again.
make[2]: *** [libltdl/loaders/libltdl_libltdl_la-preopen.lo] Error 63
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

I tried running "autoreconf --force --install", but all things continued to point toward LT_INIT. I dug a little deeper and found "LT_INIT([dlopen win32-dll])" in the configure.ac file in autotools/src. By changing this line to simply "LT_INIT" (i.e., removing the ([dlopen win32-dll])), I was able to get libtool to install. However I am not sure that this is the correct solution.

Continuing on, I was able to successfully install cmake, but ran into issues with petsc (specifically HDF5). Reviewing the configure.log file, I found this error:

configure:7935: /Users/lbir0005/ISSM/trunk/externalpackages/petsc/install/bin/mpif90 -o conftest -I. -fallow-argument-mismatch -g -O -fallow-argument-mismatch conftest.f90 -Wl,-rpath,/Users/lbir0005/ISSM/trunk/externalpackages/petsc/install/lib -L/Users/lbir0005/ISSM/trunk/externalpackages/petsc/install/lib -lz >&5
configure:7935: $? = 0
configure:7935: ./conftest
configure:7935: $? = 0
configure:7996: result: Error
configure:7998: error: No output from Fortran test program!

I checked my gfortran install and am able to compile a simple fortran program with gfortran outside of the ISSM install. I'd be curious to hear if others are compiling ISSM on the new M1 chips and if anybody is having similar issues!

Thanks for any advice here.

Lawrence

  • sithubdelhi123 likes this.
  • Hi guys,

    we got it to work this morning! The caveat is that you need to use the mex binaries that are on the website because they were compiled for x86_64, which MATLAB understands. Here are the steps:

    • Download ISSM
    • Install the following external packages: autotools, cmake, and PETSc (install-3.17-mac-m1.sh) (do NOT use Homebrew or Macports)
    • use the following ISSM configure.sh file:
      export FFLAGS=" -arch arm64"
      export CFLAGS=" -arch arm64"
      export LDFLAGS=" -arch arm64"
      export CXXFLAGS=" -arch arm64"
      
      ./configure \
         --without-Love --without-kml --without-Sealevelchange \
         --prefix=$ISSM_DIR \
         --without-wrappers \
         --enable-debugging \
         --enable-development \
         --with-mpi-include="$ISSM_DIR/externalpackages/petsc/install/" \
         --with-mpi-libflags="-L$ISSM_DIR/externalpackages/petsc/install/ -lmpich" \
         --with-petsc-dir="$ISSM_DIR/externalpackages/petsc/install" \
         --with-metis-dir="$ISSM_DIR/externalpackages/petsc/install" \
         --with-scalapack-dir="$ISSM_DIR/externalpackages/petsc/install/" \
         --with-mumps-dir="$ISSM_DIR/externalpackages/petsc/install/" \
         --with-numthreads=4
      then
      cd $ISSM_DIR
      autoreconf -ivf
      ./configure.sh
      make -j4 install

    Once ISSM is compiled (natively) successfully, you need to download ISSM's binaries from https://issm.jpl.nasa.gov/download/binaries/. Copy the lib directory to $ISSM_DIR/lib2 and add lib2 to your MATLAB path, and VOILA!
    Enjoy
    Mathieu

Hi Lawrence

That is weird! We successfully compiled all external packages on M1 chips.
Now... we are still trying to figure out how to compile MATLAB mex files because MATLAB does not support native compilation on M1 chips 🙁 we are trying to find a workaround but it seems like for now we need to wait for MATLAB to release an update. If you have ideas, let us know!
Mathieu

Hi Mathieu:

Thanks for your quick reply. It sounds like I have bigger problems down the road, aside from issues with the external packages! Thanks for the note on this - I will let you know if I come across anything that might be helpful!

Lawrence

    lawrence-bird
    Hi Lawrence,
    As Mathieu noted, if you intend to use MATLAB, it does not currently support compilation of MEX modules on the M1 chip.

    Regarding libtool under macOS Monterey, I just encountered this issue the other day and the fix will be applied to our next update: simply change line 9 to read LIBTOOL_VER="2.4.6".

      justinquinn

      Thanks Justin - that was an easy fix! Libtool is now taken care of.

      I'm still having issues with petsc - which version of the install script would you recommend using, and which version of gfortran? I have gfortran version 11.2.0 which appears to be the latest release, but is intended for intel processors. I wonder if this might be my issue. When I try the install-3.14-mac.sh script, it fails with the following error:

      *******************************************************************************
               UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):
      -------------------------------------------------------------------------------
      Unknown Fortran name mangling: Are you sure the C and Fortran compilers are compatible?
        Perhaps one is 64 bit and one is 32 bit?
        See https://www.mcs.anl.gov/petsc/documentation/faq.html#gfortran
      *******************************************************************************

      I checked the type of compilers I have:

      • /usr/local/bin/gfortran: Mach-O 64-bit executable x86_64
      • /usr/bin/gcc: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
      • /usr/bin/gcc (for architecture x86_64): Mach-O 64-bit executable x86_64
      • /usr/bin/gcc (for architecture arm64e): Mach-O 64-bit executable arm64e

      Based on this, I tried to force the script to run using the x86_64 architecture, since I don't have an arm64 version of gfortran. I used "arch -x86_64e ./install-3.14-mac.sh" and the install progressed further, but gets hung up on HDF5 (see my first post for that error). When trying the install-3.15-mac-arm.sh script, I get the following error:

      *******************************************************************************
               UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):
      -------------------------------------------------------------------------------
      Could not locate a functional C compiler
      *******************************************************************************

      I'm missing something here, but struggling to figure out exactly what it is!

      Thanks for your advice.

      Lawrence

        lawrence-bird
        Glad to hear that worked.

        To reiterate, once you have the external packages built, you will have to use the Python API for ISSM until MathWorks have updated MATLAB. If that is okay with you, I can help you with a configuration that works for me under Monterey (I do not have a machine with the M1 chipset, so hopefully we do not hit any snags in that respect).

        mathieumorlighem
        Hi Mathieu:

        I'd tried that install script too, but it was failing with an error around being unable to find a functional C compiler (see second error included on my post above).

        Thanks.

        Lawrence

          justinquinn
          Hi Justin:

          The Forum doesn't appear to let me upload a *.log or a *.txt file - is there perhaps an email I can send the configure.log to you at?

          As for using Python, I am okay with that for now - hopefully an update to MATLAB is released in the not too distant future.

          @mathieumorlighem - thanks for the note on gfortran. I'll see if Justin spots anything obvious in the configure.log, otherwise I'll definitely try a different gfortran version.

          Thank you both for your help - I appreciate it!

          Lawrence

            lawrence-bird

            That is odd indeed. I'll have to look further into this restriction.

            That said, I suspect Mathieu is correct: it is likely due to having a copy of gfortran that is not designed to compile for the M1 target.

              @justinquinn @mathieumorlighem

              Hi Justin/Mathieu:

              Updating gfortran to an experimental ARM version for MacOS Monterey (gfortran 12-experimental for ARM, macOS 12 (Monterey)) did indeed allow me to successfully install PETSc. That said, I was able to install all external packages.

              Moving on to the next step, ISSM appears to configure successfully, but is failing during make. I am receiving the following error:

              ld: file not found: @rpath/libgcc_s.1.1.dylib for architecture arm64
              clang: error: linker command failed with exit code 1 (use -v to see invocation)

              It seems to be something to do with gcc; however, when I interrogate the gcc version on my system (below), it looks like there is a gcc version suitable for arm64:

              $ which gcc
              /usr/bin/gcc

              $ file /usr/bin/gcc
              /usr/bin/gcc: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
              /usr/bin/gcc (for architecture x86_64): Mach-O 64-bit executable x86_64
              /usr/bin/gcc (for architecture arm64e): Mach-O 64-bit executable arm64e

              $ gcc --version
              Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
              Apple clang version 13.0.0 (clang-1300.0.29.30)
              Target: arm64-apple-darwin21.2.0
              Thread model: posix
              InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

              If you have any ideas on this, I'm all ears!

              Thanks.

              Lawrence

                lawrence-bird Okay, you may have to,

                export LD_LIBRARY_PATH=/usr/local/gfortran/lib:${LD_LIBRARY_PATH}
                export DYLD_LIBRARY_PATH=/usr/local/gfortran/lib:${DYLD_LIBRARY_PATH}

                in your shell profile (the above assumes bash). You may be able to test this ahead of time by exporting (or otherwise setting these environment variables) directly in the terminal instance and recompiling.

                  justinquinn

                  Hi Justin - I implemented this, but the same error persists, unfortunately. I assume this would not affect the external package installations and I don't need to recompile those?

                    justinquinn

                    I am not sure if it's relevant where this error is occurring during the make process, but this is the full error:

                    ld: file not found: @rpath/libgcc_s.1.1.dylib for architecture arm64
                    clang: error: linker command failed with exit code 1 (use -v to see invocation)
                    make[3]: *** [libISSMCore.la] Error 1
                    make[2]: *** [all-recursive] Error 1
                    make[1]: *** [all-recursive] Error 1
                    make: *** [all] Error 2

                    This is preceded by a number of warnings similar to this:

                    *** Warning: Linking the shared library libISSMCore.la against the
                    *** static library /Users/lbir0005/ISSM/trunk/externalpackages/m1qn3/install/libddot.a is not portable!
                    ld: warning: object file (./modules/FourierLoveCorex/.libs/lnb_param.o) was built for newer macOS version (12.1) than being linked (12.0)