Skip to content

Building on macOS using Apple Clang for C/CXX and GCC for fortran fails to link unit tests #5795

@paulgessinger

Description

@paulgessinger

I'm on macOS 26

Darwin Terminus-3596.local 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041 arm64

using Apple Clang

Apple clang version 21.0.0 (clang-2100.0.123.102)
Target: arm64-apple-darwin25.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

When building openblas using spack it concretizes to

 -   openblas@develop~bignuma~consistent_fpcsr+dynamic_dispatch+fortran~ilp64+locking+pic+shared~static build_system=makefile dev_path=/Users/pagessin/dev/openblas-dev/openblas symbol_suffix=none threads=none platform=darwin os=tahoe target=m3 %c,cxx=apple-clang@21.0.0 %fortran=gcc@15.1.0
[e]      ^apple-clang@21.0.0 build_system=bundle platform=darwin os=tahoe target=aarch64
[+]      ^compiler-wrapper@1.0 build_system=generic platform=darwin os=tahoe target=m4
[e]      ^gcc@15.1.0+binutils+bootstrap~graphite+libsanitizer~mold~nvptx~piclibs~profiled~strip build_system=autotools build_type=RelWithDebInfo languages:='c,c++,fortran' platform=darwin os=tahoe target=aarch64
[+]      ^gcc-runtime@15.1.0 build_system=generic platform=darwin os=tahoe target=m3
[+]      ^gmake@4.4.1~guile build_system=generic platform=darwin os=tahoe target=m4 %c=apple-clang@21.0.0

which essentially means that it'll use clang for C and C++ and gfortran for fortran.

The test build then ultimately fails with:

ld: warning: ignoring duplicate libraries: '-lSystem', '-lemutls_w', '-lgfortran', '-lheapt_w', '-lquadmath'
No receipt for 'com.apple.pkg.Xcode' found at '/'.
ld: warning: ignoring duplicate libraries: '-lgfortran'
ld: library 'gfortran' not found
ld: warning: ignoring duplicate libraries: '-lgfortran'
ld: library 'gfortran' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:485: test_sbgemv] Error 1
make[1]: *** Waiting for unfinished jobs....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:479: test_bgemv] Error 1

which I understand to mean that clang is not able to resolve the gfortran library. Full build log is here:

build.log

See spack/spack-packages#4569

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions