Thread overview
[Issue 2182] New: Exceptions don't work on FreeBSD
Jun 28, 2008
d-bugmail
Jul 20, 2008
d-bugmail
Jul 23, 2008
d-bugmail
Jul 24, 2008
d-bugmail
Jul 28, 2008
d-bugmail
Jul 28, 2008
d-bugmail
Aug 05, 2008
d-bugmail
Aug 06, 2008
d-bugmail
Aug 07, 2008
d-bugmail
Aug 07, 2008
d-bugmail
June 28, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182

           Summary: Exceptions don't work on FreeBSD
           Product: DGCC aka GDC
           Version: unspecified
          Platform: PC
        OS/Version: Other
            Status: NEW
          Keywords: EH
          Severity: major
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn@users.sf.net
        ReportedBy: korslund@gmail.com


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.


-- 

July 20, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182


dvdfrdmn@users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dvdfrdmn@users.sf.net
             Status|NEW                         |ASSIGNED




------- Comment #1 from dvdfrdmn@users.sf.net  2008-07-20 11:30 -------
I need to know the following:

OS Version
Architecture
GCC Version you are building
GDC Version (release or SVN revision)


-- 

July 23, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #2 from amdmi3@amdmi3.ru  2008-07-23 05:49 -------
> 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.


-- 

July 24, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #3 from dvdfrdmn@users.sf.net  2008-07-23 22:08 -------
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?


-- 

July 28, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #4 from amdmi3@amdmi3.ru  2008-07-28 14:23 -------
I've just used gdc from ports.


-- 

July 28, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #5 from amdmi3@amdmi3.ru  2008-07-28 14:31 -------
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)


-- 

August 05, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #6 from amdmi3@amdmi3.ru  2008-08-05 02:52 -------
So, can you confirm the bug with gdc from ports?


-- 

August 06, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182


dvdfrdmn@users.sf.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |WONTFIX




------- Comment #7 from dvdfrdmn@users.sf.net  2008-08-05 22:40 -------
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.


-- 

August 07, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182


amdmi3@amdmi3.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amdmi3@amdmi3.ru




------- Comment #8 from amdmi3@amdmi3.ru  2008-08-07 13:56 -------
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'.


-- 

August 07, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2182





------- Comment #9 from dvdfrdmn@users.sf.net  2008-08-07 17:28 -------
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.


--