Installation on M1 mac

GROMACS version: GROMACS 2021.4
GROMACS modification: No
Here post your question
Hi,
I am following this protocol:

  1. Get the latest version of your C and C++ compilers.
  2. Check that you have CMake version 3.13 or later.
  3. Get and unpack the latest version of the GROMACS tarball.
  4. Make a separate build directory and change to it.
  5. Run cmake with the path to the source as an argument
  6. Run make , make check , and make install
  7. Source GMXRC to get access to GROMACS
    Installation guide — GROMACS 2021.4 documentation

It fails at 6 when I do ‘make’
checking size of size_t… configure: error: in /Applications/gromacs-2021.4/build/src/external/build-fftw/fftwBuild-prefix/src/fftwBuild-build': configure: error: cannot compute sizeof (size_t) See config.log’ for more details
make[2]: *** [src/external/build-fftw/fftwBuild-prefix/src/fftwBuild-stamp/fftwBuild-configure] Error 77
make[1]: *** [src/external/build-fftw/CMakeFiles/fftwBuild.dir/all] Error 2
make: *** [all] Error 2

I run in on a MAC M1 OSX11.6, with Xcode
cmake --version
cmake version 3.22.0

g++ --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.3)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

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.3)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Any idea of what to do would be greatly appreciated.
Many thanks in advance

Julien

Hi,
you can try to use -DGMX_BUILD_OWN_FFTW=ON
\Alessandra

Dear Alevilla,
Thanks for your input, but it does not work.

I do (point 5)
‘cmake … -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON’
and that runs fine.

It fails at 6 when I do ‘make’
checking size of size_t… configure: error: in /Applications/gromacs-2021.4/build/src/external/build-fftw/fftwBuild-prefix/src/fftwBuild-build': configure: error: cannot compute sizeof (size_t) See config.log’ for more details

‘make -DGMX_BUILD_OWN_FFTW=ON’ is not possible.

best
julien

Problem is occuring in the fftw configure before build. It is possible that the automatic configure/build is not suitable for M1, or to your compilation environement. Perhaps you could build fftw separately to isolate what is causing it.

Get the fftw source from their website, then ./configure --prefix ~/(some directory to install to) --enable-single --with-pic --disable-fortran --disable-mpi --disable-threads --enable-shared --disable-static, then make. (NB: this is not necessarily the best build option for the platform in term of optimization)

if perchance the problem does not appear when building ffttw standalone, you can change the gromacs cmake options to -DGMX_BUILD_OWN_FFTW=OFF -DFFTWF_LIBRARY=/{prefix where fftw is installed}/lib64/libfftw3f.so -DFFTWF_INCLUDE_DIR=/{prefix where fftw is installed}/include . If so, you may want to rebuild fftw with the appropriate optimization flag (probably something like --enable-generic-simd128 or --enable-neon ?).

Hi, thanks for the input.
Indeed it gives the same error when trying to install separately.
But I do not understand the problem here too.

fftw-3.3.10 % ./configure --prefix /Applications/fftw-3.3.10/fftw --enable-single --with-pic --disable-fortran --disable-mpi --disable-threads --enable-shared --disable-static

checking whether time.h and sys/time.h may both be included… no
checking for long double… yes
checking for hrtime_t… no
checking size of int… 0
checking size of unsigned int… 0
checking size of long… 0
checking size of unsigned long… 0
checking size of long long… 0
checking size of unsigned long long… 0
checking size of size_t… configure: error: in /Applications/fftw-3.3.10': configure: error: cannot compute sizeof (size_t) See config.log’ for more details

In the config.log there is 349 ‘error’.
The first error enconter is:

configure:4443: gcc --version >&5
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: arm64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
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
configure:4454: ? = 0 configure:4443: gcc -v >&5 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.3) Target: arm64-apple-darwin20.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin configure:4454: ? = 0
configure:4443: gcc -V >&5
clang: error: argument to ‘-V’ is missing (expected 1 value)
clang: error: no input files
configure:4454: ? = 1 configure:4443: gcc -qversion >&5 clang: error: unknown argument '-qversion'; did you mean '--version'? clang: error: no input files configure:4454: ? = 1
configure:4474: checking whether the C compiler works
configure:4496: gcc conftest.c >&5
configure:4500: $? = 0
configure:4548: result: yes

The first error associated to ‘size_t’ is:
configure:16061: checking for size_t
configure:16061: gcc -c -O3 -fomit-frame-pointer -mtune=native -fstrict-aliasing conftest.c >&5
configure:16061: ? = 0 configure:16061: gcc -c -O3 -fomit-frame-pointer -mtune=native -fstrict-aliasing conftest.c >&5 conftest.c:63:21: error: expected expression if (sizeof ((size_t))) ^ 1 error generated. configure:16061: ? = 1
configure: failed program was:
| /* confdefs.h /
| #define PACKAGE_NAME “fftw”
| #define PACKAGE_TARNAME “fftw”
| #define PACKAGE_VERSION “3.3.10”
| #define PACKAGE_STRING “fftw 3.3.10”
| #define PACKAGE_BUGREPORT “fftw@fftw.org
| #define PACKAGE_URL “”
| #define PACKAGE “fftw”
| #define VERSION “3.3.10”
| #define FFTW_ENABLE_ALLOCA 1
| #define FFTW_SINGLE 1
| #define BENCHFFT_SINGLE 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR “.libs/”
| #define HAVE_FCNTL_H 1
| #define HAVE_FENV_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_SYS_TIME_H 1
| /
end confdefs.h. */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| # include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| if (sizeof ((size_t)))
| return 0;
| ;
| return 0;
| }
configure:16061: result: yes
configure:16072: checking for uint32_t

Thanks!

Unfortunately, none of these errors are actually errors. (some of the tests the configure script runs are actually expected to fail, so searching for “error” do not necessarily give results. For instance here, sizeof((size_t)) should not compile - if it did, this means size_t is not a type but a variable, which is the actual problem the test is trying to detect)

Can you search in config.log for “checking size of size_t” (full line “configure:16363: checking size of size_t”) and post the surrounding ?

For reference, you can post code verbatim like so:

```
the code
```

Oh Sorry!
Please find enclosed the config.log part where the error arise

configure:16393: result: 0
configure:16407: checking size of size_t
configure:16412: gcc -o conftest -O3 -fomit-frame-pointer -mtune=native -fstrict-aliasing   conftest.c  >&5
In file included from conftest.c:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:66:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:202:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:216:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:236:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:258:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:289:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:328:2: error: unknown type name 'uint8_t'
        uint8_t  ri_uuid[16];
        ^
In file included from conftest.c:70:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:66:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h:186:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/endian.h:37:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/endian.h:77:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_endian.h:130:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrder.h:80:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:14:1: error: unknown type name 'uint16_t'
uint16_t
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:16:2: error: unknown type name 'uint16_t'
        uint16_t        _data
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:20:10: error: use of undeclared identifier 'uint16_t'
        return (uint16_t)(_data << 8 | _data >> 8);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:65:11: error: unknown type name 'uint16_t'
        volatile uint16_t __val;
                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:88:1: error: unknown type name 'uint16_t'
uint16_t
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/OSByteOrder.h:161:2: error: unknown type name 'uint16_t'
        uint16_t        _data
        ^
12 errors generated.
configure:16412: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "fftw"
| #define PACKAGE_TARNAME "fftw"
| #define PACKAGE_VERSION "3.3.8"
| #define PACKAGE_STRING "fftw 3.3.8"
| #define PACKAGE_BUGREPORT "fftw@fftw.org"
| #define PACKAGE_URL ""
| #define PACKAGE "fftw"
| #define VERSION "3.3.8"
| #define FFTW_ENABLE_ALLOCA 1
| #define FFTW_SINGLE 1
| #define BENCHFFT_SINGLE 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define HAVE_FCNTL_H 1
| #define HAVE_FENV_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_LONG_DOUBLE 1
| #define SIZEOF_INT 0
| #define SIZEOF_UNSIGNED_INT 0
| #define SIZEOF_LONG 0
| #define SIZEOF_UNSIGNED_LONG 0
| #define SIZEOF_LONG_LONG 0
| #define SIZEOF_UNSIGNED_LONG_LONG 0
| /* end confdefs.h.  */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| #  include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| #  include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| static long int longval () { return (long int) (sizeof (size_t)); }
| static unsigned long int ulongval () { return (long int) (sizeof (size_t)); }
| #include <stdio.h>
| #include <stdlib.h>
| int
| main ()
| {
| 
|   FILE *f = fopen ("conftest.val", "w");
|   if (! f)
|     return 1;
|   if (((long int) (sizeof (size_t))) < 0)
|     {
|       long int i = longval ();
|       if (i != ((long int) (sizeof (size_t))))
| 	return 1;
|       fprintf (f, "%ld", i);
|     }
|   else
|     {
|       unsigned long int i = ulongval ();
|       if (i != ((long int) (sizeof (size_t))))
| 	return 1;
|       fprintf (f, "%lu", i);
|     }
|   /* Do not output a trailing newline, as this causes \r\n confusion
|      on some platforms.  */
|   return ferror (f) || fclose (f) != 0;
| 
|   ;
|   return 0;
| }
configure:16416: error: in `/Applications/gromacs-2021.4/build/src/external/build-fftw/fftwBuild-prefix/src/fftwBuild-build':
configure:16418: error: cannot compute sizeof (size_t)
See `config.log' for more details

This sounds like your compiler install has some problem ( uint8_t and other are built-in type, this should not occur). Seems very similar to the following stackoverflow post or this github post, i.e. interation between OS upgrade and homebrew/xcode.

I’m not knowledgeable on Mac OS, so cannot advise about any of the proposed solutions. If a solution does solve your problem, please write back what worked.

uint8_t is not guaranteed to be provided by any given tool chain. It can be particularly tricky to get the right combination of headers, compilers, and libraries on Mac.

I have not tried the M1 Macs, but on any Mac, I always use homebrew to install fftw.

If you can’t install fftw through homebrew or build it with the instructions on https://fftw.org, you could look for support on homebrew or fftw forums.

Thank you!
For the moment I will just give up and install it on a Linux machine instead.

Give a try with clang/clang++ as a compiler, see if it helps. sometimes, I find using clang is less hassle in macOS

+1 for trying with clang/clang++ as it seems to be working better so far. Next going to try to run with icc/ispc from brew if it ever gets brewwed…

So I tried compiling with icc but I come across this error during building adler32.c.o. Not sure where add dependency check since it says not to edit the Makefile. It was made without any issue using clang and gcc.

icc: error #10172: dependency generation to a file requires dependency option
make[2]: *** [src/gromacs/CMakeFiles/tng_io_zlib.dir/__/external/tng_io/external/zlib/adler32.c.o] Error 1
make[1]: *** [src/gromacs/CMakeFiles/tng_io_zlib.dir/all] Error 2
make: *** [all] Error 2

Not sure where add dependency check since it says not to edit the Makefile.

That advice is because the Makefile is generated by CMake. Updates to the build system logic need to be made in the CMakeLists.txt (and related files) in order to be persistent.

However, it looks like you may be able to resolve the error by adding some CFLAGS and CXXFLAGS to the CMake command line. See How to use the Intel Classic C++ Compiler with macOS 11 (Big Sur) - Intel Community

Hello,

gromacs 2021.5 built flawlessly on a M1 Max MacBook Pro (Monterey 12.2) using gcc11, libomp, cmake and fftw from homebrew.

I use these cmake arguments :

cmake … -DGMX_GPU=OpenCL -DCMAKE_C_COMPILER=/opt/homebrew/bin/gcc-11 -DCMAKE_CXX_COMPILER=/opt/homebrew/bin/g+±11 -DCMAKE_INSTALL_PREFIX=/usr/local/gromacs

For information, I failed to built the 2022.rc1 with the same command (some errors with static_cast?)

For information, I failed to built the 2022.rc1 with the same command (some errors with static_cast?)

I saw something like that recently. I can’t remember if it was GROMACS or something else. It was reported that gcc 10 worked for the same case. I think it is some sort of low-priority incompatibility with gcc11 and some GPU code somewhere.

Yes, it is a gcc11 thing and should be fixed in future releases: