Skip to content

f_check incorrectly interpreting -R in static library path as rpath flag #5664

@Thyre

Description

@Thyre

While trying to build OpenBLAS with ROCm, I've encountered this build failure:

clang: error: no such file or directory: '/data/EasyBuild-develop/software/ROCm-LLVM/22.0.0-GCCcore-14.3.0-rpath%OCm-7.2.0/lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a'
clang: error: no such file or directory: '/data/EasyBuild-develop/software/ROCm-LLVM/22.0.0-GCCcore-14.3.0-rpath%OCm-7.2.0/lib/clang/22/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a'

A close look shows that we're trying to link static libraries, but the path was changed to include -rpath% instead of -R.
This comes from FEXTRALIB=, created by f_check.

Looking at the f_check code, it first does a few replacements in the link command:

https://github.com/OpenMathLib/OpenBLAS/blob/db6bbc715013d0ed790fdb6684947df525335b2e/f_check#L345C1-L352C76

   link=`echo "$link" | sed 's/\-Y[[:space:]]P\,/\-Y/g'`

    link=`echo "$link" | sed 's/\-R[[:space:]]*/\-rpath\%/g'`

    link=`echo "$link" | sed 's/\-rpath[[:space:]]+/\-rpath\%/g'`

    link=`echo "$link" | sed 's/\-rpath-link[[:space:]]+/\-rpath-link\%/g'`

only after that, it is checked if the linker flags are actually paths to static libraries.

    	case "$flag" in *.a) linker_a="$linker_a $flag" ;; esac

This breaks any build where the link command includes static libraries, with the path including -R.

To reproduce, one can e.g. and try to run f_check with this:

$ ./f_check Makefile config "gfortran /path-with-R/library.a" && tail -n 5 Makefile
        @echo Done.
F_COMPILER=GFORTRAN
FC=gfortran /path-with-R/library.a
BU=_
FEXTRALIB= -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1 -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/../../.. -L/lib -L/usr/lib  -lgfortran -lm -lquadmath -lm -lc  /path-with-rpath%/library.a /path-with-rpath%/library.a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions