Hi Steve,
Steve Ellcey wrote:
I have a question about the libgfortran configure script. I am trying to
build the fortran language for the mips-mti-elf target (which is built with
newlib) and as part of the configure script for libgfortran it is trying to
check for localtime_r and other functions. These functions exist on my target
but the configure script thinks they don't because the GCC compile and link
done in the configure script doesn't include any linker script options.
So I get:
% install-mips-mti-elf/bin/mips-mti-elf-gcc time.c -o x
/local/home/sellcey/nightly/install-mips-mti-elf/lib/gcc/mips-mti-elf/4.9.0/../../../../mips-mti-elf/bin/ld:
warning: cannot find entry symbol __start; defaulting to 0000000000400098
/tmp/ccnihmPO.o: In function `main':
time.c:(.text+0x10): undefined reference to `localtime_r'
collect2: error: ld returned 1 exit status
If I add '-Tmti32.ld' then it compiles cleanly:
% install-mips-mti-elf/bin/mips-mti-elf-gcc -Tmti32.ld time.c -o x
I don't have any problems like this building the C++ library. I guess
it is because that library doesn't use AC_CHECK_FUNCS_ONCE like libgfortran
does.
Well, if I do a grep in libstdc++ that it does not use localtime_r at
all. Thus, it is not surprising that it works there. ;-)
In general, AC_CHECK_FUNCS_ONCE should be a reasonable approach.
(Although, one could argue that using AC_CHECK_FUNCS would be better;
cf.
http://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Generic-Functions.html
)
For the localtime_r issue with newlib,I wonder whether one should do the
same as libjava/configure.ac does:
if test "x${with_newlib}" = "xyes"; then
...
# We assume newlib. This lets us hard-code the functions we know
# we'll have.
...
AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have the 'gmtime_r'
function])
...
Tobias