Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: Compiling a shared library with rdmd points to name.dylib.tmp instead of name.dylib #406

Open
dlang-bugzilla-migration opened this issue Jun 4, 2020 · 0 comments
Labels
OS.OSX Related to a Mac OSX-specific behavior (excluding iOS derivatives) Prio.1.Regression Used to work in a previous version, but not anymore Type.Bug Things don't work as they were intended to, or the way they were intended to work doesn't make sense

Comments

@dlang-bugzilla-migration
Copy link

dlang-bugzilla-migration commented Jun 4, 2020

Transferred from: https://issues.dlang.org/show_bug.cgi?id=17216

User @timotheecour reported (2017-Feb-21 05:06:39):

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)

User @timotheecour responded (2017-Feb-21 05:17:26):

same with latest:
DMD64 D Compiler v2.073.1
rdmd build 20170220

User @timotheecour responded (2017-Feb-21 05:33:14):

workaround:
-L-install_name -Llibfun.dylib

User @cqexbesd responded (2017-May-07 13:44:23):

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.

User @cqexbesd responded (2017-May-07 13:49:35):

OK .tmp is added at 085dc5d to work around a Windows problem so removing it without an alternative wouldn't be good.

User @cqexbesd responded (2017-May-07 14:29:52):

I now have a fix at https://github.com/cqexbesd/tools/tree/dlang_17216.

It's not great - it just makes the windows work around only happen under Windows.

Given https://github.com/cqexbesd/tools/blob/d27bcc1228863ba0a3b0ae5cf47a8d3a409bda45/rdmd.d#L461-L481 however I'm not sure that the windows workaround should still be needed. The rm code didn't exist when the workaround was added AFAIK. I might try removing the workaround and finding a windows user who can test it.

User @cqexbesd responded (2017-May-07 14:37:38):

Second proposed fix (removing the use of .tmp altogether) is at https://github.com/cqexbesd/tools/tree/dlang_17216_v2. I don't have a copy of Windows so it needs testing - but it works under OSX.

@dlang-bugzilla-migration dlang-bugzilla-migration added Type.Bug Things don't work as they were intended to, or the way they were intended to work doesn't make sense OS.OSX Related to a Mac OSX-specific behavior (excluding iOS derivatives) Prio.1.Regression Used to work in a previous version, but not anymore labels Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS.OSX Related to a Mac OSX-specific behavior (excluding iOS derivatives) Prio.1.Regression Used to work in a previous version, but not anymore Type.Bug Things don't work as they were intended to, or the way they were intended to work doesn't make sense
Projects
None yet
Development

No branches or pull requests

1 participant