Bug 17216 – OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp
Status
RESOLVED
Resolution
MOVED
Severity
regression
Priority
P1
Component
tools
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2017-02-21T05:06:39Z
Last change time
2020-06-04T16:58:51Z
Assigned to
No Owner
Creator
Timothee Cour
Comments
Comment #0 by timothee.cour2 — 2017-02-21T05:06:39Z
v2.072.2
rdmd build 20170108
fun.d:whatever
rdmd -v --force --build-only -shared -oflibfun.dylib fun.d
creates libfun.dylib
otool -L libfun.dylib
libfun.dylib:
libfun.dylib.tmp (compatibility version 0.0.0, current version 0.0.0)
libfun.dylib.tmp is wrong, and will cause errors when linking via `-lfun`, eg:
`dyld: Library not loaded: libfun.dylib.tmp`
This used to work on OSX (and works on linux)
Comment #1 by timothee.cour2 — 2017-02-21T05:17:26Z
same with latest:
DMD64 D Compiler v2.073.1
rdmd build 20170220
Comment #2 by timothee.cour2 — 2017-02-21T05:33:14Z
workaround:
`-L-install_name -Llibfun.dylib`
Comment #3 by andrew — 2017-05-07T13:44:23Z
This is still occurring in HEAD.
When rdmd calls dmd it gives an output name that ends with ".tmp" (https://github.com/dlang/tools/blob/master/rdmd.d#L483-L488) and that is what dmd passes to clang (used for linking under OSX). As the install_name arg isn't given thats what ends up being the install_name of the dylib and hence this problem.
There are two obvious ways of fixing it - get dmd to call clang with install_name or run install_name_tool after building.
Neither seem obviously great - IIUC rdmd doesn't know its building a shared library so doesn't know install_name is important. dmd does know but isn't aware that rdmd has passed it a dummy output name that will later get mv'ed to the final name.
I don't yet know if rdmd _needs_ to use the .tmp then mv trick but I'm guessing its there to cope with some sort of error on some platform - if that could be avoided the problem would disappear. Anything else seems to require rdmd learning about shared libraries under OSX or dmd having more awareness of rdmd.