[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_F77_LIBRARY_LDFLAGS adds LLVM compiler flags to FLIBS
From: |
Dieter, William R |
Subject: |
AC_F77_LIBRARY_LDFLAGS adds LLVM compiler flags to FLIBS |
Date: |
Wed, 22 Jul 2020 18:47:21 +0000 |
I am trying to build GlobalArrays (https://github.com/GlobalArrays/ga) with the
public beta Intel Fortran compiler available in the oneAPI HPC ToolKit
(https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit.html).
The configure.ac includes the AC_F77_LIBRARY_LDFLAGS macro to discover which
libraries are needed to link Fortran code with C/C++ code.
AC_F77_LIBRARY_LDFLAGS calls the ifx, the Fortran compiler, with the -v flag
and tries to parse the output for library flags. The problem is that the
driver passes an LLVM option "-mllvm -loopopt=0" to the underlying compiler.
The configure script sees a string starting with " -l" and interprets it as a
library. The configure script then fails, because it cannot link the test
program to liboopopt=0.a.
AC_F77_LIBRARY_LDFLAGS only needs the linker flags, not the compiler flags.
Compiling conftest.f directly to an executable with verbose output results in
separate output lines for compiling and linking. A different way would be for
the macro to compile conftest.f to an object file in a separate step, and then
parse the verbose output of linking the resulting conftest.o file. This way,
./configure only tries to parse the linker output and cannot be fooled by the
compiler output.
To test this, I changed the configure script from:
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext
$LIBS >&5'
to
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS
conftest.$ac_objext $LIBS >&5'
And, changed:
ac_f77_v_output=` eval $ac_link 5>&1 2>&1 |
sed '/^Driving:/d; /^Configured with:/d;
'"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"`
to
ac_f77_v_output=`eval $ac_compile >&5 && eval $ac_link 5>&1 2>&1 |
sed '/^Driving:/d; /^Configured with:/d;
'"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"`
Not sure how this will impact other compilers. I expect that narrowing the
scope of what is parsed to just the linker should help reduce false positives
in general. Is splitting compilation into two steps to eliminate the compiler
output a reasonable fix for this? If so, I can try to figure out the macro.
It looks like _AC_PROG_FC_V_OUTPUT in lib/autoconf/fortran.m4 emits the shell
code that would need to change.
Thanks,
Bill.
- AC_F77_LIBRARY_LDFLAGS adds LLVM compiler flags to FLIBS,
Dieter, William R <=