coin-or-tools / ThirdParty-Mumps

COIN-OR autotools harness to build Mumps
Eclipse Public License 1.0
18 stars 13 forks source link

Builds failing on linux aarch64 - Cannot link to user-specified Lapack #11

Closed jacobsvante closed 4 months ago

jacobsvante commented 4 months ago

I'm unable to build on linux aarch64. Getting Cannot link to user-specified Lapack -llapack_pic -lblas.. See below for full error details.

MRE using alpine linux in Docker:

FROM alpine:3.19
RUN apk add --no-cache \
    curl \
    alpine-sdk \
    gfortran \
    cmake

ENV LD_LIBRARY_PATH=/usr/lib

ARG LAPACK_VERSION=3.12.0
RUN curl -L https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${LAPACK_VERSION}.tar.gz | tar -xz \
    && cd lapack-${LAPACK_VERSION} \
    && mkdir build \
    && cd build \
    && cmake .. \
    && make -j \
    && mv lib/liblapack.a lib/libblas.a /usr/lib/

ARG THIRDPARTY_MUMPS_VERSION=3.0.5
RUN curl -L https://github.com/coin-or-tools/ThirdParty-Mumps/archive/refs/tags/releases/${THIRDPARTY_MUMPS_VERSION}.tar.gz | tar -xz \
    && cd ThirdParty-Mumps-releases-${THIRDPARTY_MUMPS_VERSION} \
    && ./get.Mumps

RUN cd ThirdParty-Mumps-releases-${THIRDPARTY_MUMPS_VERSION} \
    && ./configure \
        --enable-shared=no \
        --enable-static=yes \
        --prefix=/work/scip_install \
        # --with-lapack-lflags='-llapack' \
        --with-lapack-lflags='-llapack_pic -lblas' \
        # --with-lapack-lflags='-llapack_pic -lblas -lgfortran -lquadmath -lm'
    || cat config.log

Running using:

docker buildx build --no-cache --progress=plain -t mumps .

Gives error:

configure:17961: error: Cannot link to user-specified Lapack -llapack_pic -lblas.

See this file for full console output, including config.log: console-errors.log

svigerske commented 4 months ago

config.log says

#8 1.276 /usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: cannot find -llapack_pic: No such file or directory

Above you do mv lib/liblapack.a lib/libblas.a /usr/lib/, so maybe you meant lapack_pic.a there?

jacobsvante commented 4 months ago

Thanks for the quick response @svigerske.

There'ss exactly the same error if I instead set --with-lapack-lflags='-llapack -lblas'. Is the --enable-static=yes flag forcing -pic?

jacobsvante commented 4 months ago

Upon further checking it seems that I was wrong. There were other about files missing, which I fixed by changing the value to: --with-lapack-lflags="-llapack -lblas -lgfortran -lm"

Btw how would I create the PIC version of lapack? Or is it PIC by default?

svigerske commented 4 months ago

I don't know much about the buildsystem of Lapack, but if you add a VERBOSE=true to its call of make, it seems that it is build with PIC, e.g., I see

cd /lapack-3.12.0/build/BLAS/SRC && /usr/bin/gfortran   -frecursive -O2 -DNDEBUG -O2 -fPIC -fdefault-integer-8 -cpp -DCHEMV=CHEMV_64 -DLSAME=LSAME_64 -DXERBLA=XERBLA_64 -c /lapack-3.12.0/build/BLAS/SRC/blas_64_obj/chemv.f -o CMakeFiles/blas_64_obj.dir/blas_64_obj/chemv.f.o

For ThirdParty-Mumps, --with-pic is the default, so also static libraries will be PIC.

jacobsvante commented 4 months ago

Thanks for the clarification @svigerske, very helpful for someone like me who's never worked with C/C++ configuration/compilation before. It sure is a lot to take in!