This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g++ 2.95.2 -fhonor-std fails to link std::terminate()


On Thu, 20 Apr 2000, Martin Sebor wrote:
> Hi,
> 
> the linker is failing to find std::terminate() when linking exception
> code compiled with -fhonor-std. We're currently providing our own
> definition of the missing function(s) but, since this is surely a known
> problem, I'm wondering whether perhaps there is an option that would let
> the linker use the globals.
> 
> Thanks
> Martin
> 
> $ cat test.cpp
> 
> int main ()
> try { }
> catch (...) { }
> 
> $ g++ -fhonor-std test.cpp
> /tmp/ccyIx02a.o: In function `main':
> /tmp/ccyIx02a.o(.text+0x61): undefined reference to
> `std::terminate(void)'
> collect2: ld returned 1 exit status
> 

This is because libgcc and libstdc++ are (in 2.95.2) compiled with
  -fno-honor-std (the default) and so std::terminate() has the link-time
  name 'terminate'.

The workaround is to recompile libstdc++ and libgcc with -fhonor-std.

Unfortunately, I do not remember the official way to do this.

I did it by changing the value of flag_honor_std (to 1) in gcc/cp/decl2.c
  and rebuilding gcc . This turns on -fhonor-std on by default.

Note that you if you build a c++ project with such a patched compiler,
  will *not* link against a libstdc++ that was built with -fno-honor-std .

I have attached a diff, which works for me, but I am not using the patched
  gcc 2.95.2 in a production environment.

*** old/gcc-2.95.2/gcc/cp/decl2.c     Thu Aug 19
17:29:45 1999
--- new/gcc-2.95.2/gcc/cp/decl2.c     Fri Apr 14
21:42:12 2000
***************
*** 449,455 ****
  
  /* Nonzero to not ignore namespace std. */
  
! int flag_honor_std;
  
  /* Maximum template instantiation depth. Must be at least 17 for ANSI
     compliance. */
--- 449,455 ----
  
  /* Nonzero to not ignore namespace std. */
  
! int flag_honor_std = 1;
  
  /* Maximum template instantiation depth. Must be at least 17 for ANSI
     compliance. */




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]