libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libtool & GCC 3.0


From: Steve Ellcey
Subject: libtool & GCC 3.0
Date: Wed, 25 Jul 2001 11:03:32 -0700 (PDT)

I was testing libtool with GCC 3.0 and ran into a configuration problem.
I finally tracked it down to a problem with declaring main to be of type
"char", older GCC's allowed this, GCC 3.0 does not.

At around line 3928 of configure a C++ program is generated that
contains a table with symbol names extracted from another program.  Here
is the program that my configure run generated:

        #ifdef __cplusplus
        extern "C" {
        #endif
        
        extern char nm_test_var;
        extern char main();
        extern char nm_test_func();
        #if defined (__STDC__) && __STDC__
        # define lt_ptr_t void *
        #else
        # define lt_ptr_t char *
        # define const
        #endif
        
        /* The mapping between symbol names and symbols. */
        const struct {
          const char *name;
          lt_ptr_t address;
        }
        lt_preloaded_symbols[] =
        {
          {"nm_test_var", (lt_ptr_t) &nm_test_var},
          {"main", (lt_ptr_t) &main},
          {"nm_test_func", (lt_ptr_t) &nm_test_func},
          {0, (lt_ptr_t) 0}
        };
        
        #ifdef __cplusplus
        }
        #endif
 
When this program is compiled with g++ 3.0 I get the following:

[hpsje] $ g++ -c conftest.cc
conftest.cc:6: `main' must return `int'

And g++ returns an exit code of 1.

This messes up the rest of my configure/build resulting in a bad
libtool.  This can be fixed by modifying
lt_cv_sys_global_symbol_to_cdecl to declare things to be "int" instead
of "char".  Does that sound like the right fix?

Here is a patch that can be used, if people think this is the right
fix, I do not have write permission to CVS:

2001-07-25  Steve Ellcey  <address@hidden>

        * libtool.m4 (lt_cv_sys_global_symbol_to_cdecl):  Change it from
        "extern char" to "extern int" so that GCC 3.0 won't complain and
        refuse to compile programs containing "extern char main()".


*** libtool.m4.orig     Wed Jul 25 10:54:14 2001
--- libtool.m4  Wed Jul 25 10:37:05 2001
*************** AC_CACHE_VAL([lt_cv_sys_global_symbol_pi
*** 3583,3589 ****
  symxfrm='\1 \2\3 \3'
  
  # Transform an extracted symbol line into a proper C declaration
! lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char 
\1;/p'"
  
  # Transform an extracted symbol line into symbol name and symbol address
  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  
{\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  
{\"\2\", (lt_ptr) \&\2},/p'"
--- 3583,3589 ----
  symxfrm='\1 \2\3 \3'
  
  # Transform an extracted symbol line into a proper C declaration
! lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int 
\1;/p'"
  
  # Transform an extracted symbol line into symbol name and symbol address
  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  
{\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  
{\"\2\", (lt_ptr) \&\2},/p'"
*************** cygwin* | mingw* | pw32*)
*** 3597,3603 ****
    [symcode='[ABCDGISTW]']
    ;;
  hpux*) # Its linker distinguishes data from code symbols
!   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char 
\1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  
{\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  
{\"\2\", (lt_ptr) \&\2},/p'"
    ;;
  irix*)
--- 3597,3603 ----
    [symcode='[ABCDGISTW]']
    ;;
  hpux*) # Its linker distinguishes data from code symbols
!   lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int 
\1();/p' -e 's/^$symcode* .* \(.*\)$/extern int \1;/p'"
    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  
{\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  
{\"\2\", (lt_ptr) \&\2},/p'"
    ;;
  irix*)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]