NetBSD-Bugs archive

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

Re: toolchain/53810: C++ exception does not work on m68k when libstdc++ is dynamicaly linked



The following reply was made to PR toolchain/53810; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: toolchain/53810: C++ exception does not work on m68k when
 libstdc++ is dynamicaly linked
Date: Wed, 9 Jan 2019 19:15:59 +0000

 (not sent to gnats)
 
    ------
 
 From: Rin Okuyama <rokuyama%rk.phys.keio.ac.jp@localhost>
 To: toolchain-manager%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
 	netbsd-bugs%netbsd.org@localhost
 Subject: Re: toolchain/53810: C++ exception does not work on m68k when
 	libstdc++ is dynamicaly linked
 Date: Sat, 29 Dec 2018 06:09:03 +0900
 
 On archs other than m68k, libstdc++.so and C++ binaries depend on
 libgcc_s.so. On m68k, this is not the case: -shared-libgcc is
 observed in "g++ -v", but only -lgcc (not -lgcc_s) is passed to ld:
 
   % uname -p
   m68k
   % g++ -v hello.c
   ...
    ld ... /tmp/cc8plluA.o -lstdc++ -lm -lgcc -lc -lgcc /usr/lib/crtend.o ...
    COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mcpu=68020'
   % ldd a.out
   a.out:
 	-lstdc++.8 => /usr/lib/libstdc++.so.8
 	-lm.0 => /usr/lib/libm.so.0
 	-lc.12 => /usr/lib/libc.so.12
 
 What the difference between m68k and others? I found an answer in
 external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h:
 
     81  /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic.  */
     82  #if TARGET_DEFAULT_CPU == 0
     83  #undef REAL_LIBGCC_SPEC
     84  #define REAL_LIBGCC_SPEC        "-lgcc"
     85  #endif
 
 This hack for m68000 does not work anymore since no one in source
 tree defines TARGET_DEFAULT_CPU. Therefore, even for m68k machines,
 -lgcc is used when -lgcc_s is more appropriate.
 
 I've modified the hack as follows:
 
     81  /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic.  */
     82  #ifndef ENABLE_SHARED_LIBGCC
     83  #undef REAL_LIBGCC_SPEC
     84  #define REAL_LIBGCC_SPEC        "-lgcc"
     85  #endif
 
 Then, C++ applications on m68k get working again. Also, sun2 seems
 no more broken than before (-current kernel does not boot on TME
 regardless of my patch. Userland built with the patch works to
 some extent on 8.0 kernel).
 
 Can I commit the patch?
 
 Thanks,
 rin
 
 Index: external/gpl3/gcc.old/dist/gcc/config/m68k/netbsd-elf.h
 ===================================================================
 RCS file: /home/netbsd/src/external/gpl3/gcc.old/dist/gcc/config/m68k/netbsd-elf.h,v
 retrieving revision 1.6
 diff -p -u -r1.6 netbsd-elf.h
 --- external/gpl3/gcc.old/dist/gcc/config/m68k/netbsd-elf.h	2 Aug 2018 00:02:57 -0000	1.6
 +++ external/gpl3/gcc.old/dist/gcc/config/m68k/netbsd-elf.h	28 Dec 2018 11:29:00 -0000
 @@ -79,7 +79,7 @@ along with GCC; see the file COPYING3.
  #define LINK_SPEC NETBSD_LINK_SPEC_ELF
 
  /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic.  */
 -#if TARGET_DEFAULT_CPU == 0
 +#ifndef ENABLE_SHARED_LIBGCC
  #undef REAL_LIBGCC_SPEC
  #define REAL_LIBGCC_SPEC	"-lgcc"
  #endif
 Index: external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h
 ===================================================================
 RCS file: /home/netbsd/src/external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h,v
 retrieving revision 1.12
 diff -p -u -r1.12 netbsd-elf.h
 --- external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h	2 Feb 2018 03:41:05 -0000	1.12
 +++ external/gpl3/gcc/dist/gcc/config/m68k/netbsd-elf.h	28 Dec 2018 11:29:40 -0000
 @@ -79,7 +79,7 @@ along with GCC; see the file COPYING3.
  #define LINK_SPEC NETBSD_LINK_SPEC_ELF
 
  /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic.  */
 -#if TARGET_DEFAULT_CPU == 0
 +#ifndef ENABLE_SHARED_LIBGCC
  #undef REAL_LIBGCC_SPEC
  #define REAL_LIBGCC_SPEC	"-lgcc"
  #endif
 


Home | Main Index | Thread Index | Old Index