[Patch] libgfortran: do not assume libm

Tristan Gingold gingold@adacore.com
Tue Mar 20 09:57:00 GMT 2012


On Mar 20, 2012, at 10:48 AM, Tobias Burnus wrote:

> Hi Tristan,
> 
>> I am starting to build fortran for VMS.
> 
> Thanks for the patch and this endeavor.
> 
>> The first serious issue was with libgfortran/configure.  It checks for
>> several math functions, but directly in libm using AC_CHECK_LIB.
>> But there is on such things as libm on VMS systems 
> 
> I think after building you will run into the same issue when using
> gfortran. The linking of -lm is hardcoded in gcc/fortran/gfortranspec.c
> (search there for MATH_LIBRARY).

A target may redefine MATH_LIBRARY to "" to avoid linking with -lm, and this is
correctly handled by gfortranspec.c.  After defining MATH_LIBRARY in vms.h, I was
able to cross build a hello whorl fortran program.

So that part is already correctly handled!

> And it is hard coded in libgfortran/libgfortran.spec.in and in the
> as-needed check of libgfortran/acinclude.m4 within a libquadmath check.
> 
> Talking about libquadmath, its libquadmath/configure.ac has the same issue.

I have to check that.  I was able to build libquadmath without errors, but I
didn't look at config.log, so I may have missed issues.

> * * *
> 
> To your patch:
> 
> First, I am far from being a configure expert and thus would like if
> a build maintainer could have a look (or Janne, who seems to have also
> more experience.)

Sure.

> I don't understand the purpose of the line:
> 
> +# Check for libm
> +AC_CHECK_LIB([m],[sin])
> 
> Except of printing to stdout and to the logs whether -lm is available and
> contains "sin", it doesn't seem to do anything. If that's the purpose, I think
> it needs a better comment. If not, I would like to know its purpose.

The purpose is to check for the presence of -libm.  If found, all tests will be linked
with -lm, which is necessary for the following tests on regular platform.  Indeed, I
should improve the documentation.

> Otherwise, the patch looks fine to me - but as written, I would like if
> someone else (build maintainer, Janne, ...) could have a look.

Thank you for your prompt reply,
Tristan.



More information about the Gcc-patches mailing list