[MacPorts] #68810: OpenBLAS: libopenblas.0.dylib cannot find symbol _xerbla_
MacPorts
noreply at macports.org
Sun Dec 3 06:22:15 UTC 2023
#68810: OpenBLAS: libopenblas.0.dylib cannot find symbol _xerbla_
-----------------------+-------------------------
Reporter: erikbs | Owner: NicosPavlov
Type: defect | Status: assigned
Priority: Normal | Milestone:
Component: ports | Version:
Resolution: | Keywords:
Port: OpenBLAS |
-----------------------+-------------------------
Comment (by erikbs):
I removed the patch that enables weak linking on older platforms as a
test. The build then fails:
{{{
...
:info:build [ 0%] Building C object
driver/others/CMakeFiles/driver_others.dir/xerbla.c.o
:info:build cd
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/driver/others
&& /opt/local/bin/clang-mp-16
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.25
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build
-pipe -O3 -DNDEBUG -I/opt/local/include -arch x86_64 -DHAVE_C11 -Wall
-m64 -mavx2 -mavx -msse -msse2 -msse3 -mssse3 -msse4.1 -fPIC
-DSMALL_MATRIX_OPT -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8
-DMAX_PARALLEL_NUMBER=1 -DMAX_STACK_ALLOC=2048 -DNO_AFFINITY
-DVERSION="\"0.3.25\"" -DBUILD_SINGLE -DBUILD_DOUBLE -DBUILD_COMPLEX
-DBUILD_COMPLEX16 -arch x86_64 -mmacosx-version-min=10.9 -MD -MT
driver/others/CMakeFiles/driver_others.dir/xerbla.c.o -MF
CMakeFiles/driver_others.dir/xerbla.c.o.d -o
CMakeFiles/driver_others.dir/xerbla.c.o -c
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.25/driver/others/xerbla.c
...
:info:build [ 11%] Building C object
interface/CMakeFiles/interface.dir/CMakeFiles/xerbla.c.o
:info:build cd
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/interface
&& /opt/local/bin/clang-mp-16
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.25
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build
-pipe -O3 -DNDEBUG -I/opt/local/include -arch x86_64 -DHAVE_C11 -Wall
-m64 -mavx2 -mavx -msse -msse2 -msse3 -mssse3 -msse4.1 -fPIC
-DSMALL_MATRIX_OPT -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8
-DMAX_PARALLEL_NUMBER=1 -DMAX_STACK_ALLOC=2048 -DNO_AFFINITY
-DVERSION="\"0.3.25\"" -DBUILD_SINGLE -DBUILD_DOUBLE -DBUILD_COMPLEX
-DBUILD_COMPLEX16 -arch x86_64 -mmacosx-version-min=10.9 -MD -MT
interface/CMakeFiles/interface.dir/CMakeFiles/xerbla.c.o -MF
CMakeFiles/interface.dir/CMakeFiles/xerbla.c.o.d -o
CMakeFiles/interface.dir/CMakeFiles/xerbla.c.o -c
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/interface/CMakeFiles/xerbla.c
...
:info:build ar: creating archive libopenblas.a
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build sh -c '/opt/local/bin/ar -ru libopenblas.a
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o
&& exit 0'
:info:build /opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no
symbols
:info:build /opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o)
has no symbols
:info:build sh -c 'echo "" | /opt/local/bin/gfortran-mp-13 -o dummy.o -c
-x f95-cpp-input - '
:info:build f951: Warning: Reading file '<stdin>' as free form
:info:build sh -c '/opt/local/bin/gfortran-mp-13 -fpic -shared
-Wl,-all_load -Wl,-force_load,libopenblas.a -Wl,-noall_load dummy.o -o
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/lib/libopenblas.0.3.dylib'
:info:build ld: warning: option -noall_load is obsolete and being ignored
:info:build Undefined symbols for architecture x86_64:
:info:build "_xerbla_", referenced from:
:info:build _sgemv_ in libopenblas.a(sgemv.c.o)
:info:build _sger_ in libopenblas.a(sger.c.o)
:info:build _strsv_ in libopenblas.a(strsv.c.o)
:info:build _strmv_ in libopenblas.a(strmv.c.o)
:info:build _ssyr2_ in libopenblas.a(ssyr2.c.o)
:info:build _sgbmv_ in libopenblas.a(sgbmv.c.o)
:info:build _ssbmv_ in libopenblas.a(ssbmv.c.o)
:info:build ...
:info:build (maybe you meant: _xerbla_array_)
:info:build ld: symbol(s) not found for architecture x86_64
:info:build collect2: error: ld returned 1 exit status
}}}
There are two xerbla.c.o files. Standing in the build directory:
{{{
sh-3.2# find . -iname xerbla.c.o
./driver/others/CMakeFiles/driver_others.dir/xerbla.c.o
./interface/CMakeFiles/interface.dir/CMakeFiles/xerbla.c.o
}}}
The second does not contain any symbols, but the first one does:
{{{
sh-3.2# nm -gU ./driver/others/CMakeFiles/driver_others.dir/xerbla.c.o |
grep _xerbla_
0000000000000000 T _xerbla_
}}}
However, `libopenblas.a` does not contain the `_xerbla_` symbol:
{{{
sh-3.2# nm -gU libopenblas.a | grep _xerbla_
no symbols
no symbols
0000000000000000 T _xerbla_array_
}}}
Even when I run
{{{
/opt/local/bin/ar -ru libopenblas.a
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o
}}}
manually, `libopenblas.a` still does not contain it. It warns about
missing symbols, but that seems to be because it references the other
xerbla.c.o file (and another file without symbols), but the command does
not fail:
{{{
sh-3.2# /opt/local/bin/ar -ru libopenblas.a
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/driver/others/CMakeFiles/driver_others.dir/xerbla.c.o
/opt/local/bin/ranlib: file: libopenblas.a(xerbla.c.o) has no symbols
/opt/local/bin/ranlib: file: libopenblas.a(la_constants.f90.o) has no
symbols
sh-3.2# echo $?
0
}}}
I get `ar`/`ranlib` from cctools:
{{{
The following ports are currently installed:
cctools @949.0.1_3+llvm90 (active)
}}}
Per
[https://github.com/OpenMathLib/OpenBLAS/issues/4347#issuecomment-1829723031
this comment], `libopenblas.a` should have contained `_xerbla_` (“even if
as a weak symbol”, but `__attribute__((weak))`
[https://github.com/OpenMathLib/OpenBLAS/blob/develop/driver/others/xerbla.c
is #ifdef-ed to only apply to ELF]).
I have no idea why, but when I did this:
{{{
sh-3.2# cc -o xx.o -I$(pwd) -I ../OpenBLAS-0.3.25/ -c
../OpenBLAS-0.3.25/driver/others/xerbla.c
sh-3.2# /opt/local/bin/ar -ru libopenblas.a xx.o
sh-3.2# chown macports libopenblas.a
}}}
followed by
{{{
install -o openblas +gcc13 +lapack +native
}}}
in the MacPorts shell, the linking succeeds and the build finishes. Even
NumPy works
So why does
{{{
cc -o xx.o -I$(pwd) -I ../OpenBLAS-0.3.25/ -c
../OpenBLAS-0.3.25/driver/others/xerbla.c
}}}
produce a usable object file when
{{{
cd
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build/driver/others
&& /opt/local/bin/clang-mp-16
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.25
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/build
-pipe -O3 -DNDEBUG -I/opt/local/include -arch x86_64 -DHAVE_C11 -Wall
-m64 -mavx2 -mavx -msse -msse2 -msse3 -mssse3 -msse4.1 -fPIC
-DSMALL_MATRIX_OPT -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8
-DMAX_PARALLEL_NUMBER=1 -DMAX_STACK_ALLOC=2048 -DNO_AFFINITY
-DVERSION="\"0.3.25\"" -DBUILD_SINGLE -DBUILD_DOUBLE -DBUILD_COMPLEX
-DBUILD_COMPLEX16 -arch x86_64 -mmacosx-version-min=10.9 -MD -MT
driver/others/CMakeFiles/driver_others.dir/xerbla.c.o -MF
CMakeFiles/driver_others.dir/xerbla.c.o.d -o
CMakeFiles/driver_others.dir/xerbla.c.o -c
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_math_OpenBLAS/OpenBLAS/work/OpenBLAS-0.3.25/driver/others/xerbla.c
}}}
does not?
My `cc` is:
{{{
sh-3.2# cc --version
clang version 17.0.6
Target: x86_64-apple-darwin13.4.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-17/bin
}}}
--
Ticket URL: <https://trac.macports.org/ticket/68810#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list