[petsc-users] Problem installing metis

Satish Balay balay at mcs.anl.gov
Thu Sep 3 20:21:46 CDT 2015


The primary issue is not the include statement - that just gives a
different error message:

undefined reference to `__pow_finite'
vs
undefined reference to `pow'

The issue is:
static void _check_pow() { double x = 0,y ; y = pow(x, x);
vs
double _check_pow(double x ) { return pow(x, x);

i.e
1. remove static
2. pass in input 'double x' [instead of declaring in function]
3. pass back the retrun as 'dobule' - instead of locally computing value [with void]

config/BuildSystem/config/libraries.py uses code generator to generate
a bunch of configure tests to generate the following test code for -lm
check [and uses the same genater for abunch of other tests]

Source:
#include "confdefs.h"
#include "conffix.h"
/* Override any gcc2 internal prototype to avoid an error. */
double sin(double);
static void _check_sin() { double x = 0,y; y = sin(x);
; }
double floor(double);
static void _check_floor() { double x = 0,y; y = floor(x);
; }
double log10(double);
static void _check_log10() { double x = 0,y; y = log10(x);
; }
double pow(double, double);
static void _check_pow() { double x = 0,y ; y = pow(x, x);
; }

int main() {
_check_sin();
_check_floor();
_check_log10();
_check_pow();;
  return 0;
}

And there are comments like:
>>>>>>>
      # Capture the function call in a static function so that any local variables are isolated from
      # calls to other library functions.
<<<<<<<<

So we'll have to look at this code generater [and its assumtions] -
and see if it can be modified to generate this alternate code..

Satish

On Thu, 3 Sep 2015, Barry Smith wrote:

> 
>   Satish,
> 
>    Well the classic model that Matt inherited from GNU that does not include the appropriate include files but instead makes up some prototype in the test file and looks for symbols in the resulting .o is not IMHO good anyways and I'd like to see it eventually totally eliminated so here is one place it can be done.  Use the checklink() function that takes an include and a main body to check these math functions?  If you have the main() return depend on the result of the math function then it cannot simply remove the entire call.
> 
> 
>   Barry
> 
> 
> > On Sep 3, 2015, at 7:33 PM, Satish Balay <balay at mcs.anl.gov> wrote:
> > 
> > Ok - the issue here is:- '-O3 -ffast-math' inlines/optimzies out the
> > math code in configure test [so -lm isn't needed/required here].  But
> > the code in metis [and petsc] library sources isn't inlined out
> > [requiring -lm].
> > 
> >>>>>>>>>>>>> Current configure behavior <<<<<<<<<<<
> > $ cat conftest.c 
> > double pow(double, double);
> > static void _check_pow() { double x = 0,y ; y = pow(x, x);
> > ; }
> > int main() {
> > _check_pow();;
> >  return 0;
> > }
> > $ gcc -O -ffast-math conftest.c
> > $ gcc  conftest.c
> > /tmp/ccWCYvMy.o: In function `_check_pow':
> > conftest.c:(.text+0x28): undefined reference to `pow'
> > collect2: error: ld returned 1 exit status
> > $ gcc  conftest.c -lm
> > $ 
> >>>>>>>>>>>>> modified testcode to reproduce library-code behavior <<<<<<<<<<<
> > $ cat newtest.c 
> > #include <math.h>
> > //double pow(double, double); //also works but gives different error
> > double _check_pow(double x ) { return pow(x, x);
> > ; }
> > int main() {
> > _check_pow(1.0);;
> >  return 0;
> > }
> > $ gcc -O3 -ffast-math newtest.c
> > /tmp/ccfeotgx.o: In function `_check_pow':
> > newtest.c:(.text+0x5): undefined reference to `__pow_finite'
> > collect2: error: ld returned 1 exit status
> > $ gcc -O3 -ffast-math newtest.c -lm
> > $ 
> > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> > 
> > This test code within configure is spun by code-generator- so I'm not
> > sure how to modify it to get this test working..
> > 
> > [and its not clear if this change works universally - a different
> > compiler/optimizer might not fail the same way?]
> > 
> > Satish
> > 
> > On Thu, 3 Sep 2015, Michele Rosso wrote:
> > 
> >> Hi Satish,
> >> 
> >> I did as you suggested and I was able to install successfully.
> >> I attached the configure script and log.
> >> 
> >> Thanks!
> >> Michele
> >> 
> >> On Thu, 2015-09-03 at 13:08 -0500, Satish Balay wrote:
> >> 
> >>> Hm - this is weird.
> >>> 
> >>>>>>>>>>>>>> 
> >>> 
> >>> TESTING: checkMath from config.libraries(config/BuildSystem/config/libraries.py:251)
> >>>  Check for sin() in libm, the math library
> >>> 
> >>> Executing: mpicc  -o /tmp/petsc-AXFj8c/config.libraries/conftest    -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -O3 -ffast-math -march=native -mtune=native /tmp/petsc-AXFj8c/config.libraries/conftest.o   -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lopa -lmpl -lrt -lcr -lpthread -lgcc_s -ldl
> >>>              Popping language C
> >>>          Math functions are linked in by default
> >>> 
> >>> 
> >>> Executing: mpicc  -o /tmp/petsc-AXFj8c/config.libraries/conftest    -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -O3 -ffast-math -march=native -mtune=native /tmp/petsc-AXFj8c/config.libraries/conftest.o  -Wl,-rpath,/opt/petsc/petscfork/gnu-opt-32idx/lib -L/opt/petsc/petscfork/gnu-opt-32idx/lib -lmetis -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lopa -lmpl -lrt -lcr -lpthread -lgcc_s -ldl
> >>> Possible ERROR while running linker: exit code 256
> >>> stderr:
> >>> /opt/petsc/petscfork/gnu-opt-32idx/lib/libmetis.a(kmetis.c.o): In function `libmetis__InitKWayPartitioning':
> >>> /opt/petsc/petscfork/gnu-opt-32idx/externalpackages/metis-5.1.0-p1/libmetis/kmetis.c:187: undefined reference to `__log_finite'
> >>> /opt/petsc/petscfork/gnu-opt-32idx/externalpackages/metis-5.1.0-p1/libmetis/kmetis.c:187: undefined reference to `__pow_finite'
> >>> /opt/petsc/petscfork/gnu-opt-32idx/lib/libmetis.a(util.c.o): In function `gk_flog2':
> >>> /opt/petsc/petscfork/gnu-opt-32idx/externalpackages/metis-5.1.0-p1/GKlib/util.c:106: undefined reference to `__log_finite'
> >>> <<<<<<<<<<
> >>> 
> >>> Can you rerun configure with the additional option "LIBS=-lm" - and see if it makes a difference?
> >>> 
> >>> Satish
> >>> 
> >>> 
> >>> On Thu, 3 Sep 2015, Michele Rosso wrote:
> >>> 
> >>>> Hi,
> >>>> 
> >>>> I am trying to install METIS via the development version of petsc, but I
> >>>> encountered the following error:
> >>>> 
> >>>>         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log
> >>>> for details):
> >>>> -------------------------------------------------------------------------------
> >>>> Downloaded metis could not be used. Please check install
> >>>> in /opt/petsc/petscfork/gnu-opt-32idx
> >>>> 
> >>>> 
> >>>> I attached the install script and the configure.log file.
> >>>> Any idea?
> >>>> 
> >>>> Thanks,
> >>>> Michele
> >>>> 
> >>>> 
> >>>> 
> >>>> 
> >>> 
> >> 
> >> 
> >> 
> > 
> 
> 



More information about the petsc-users mailing list