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

Ticket #1882 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Patch for building as a dynamic library with dmd on mac

Reported by: doob Assigned to: kris
Priority: major Milestone: 1.0
Component: Tango Version: 0.99.9 Kai
Keywords: Cc: doob, larsivi

Description

This patch makes it possible to build Tango as a dynamic library with DMD on Mac OS X. To build as a dynamic library use the bob.rb script and add the "-d"/"--dynamic" option.

Every dynamic library has an install name on Mac OS X which is the path to where an executable should look in for the library when loading it. The build script sets this to "@rpath/<libname>.dylib", <libname> defaults to "libtango".

@rpath is a relative path which the user can set when compiling an executable like this: "dmd -L-rpath -L/path/to/tango/". When the executable then is loaded it will search for Tango in "/path/to/tango/libtango.dylib". -rpath can be set multiple times. The user can also change the install name with the tool "install_name_tool" without needing to recompile.

Attachments

dylib.path (13.9 kB) - added by doob on 03/16/10 12:16:51.
dylib.patch (22.0 kB) - added by doob on 05/11/10 10:19:41.
I've moved all new files to rt/compiler/dmd/darwin/

Change History

03/16/10 12:16:51 changed by doob

  • attachment dylib.path added.

03/16/10 16:52:28 changed by doob

With this patch all the module constructors from all the loaded binaries will be called.

03/17/10 18:16:49 changed by kris

this is really awesome!

05/10/10 00:36:22 changed by kris

  • cc set to doob, larsivi.
  • status changed from new to assigned.

some things don't compile with win32/dmd, doob:

dynamic_lib_fixes.c

and I'm guessing the util/darwin folder should be ignored for non-darwin builds?

05/10/10 06:28:02 changed by doob

hmm, strange, I added

exclude("tango/core/rt/util/darwin")

it's there in the patch, line 134. Oh I've only patched bob.rb, not the other bobs. And I didn't exclude dynamic_lib_fixes.c, I'll update the patch.

05/10/10 09:20:49 changed by doob

Ok, new patch:

Updated to latest trunk
bob.d can also build the dynamic library now
The runtime will automatically start if one create a dynamic library and linking with a non D application
Excluded dynamic_lib_fixes.c from non darwin builds

I've not updated bob.sh (don't now if it's up to date anyway), I refuse to touch shell scripts. I hope I haven't messed up something else on the other platforms.

(follow-up: ↓ 7 ) 05/10/10 11:41:42 changed by kris

thanks doob

there's a folder within rt/compiler/dmd for platform specifics ... can you add one for darwin, and place the darwin specifics in there please? Should the util/* additions be placed in that new folder also?

(in reply to: ↑ 6 ) 05/10/10 18:33:36 changed by doob

Replying to kris:

thanks doob there's a folder within rt/compiler/dmd for platform specifics ... can you add one for darwin, and place the darwin specifics in there please?

Sure, I missed that. I could put dynamic_lib_fixes.c in rt/compiler/dmd/posix, I guess it can be used for those platforms as well.

Should the util/* additions be placed in that new folder also?

I guess there is as good as anywhere else. I was planing on adding support for line numbers in traced exceptions for mac (when the debug info is fixed) where these files will be needed as well.

05/10/10 23:32:35 changed by kris

As an aside: we've been making duplicates of certain low-level runtime modules, rather than sharing them, where they cross platform boundaries. This allows the implementation to be adjusted accordingly without impacting anything else, and makes the build-tools much simpler to maintain.

05/11/10 10:19:41 changed by doob

  • attachment dylib.patch added.

I've moved all new files to rt/compiler/dmd/darwin/

05/22/10 14:00:37 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [5463]) fixes #1882 :: Patch for building as a dynamic library with dmd on mac

big thank-you to doob