4080 – Patch for building dynamic libraries on Mac OS X

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4080 - Patch for building dynamic libraries on Mac OS X
Summary: Patch for building dynamic libraries on Mac OS X
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P3 normal
Assignee: Sean Kelly
URL:
Keywords:
Depends on:
Blocks:
Reported: 2010年04月11日 05:48 UTC by Jacob Carlborg
Modified: 2024年12月07日 13:30 UTC (History)
1 user (show)

See Also:


Attachments
Adds the "-dylib" flag (3.99 KB, patch)
2010年04月11日 05:48 UTC, Jacob Carlborg
Details | Diff
Adds support for building dynamic libraries (14.68 KB, patch)
2010年04月11日 05:49 UTC, Jacob Carlborg
Details | Diff
Adds support for building dynamic libraries (871 bytes, patch)
2010年04月11日 05:50 UTC, Jacob Carlborg
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2010年04月11日 05:48:49 UTC
Created attachment 606 [details] 
Adds the "-dylib" flag
These three patches adds support for building dynamic libraries on Mac OS X.
The patch for DMD adds the "-dylib" flag to the compiler. Building with this
flag enabled will produce a dynamic library.
The patch for druntime makes the necessary changes to build dynamic libraries.
The D main function is now weakly linked, all of the module constructors of all
the loaded images (executables, dynamic libraries) are run. The C main function
is slightly modified to use the rt_init and rt_term functions. Two C functions
are also added the will initialize and terminate the runtime if no D main
function is available, i.e. a D plugin linked with a C application.
The patch for phobos is just some modifications to the make file.
To build druntime and phobos as dynamic libraries add "dynamic", i.e. "make -f
osx.mak dynamic".
A note about dynamic libraries on Mac OS X:
Every dynamic library has an install name on Mac OS X which is the path to
where an executable should look for the library when loading it. The build
script sets this to "@rpath/<libname>.dylib", where <libname> is "libdruntime"
or "libphobos2".
@rpath is a relative path which the user can set when compiling an executable
like this: "dmd -L-rpath -L/path/to/library/". When the executable then is
loaded it will search for the library in "/path/to/library/<libname>.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.
A change to the dmd.conf file is also needed. With this change the user doesn't
have to set the @rpath every time when compiling. "libdruntime" must also be
linked.
DFLAGS=-I%@P%/../src/phobos -I%@P%/../src/druntime/import -L-L%@P%/../lib
-L-rpath -L%@P%/../lib -L%@P%/../lib/libdruntime.dylib
Comment 1 Jacob Carlborg 2010年04月11日 05:49:32 UTC
Created attachment 607 [details] 
Adds support for building dynamic libraries
Comment 2 Jacob Carlborg 2010年04月11日 05:50:13 UTC
Created attachment 608 [details] 
Adds support for building dynamic libraries
Comment 3 Jacob Carlborg 2010年04月11日 05:52:34 UTC
BTW the make files probably needs some cleaning up, make files are not my strong side.
Comment 4 Walter Bright 2010年06月24日 14:29:00 UTC
dmd portion: http://www.dsource.org/projects/dmd/changeset/559 
Comment 5 Walter Bright 2010年08月26日 14:21:48 UTC
http://www.dsource.org/projects/dmd/changeset/372
I changed the location of the new files to be more consistent with druntime's existing conventions:
Adding src\core\sys\osx\mach\dyld.d
Adding src\core\sys\osx\mach\getsect.d
Adding src\core\sys\osx\mach\loader.d
Adding src\rt\dylib_fixes.c
Adding src\rt\image.d
Comment 6 dlangBugzillaToGithub 2024年12月07日 13:30:53 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/17222
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB


AltStyle によって変換されたページ (->オリジナル) /