RFA: Fix basename function detection in cgen-cpu configure script

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

RFA: Fix basename function detection in cgen-cpu configure script

Nick Clifton
Hi Guys,

  The port of SID to the MIPS[1] target is failing to build in an
  integrated source tree (one with include/libiberty.h) on a 32-bit
  host, because of this compile time error:

    /usr/include/string.h:602: error: new declaration 'const char* basename(const char*)'
    .../include/libiberty.h:106: error: ambiguates old declaration 'char* basename(const char*)'

  I traced this down to the fact that HAVE_DECL_BASENAME is defined to 0
  in the config.h file in the sid/component/cgen-cpu build directory.
  This macro should be defined to 1, but the test run by the configure
  script is failing to compile because of this error:

    conftest.cc:41: error: overloaded function with no contextual type information
 
  This is line 41 of the conftest.cc file:

     char *(*pfn) = (char *(*)) basename ;
     
  The error is happening because G++ now complains about function
  pointer casts without parameter type information.  To fix the problem
  it is necessary to add a parameter type like this:

     char *(*pfn)(char *) = (char *(*)(char *)) basename ;
 
  The patch below makes this change and allows SID to be built for the
  mips64vrel-elf toolchain.

  OK to apply ?

Cheers
  Nick

[1] I have only tested a SID build for a mips64vrel-elf toolchain.  I
    suspect that the problem exists for other toolchains however.

sid/ChangeLog
2010-02-17  Nick Clifton  <[hidden email]>

        * acinclude.m4 (gcc_AC_CHECK_DECL): Add parameter type to function
        pointer cast, in order to allow compilation by newer versions of
        g++.
        * configure: Regenerate.

Index: component/cgen-cpu/acinclude.m4
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/acinclude.m4,v
retrieving revision 1.2
diff -c -3 -p -r1.2 acinclude.m4
*** component/cgen-cpu/acinclude.m4 4 Jun 2005 03:23:02 -0000 1.2
--- component/cgen-cpu/acinclude.m4 17 Feb 2010 11:17:35 -0000
*************** AC_DEFUN([gcc_AC_CHECK_DECL],
*** 9,15 ****
  AC_CACHE_VAL(gcc_cv_have_decl_$1,
  [AC_TRY_COMPILE([$4],
  [#ifndef $1
! char *(*pfn) = (char *(*)) $1 ;
  #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
  if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
    AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
--- 9,15 ----
  AC_CACHE_VAL(gcc_cv_have_decl_$1,
  [AC_TRY_COMPILE([$4],
  [#ifndef $1
! char *(*pfn)(char *) = (char *(*)(char *)) $1 ;
  #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
  if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
    AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])