Source installation fails on Mac M4

I have tried building from source on a Mac M4 and initially got past the compiler issue as suggested in other topics and solved here (updated with paths to reflect homebrew installation on apple chips) with

export CC=/opt/homebrew/opt/llvm/bin/clang
export CXX=/opt/homebrew/opt/llvm/bin/clang++
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

So now I am able to run cmake .. with the following output

-- The C compiler identification is Clang 20.1.2
-- The CXX compiler identification is Clang 20.1.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.39.5 (Apple Git-154)")
-- Using git describe for versioning
-- OpenMC version: 0.15.3
-- OpenMC dev state: true
-- OpenMC commit hash: 07f5334616c2ca92ad0a04dfa8c900e080509f70
-- OpenMC commit count: 5
-- OPENMC_USE_OPENMP ON
-- OPENMC_BUILD_TESTS ON
-- OPENMC_ENABLE_PROFILE OFF
-- OPENMC_ENABLE_COVERAGE OFF
-- OPENMC_USE_DAGMC OFF
-- OPENMC_USE_LIBMESH OFF
-- OPENMC_USE_MPI OFF
-- OPENMC_USE_MCPL OFF
-- OPENMC_USE_UWUW OFF
-- No build type selected, defaulting to RelWithDebInfo
-- Found OpenMP_C: -fopenmp=libomp (found version "5.1")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1")
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Found PNG: /opt/homebrew/lib/libpng.dylib (found version "1.6.47")
-- Found HDF5: hdf5-shared (found version "1.14.6") found components: C HL
-- HDF5 Libraries: hdf5-shared
-- OpenMC C++ flags: -DH5Oget_info_by_idx_vers=1;-DH5O_info_t_vers=1
-- OpenMC Linker flags: 
-- Submodule update
-- Did not find pugixml, will use submodule instead
-- Did not find fmt, will use submodule instead
-- {fmt} version: 11.0.2
-- Build type: RelWithDebInfo
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Performing Test arch_native_supported
-- Performing Test arch_native_supported - Success
-- Found xtensor: /opt/homebrew/share/cmake/xtensor (version 0.26.0)
-- Did not find Catch2, will use submodule instead
-- Performing Test HAVE_FLAG__ffile_prefix_map__Users_Nick_programs_openmc_vendor_Catch2__
-- Performing Test HAVE_FLAG__ffile_prefix_map__Users_Nick_programs_openmc_vendor_Catch2__ - Success
-- Configuring done (5.2s)
-- Generating done (0.1s)
-- Build files have been written to: /Users/Nick/programs/openmc/build

Now, when I run make, I receive the following error

[  1%] Building CXX object vendor/fmt/CMakeFiles/fmt.dir/src/format.cc.o
[  1%] Building CXX object vendor/fmt/CMakeFiles/fmt.dir/src/os.cc.o
[  2%] Linking CXX static library ../../lib/libfmt.a
[  2%] Built target fmt
[  3%] Building CXX object vendor/pugixml/CMakeFiles/pugixml-static.dir/src/pugixml.cpp.o
[  3%] Linking CXX static library ../../lib/libpugixml.a
[  3%] Built target pugixml-static
[  3%] Building CXX object CMakeFiles/libopenmc.dir/src/bank.cpp.o
In file included from /Users/Nick/programs/openmc/src/bank.cpp:5:
In file included from /Users/Nick/programs/openmc/include/openmc/simulation.h:7:
/Users/Nick/programs/openmc/include/openmc/mesh.h:11:10: fatal error: 'xtensor/xtensor.hpp' file not found
   11 | #include "xtensor/xtensor.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/libopenmc.dir/src/bank.cpp.o] Error 1
make[1]: *** [CMakeFiles/libopenmc.dir/all] Error 2
make: *** [all] Error 2

I ran brew install llvm cmake xtensor hdf5 python libomp libpng as suggested in the guide, but make cannot find xtensor for some reason. I’m a in a bit over my head, so some help would be appreciated!

If I brew uninstall xtensor, cmake finds the submodules for xtenstor and xtl, and now I can use make and make install without errors.

So the xtensor library recently made major changes to their API (specifically, the locations of all their headers): Code reorganization by JohanMabille · Pull Request #2829 · xtensor-stack/xtensor · GitHub. There is not really a great way of handling this on the OpenMC side, as if we update OpenMC to use the 0.26.0 header paths, then anyone with a system version of 0.25.0 will have it break for them. It looks like homebrew has now updated to use 0.26.0 (the newest tag with the crazy API changes). I’m hoping they roll back the changes in a future release. Otherwise, we may want to just drop xtensor and implement the needed functionality ourselves.

2 Likes

Thanks! Can confirm this work. I also switched xtl back to be compatible.