Bug 2182 – Exceptions don't work on FreeBSD

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Other
Creation time
2008-06-28T03:08:00Z
Last change time
2015-06-09T05:15:11Z
Keywords
EH
Assigned to
dvdfrdmn
Creator
korslund

Comments

Comment #0 by korslund — 2008-06-28T03:08:21Z
I am having some problems with exceptions with gdc on FreeBSD. A simple test case is this: ----- test.d ------- import std.stdio; void main() { try { throw new Exception("test"); } catch (Exception e) { } } ------------------- % gdc test.d % ./a.out [1] 98829 abort ./a.out Removing the try-catch blocks produces the same result.
Comment #1 by dvdfrdmn — 2008-07-20T11:30:24Z
I need to know the following: OS Version Architecture GCC Version you are building GDC Version (release or SVN revision)
Comment #2 by amdmi3 — 2008-07-23T05:49:47Z
> OS Version > Architecture % uname -srp FreeBSD 7.0-RELEASE-p1 i386 > GCC Version you are building > GDC Version (release or SVN revision) % gdc --version gdc (GCC) 4.1.3 20080428 (prerelease (gdc 0.24, using dmd 1.020)) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment #3 by dvdfrdmn — 2008-07-23T22:08:40Z
I cannot reproduce the problem. Tried it on 7.0-RELEASE with both gdc release 0.24 and then SVN head. I was not able to obtain the exact GCC snapshot you reported, but both the 4.1.2 and latest 4.1.x snapshot work for me. Are you using special configure arguments or compile flags?
Comment #4 by amdmi3 — 2008-07-28T14:23:30Z
I've just used gdc from ports.
Comment #5 by amdmi3 — 2008-07-28T14:31:45Z
I.e. `portsnap update extract && cd /usr/ports/lang/gdc && make install` AFAIR, I've also tried port updated to use SVN snapshot of gdc with the same results, so it's likely that something in the port is the cause of this problem. I didn't find anything suspicious in the port though. Configure args seem pretty innocent: --disable-nls --with-system-zlib --with-libiconv-prefix=${LOCALBASE} --disable-shared --enable-languages=c,c++,d --enable-thread-lib=-lpthread and {C,CXX}FLAGS are almost default as well (-O2 -pipe -fno-strict-aliasing -march=pentium4)
Comment #6 by amdmi3 — 2008-08-05T02:52:22Z
So, can you confirm the bug with gdc from ports?
Comment #7 by dvdfrdmn — 2008-08-05T22:40:47Z
Yes. The problem is that the ports gcc compilers do not have a patch that is applied to the FreeBSD system compiler. The resulting gdc links executables in a way that is incompatible with the system startup routines. I think the g++ compiler would have the same problem. Adding the following to gcc/config/freebsd-spec.h may fix it. #if defined(HAVE_LD_EH_FRAME_HDR) #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " #endif You should also remove both instances of --disable-shared from the configure options. Without making any changes to the build, a runtime workaround is to add -Wl,--eh-frame-hdr to the link command line. I am marking this issue as WONTFIX because it is a problem in the ports library.
Comment #8 by amdmi3 — 2008-08-07T13:56:48Z
Thanks a lot, this fixes exceptions. Since I'm FreeBSD ports committer, there's no problem updating the port. However, there's question about --disable-shared. It's not needed to fix exceptions, right? Which `both instances' do you mean? There's only one in CONFIGURE_ARGS. Removing it breaks gdc under FreeBSD 6.3. Tested on devel/dsss, it won't build with `ld: cannot find -lgcc_s'.
Comment #9 by dvdfrdmn — 2008-08-07T17:28:58Z
It is not needed for the general use of exceptions. However, with --disable-shared, throwing exceptions across shared libraries may not work. Most people will not need that, so it is fine to keep the config args as is. As for "both" -- I misread the Makefile and thought the option appeared twice.