Cannot compile FLUKA on Mac (ld: library not found for -lSystem)

On my 11.2.3 Mac I fail to compile FLUKA

aliBuild --defaults o2 build FLUKA

fails with :

[ (python) brew ]~/alice/brew/sw/BUILD/FLUKA-latest/FLUKA$ make
gfortran -o /Users/laurent/alice/brew/sw/BUILD/15cec4a6a6483074c90972e4e84d114af4374768/FLUKA//bin/fluka -L/Users/laurent/alice/brew/sw/BUILD/15cec4a6a6483074c90972e4e84d114af4374768/FLUKA//lib -lfluka
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/laurent/alice/brew/sw/BUILD/15cec4a6a6483074c90972e4e84d114af4374768/FLUKA//bin/fluka] Error 1
make: *** [all] Error 2
> aliBuild version
aliBuild version: 1.7.1 (osx_x86-64)

Can you try updating to aliBuild 1.8.2? Also, how did you install gfortran?

same error with latest aliBuild :

[ (python) brew ]~/alice/brew/sw/BUILD/FLUKA-latest/FLUKA$ aliBuild version
aliBuild version: 1.8.2 (osx_x86-64)
[ (python) brew ]~/alice/brew/sw/BUILD/FLUKA-latest/FLUKA$ make
gfortran -o /Users/laurent/alice/brew/sw/BUILD/e34fc5d2a53f9af62a1dbdac32cffa55a2899a39/FLUKA//bin/fluka -L/Users/laurent/alice/brew/sw/BUILD/e34fc5d2a53f9af62a1dbdac32cffa55a2899a39/FLUKA//lib -lfluka
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/laurent/alice/brew/sw/BUILD/e34fc5d2a53f9af62a1dbdac32cffa55a2899a39/FLUKA//bin/fluka] Error 1
make: *** [all] Error 2

My fortran is from brew gcc :

[ (python) brew ]~/alice/brew/sw/BUILD/FLUKA-latest/FLUKA$ gfortran --version
GNU Fortran (Homebrew GCC 10.2.0_2) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Some follow-up here.

Trying with a different (well, still gcc 10.2 but compiled with spack) gfortran I can compile FLUKA just fine so it seems the issue is indeed the fortran compiler.

My brew one (10.2.0_2) is not the latest, but if I try to upgrade (to 10.2.0_4) brew compilation fails…
(hence the test with a spack built one)

Don’t quite understand what’s going on…

For what is worth:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/10.2.0_1/libexec/gcc/x86_64-apple-darwin20/10.2.0/lto-wrapper
Target: x86_64-apple-darwin20
Configured with: ../configure --build=x86_64-apple-darwin20 --prefix=/usr/local/Cellar/gcc/10.2.0_1 --libdir=/usr/local/Cellar/gcc/10.2.0_1/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0_1' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk SED=/usr/bin/sed
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Homebrew GCC 10.2.0_1)

is what works for me.