Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1928 (new defect)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Wrong extern(Windows) for posix _d_throw()

Reported by: llucax Assigned to: community
Priority: major Milestone: 1.0
Component: Runtime Version: 0.99.9 Kai
Keywords: Cc: luca@llucax.com.ar

Description

I'm trying to build tango as a shared object and I get an error about symbol _d_throw() not found.

Here is a simple patch to fix that:

diff --git a/tango/core/rt/compiler/dmd/posix/deh.d b/tango/core/rt/compiler/dmd/posix/deh.d
index 31a54af..9e3c851 100644
--- a/tango/core/rt/compiler/dmd/posix/deh.d
+++ b/tango/core/rt/compiler/dmd/posix/deh.d
@@ -154,7 +154,7 @@ uint __eh_find_caller(uint regbp, uint *pretaddr)
  * Throw a D object.
  */
 
-extern (Windows) void _d_throw(Object *h)
+extern (C) void _d_throw(Object *h)
 {
     uint regebp;
 

Change History

06/13/10 23:22:27 changed by llucax

  • summary changed from Wrong extern(Windows) for posix _d_throw() to [PATCH] Wrong extern(Windows) for posix _d_throw().

06/14/10 07:26:01 changed by doob

I'm interested how you compiled this. I've tried compiling tango as a dynamic library myself using dmd on ubuntu. This is the errors I get:

/usr/bin/ld: libtango.so: version node not found for symbol _d_throw@4
/usr/bin/ld: failed to set dynamic section sizes: Bad value

If I change "extern (Windows)" to "extern (C)" I get:

/usr/bin/ld: libtango.so: No symbol version section for versioned symbol `_d_throw@4'
/usr/bin/ld: final link failed: Nonrepresentable section on output

06/14/10 10:37:05 changed by llucax

I think that discussion is more appropriate in bug #857. I'll post my findings about compiling tango as a shared object there so we can keep things on-topic :)

06/16/10 21:43:38 changed by llucax

OK, this is weird. With this patch applied, now I get errors when linking using tango compiled as a static lib.

lib/libtango-basic.a(Conduit.d.o): In function `_D5tango2io6device7Conduit7Conduit5errorMFAaZv':
tango/io/device/Conduit.d:(.text._D5tango2io6device7Conduit7Conduit5errorMFAaZv+0x21): undefined reference to `_d_throw@4'
lib/libtango-basic.a(Exception.d.o): In function `onAssertError':
tango/core/Exception.d:(.text.onAssertError+0x2e): undefined reference to `_d_throw@4'
lib/libtango-basic.a(Exception.d.o): In function `onAssertErrorMsg':
tango/core/Exception.d:(.text.onAssertErrorMsg+0x34): undefined reference to `_d_throw@4'
lib/libtango-basic.a(Exception.d.o): In function `onArrayBoundsError':
tango/core/Exception.d:(.text.onArrayBoundsError+0x26): undefined reference to `_d_throw@4'
lib/libtango-basic.a(Exception.d.o): In function `onFinalizeError':
tango/core/Exception.d:(.text.onFinalizeError+0x1f): undefined reference to `_d_throw@4'
lib/libtango-basic.a(Exception.d.o):tango/core/Exception.d:(.text.onOutOfMemoryError+0xa): more undefined references to `_d_throw@4' follow
collect2: ld returned 1 exit status
--- errorlevel 1

This is really odd, extern (Windows) in POSIX? WTF! =)

06/18/10 00:57:21 changed by kris

I wonder if the declared argument types are simply wrong for the platform?

06/27/10 19:06:16 changed by llucax

Here is the problem: http://d.puremagic.com/issues/show_bug.cgi?id=4398

dmd always uses Windows name mangling for _d_throw


When calling _d_throw dmd always uses the name _d_throw@4 regardless of the
operating system. Dynamic ELF libraries support versioning symbols using the
syntax name@version. Therefore when ld encounters _d_throw@4 it reads "symbol
_d_throw, version 4" and complains that there is no version 4. As long as this
isn't fixed Dynamic D libraries can't be created on operating systems using ELF
executables.

For more details, see the bug report...

I think this could not be fixed until DMD is fixed.