M2
M2 copied to clipboard
Issue with OpenMP support in compiling from source on Mac
Running OSX 14.2.1 and compiling from origin/development. When running the following line from INSTALL.mac:
../configure --enable-download --enable-build-libraries="readline" CC=/usr/bin/gcc CXX=/usr/bin/g++ CPPFLAGS=-I/opt/homebrew/Cellar/tbb/2021.11.0/include/
(with the CPPFLAGS added as the solution to #3055) I get an error
configure: error: OpenMP does not work, use a compiler that supports OpenMP
checking for /usr/bin/g++ option to support OpenMP... unsupported
The full terminal output from running configure is below:
configure: configuring Macaulay2 version 1.22.0.1
relevant environment variable values, if any:
CC = /usr/bin/gcc
CXX = /usr/bin/g++
CPPFLAGS = -I/opt/homebrew/Cellar/tbb/2021.11.0/include/
configure: unrecognized issue: macOS
configure: operating system information:
OS = Darwin
ISSUE = macOS-14.2.1
checking for gmake... gmake
checking for pkg-config... pkg-config
checking for etags... no
checking for ctags... ctags
checking for lintian... no
checking for otool... otool
checking for rpmlint... no
checking for gtar... gtar
checking for gfind... no
checking for find... find
checking for objdump... objdump
checking for objcopy... no
checking for ldd... no
checking for git... git
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for strip... strip
checking whether strip accepts the remove-section option... no
checking whether gmake is GNU make... yes
checking whether GNU make is recent enough... yes
checking whether gtar is GNU tar... yes
checking build system type... arm-apple-darwin23.2.0
checking host system type... arm-apple-darwin23.2.0
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to enable C11 features... none needed
checking whether the compiler supports GNU C++... yes
checking whether /usr/bin/g++ accepts -g... yes
checking for /usr/bin/g++ option to enable C++11 features... none needed
checking for bison... bison -y
checking for ranlib... ranlib
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for /usr/bin/gcc version... 15.0.0
checking whether exceptions are caught... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/time.h... yes
checking size of int *... 8
checking size of long... 8
checking for sys/ioctl.h... yes
checking for termios.h... yes
checking for sys/mman.h... yes
checking for sys/socket.h... yes
checking for netdb.h... yes
checking for netinet/in.h... yes
checking for arpa/inet.h... yes
checking for sys/time.h... (cached) yes
checking for time.h... yes
checking for sys/wait.h... yes
checking for sys/resource.h... yes
checking for io.h... no
checking for linux/personality.h... no
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for elf.h... no
checking for execinfo.h... yes
checking for stdlib.h... (cached) yes
checking for syscall.h... no
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for unistd.h... (cached) yes
checking for math.h... yes
checking for pthread.h... yes
checking for assert.h... yes
checking for alloca.h... yes
checking for malloc.h... no
checking for dlfcn.h... yes
checking for winsock2.h... no
checking for library containing clock_gettime... none required
checking for library containing socket... none required
checking for library containing hstrerror... none required
checking for library containing dlopen... none required
checking for library containing gethostbyname... none required
checking for tbb/tbb.h... yes
checking for library containing TBB_runtime_interface_version... -ltbb
tbb version 2021.11 found
checking for herror... yes
checking for error... no
checking for clock_gettime... yes
checking for getaddrinfo... yes
checking for hstrerror... yes
checking for sync... yes
checking for getpgrp... yes
checking for setpgid... yes
checking for fchmod... yes
checking for pipe... yes
checking for waitpid... yes
checking for setrlimit... yes
checking for alarm... yes
checking for fork... yes
checking for sigprocmask... yes
checking for kill... yes
checking for longjmp... yes
checking for siglongjmp... yes
checking for sigaction... yes
checking for wait4... yes
checking for readlink... yes
checking for lstat... yes
checking for realpath... yes
checking for mkdir... yes
checking for link... yes
checking for symlink... yes
checking for socket... yes
checking for accept... yes
checking for fcntl... yes
checking for personality... no
checking for ioctl... yes
checking for /usr/bin/g++ options needed to detect all undeclared functions... none needed
checking whether __INTEL_COMPILER is declared... no
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking whether the C compiler accepts the __thread storage attribute... yes
checking for gfortran... gfortran
checking whether the compiler supports GNU Fortran... yes
checking whether gfortran accepts -g... yes
configure: by default, adding linker flags to link with Fortran libraries
checking how to get verbose linking output from gfortran... -v
checking for Fortran libraries of gfortran... -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. -ltbb -lgfortran -lemutls_w -lquadmath
checking for dummy main to link with Fortran libraries... none
checking for Fortran name-mangling scheme... lower case, underscore, no extra underscore
checking how to get verbose linking output from gfortran... (cached) -v
checking for Fortran libraries of gfortran... (cached) -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13 -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc -L/opt/homebrew/Cellar/gcc/13.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin23/13/../../.. -ltbb -lgfortran -lemutls_w -lquadmath
checking for library containing pthread_mutex_trylock... none required
checking whether g++ gets confused about C linkage in system library files... no
checking for /usr/bin/g++ option to support OpenMP... unsupported
configure: error: OpenMP does not work, use a compiler that supports OpenMP
Maybe switch to the GNU compilers.
No, LLVM clang++ should work, even the one from apple.
Did you also give it the -L option to be able to link with libomp? Did you install libomp via brew? Also, I would have thought you don't need to give the CC, CXX arguments, as I thought those were the default?
Possibly, I wonder if the clang++ from apple has improved it's openmp support (so what we are giving it as a workaround might no longer be needed, or worse, maybe they removed support for openmp completely). I am not yet running under macOS 14. I hope to change that soon, and then I can try this too.
Giving it both CPPFLAGS="-I/opt/homebrew/opt/libomp/include" LDFLAGS="-L/opt/homebrew/opt/libomp/lib" seemed to do the trick in terms of the OpenMP support issue- thank you! (I also removed the CC and CXX arguments.)
Two more issues came up after, which I'll record here along with their solutions; since they might be related to the fix suggested above, I'll hold off making them separate issues for now (unless you think they should be). Both concern the compiler not knowing where to look for libraries or files:
configure: error: Could not find a version of the Boost::Regex library!, fixed by adding--with-boost-libdir=/opt/homebrew/lib/.configure: error: ffi.h not found, fixed by adding-I/opt/homebrew/Cellar/libffi/3.4.4/include/to CPPFLAGS.
After this, things seemed to go smoothly and I get a working M2 binary.