libflame
libflame copied to clipboard
Configuration with upstream Fortran LAPACK ignores `F77` environmental variable
I am trying to compile libflame with clang/flang. I specify the compilers via environmental variables like this:
CC=mpicc F77=mpifort CFLAGS="-march=znver2 -O3 -DNDEBUG" \
./configure --enable-lapack2flame --enable-dynamic-build --disable-warnings --prefix=${BIN_DIR}/libflame-5.2.0
Compilation used to work just fine, but now I get the error that the command f77
was not found:
$ make
Generating monolithic include/x86_64-unknown-linux-gnu/FLAME.h......................................................................................................................................................................................................................................................................................................................
Generated monolithic include/x86_64-unknown-linux-gnu/FLAME.h
Generating monolithic include/x86_64-unknown-linux-gnu/blis1.h..................
Generated monolithic include/x86_64-unknown-linux-gnu/blis1.h
Generating monolithic include/x86_64-unknown-linux-gnu/FLA_f2c.h...
Generated monolithic include/x86_64-unknown-linux-gnu/FLA_f2c.h
Building src/map/common/lapacksrc/fortran/la_constants.f90
bash: f77: command not found
make: *** [Makefile:610: obj/x86_64-unknown-linux-gnu/src/la_constants.mod] Error 127
I ran a git bisect
session and identified 74b56a226bf976be9a89e810b2c7bd0789c6d2f9 (https://github.com/flame/libflame/pull/89) as the first bad commit.
It seems like the F77
compiler specified via environmental variables is ignored when building the upstream versions of the LAPACK library. Can you confirm that?
In the meantime, adding the configuration option --enable-legacy-lapack
works as a workaround.
We're looking at it. Prior to #89 there was no Fortran in libflame - so F77
was not used.
#106 hopefully addresses this issue.
Something is still not quite right. When I specify FC
and FFLAGS
, the configure script tries to test the flags with gfortran
and not the specified compiler.
$ FC=flang FFLAGS="-march=znver2" ./configure --enable-lapack2flame
[...]
configure: FC environment variable is set to flang, which will override --with-fc option and default search list for Fortran compiler.
checking whether we are using the GNU Fortran compiler... no
checking whether flang accepts -g... yes
[...]
checking whether user requested auto-detection of Fortran linker flags... yes
checking whether user requested auto-detection of Fortran name-mangling... yes
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... gfortran
checking whether we are using the GNU Fortran 77 compiler... no
checking whether gfortran accepts -g... yes
checking how to get verbose linking output from gfortran... configure: WARNING: compilation failed
checking for Fortran 77 libraries of gfortran...
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... configure: error: in `/expanse/lustre/projects/ucd150/mfehling/libflame':
configure: error: cannot compile a simple Fortran program
See `config.log' for more details
config.log
=======
[...]
configure:5336: checking for Fortran 77 name-mangling scheme
configure:5349: gfortran -c -march=znver2 conftest.f >&5
f951: Error: bad value ('znver2') for '-march=' switch
f951: note: valid arguments to '-march=' switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server bonnell atom silvermont slm knl knm x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 btver1 btver2 native; did you mean 'znver1'?
configure:5349: $? = 1
configure: failed program was:
| subroutine foobar()
| return
| end
| subroutine foo_bar()
| return
| end
configure:5482: error: in `.../libflame':
configure:5484: error: cannot compile a simple Fortran program
See `config.log' for more details
[...]
However, it works when I specify both FC
and F77
. Is this intended behavior?
$ FC=flang F77=flang FFLAGS="-march=znver2" ./configure --enable-lapack2flame
I think we need to be careful.
-
F77
andFFLAGS
correspond to Fortran 77 -
FC
andFCFLAGS
correspond to Fortran (?)
They can both be different.
https://github.com/flame/libflame/blob/f38dd83e30136b4e25eb2343813ee4fbd7c16681/configure#L1693-L1710
I am now specifying all four (FC
, F77
, FFLAGS
, FCFLAGS
) environmental variables and it seems to work.
At the linking stage, I now also get these errors related to the lapack library (when using --enable-dynamic-build
).
Dynamically linking lib/x86_64-unknown-linux-gnu/libflame.so
ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in libflame.a(cbbcsd.o)
>>> referenced by cbbcsd.f:392 (src/map/common/lapacksrc/fortran/cbbcsd.f:392)
>>> cbbcsd.o:(cbbcsd_) in archive libflame.a
Currently only FC is supported for building the fortran files. Flags are not currently passed when building them.
https://github.com/flame/libflame/blob/f38dd83e30136b4e25eb2343813ee4fbd7c16681/Makefile#L580-L584
Usage can be found here: https://github.com/flame/libflame/blob/f38dd83e30136b4e25eb2343813ee4fbd7c16681/configure#L1673-L1676
But it might also work in the method you've invoked it.
I think it is defaulting to FC because 'flang' is not in the list of FC options. Those can be found here: https://github.com/flame/libflame/blob/f38dd83e30136b4e25eb2343813ee4fbd7c16681/configure#L3651
Currently only FC is supported for building the fortran files. Flags are not currently passed when building them.
Interesting. So the flags were only used for the internal autoconf
checks, but not for building LAPACK!
I think it is defaulting to FC because 'flang' is not in the list of FC options.
In the first comment, I was specifying FC=clang
and FFLAGS
. However FFLAGS
only applies to F77
, which I didn't specify. So F77
defaulted to gfortran
which is the first one in fla_f_compiler_list
. On the machine I use, gfortran
was too old to recognize -march=znver2
, and that's what it complained about. Interesting, thanks for pointing that out!
It seems like autoconf
treats Fortran and Fortran 77 compilers separately, which I was not aware of. So FC
is used in combination with FCFLAGS
, and F77
is used in combination with FFLAGS
.
Since you only use FC
to build LAPACK, how do you think about removing all Fortran 77 related things in your configure script? This would avoid ambiguity.
Also, building LAPACK with FCFLAGS
would be a nice feature.
Adding FCFLAGS to building LAPACK is something I will discuss with others. I see how it would be helpful.
Were you able to get your linkage issue resolved?