Thread overview
[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp
Feb 21, 2017
Timothee Cour
Feb 21, 2017
Timothee Cour
May 07, 2017
Andrew
May 07, 2017
Andrew
May 07, 2017
Andrew
May 07, 2017
Andrew
May 07, 2017
Andrew
Jun 04, 2020
Mathias LANG
February 21, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

Timothee Cour <timothee.cour2@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2@gmail.com

--- Comment #1 from Timothee Cour <timothee.cour2@gmail.com> ---
same with latest:
DMD64 D Compiler v2.073.1
rdmd build 20170220

--
February 21, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #2 from Timothee Cour <timothee.cour2@gmail.com> ---
workaround:
`-L-install_name -Llibfun.dylib`

--
May 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

Andrew <andrew@ugh.net.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew@ugh.net.au

--- Comment #3 from Andrew <andrew@ugh.net.au> ---
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.

--
May 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #4 from Andrew <andrew@ugh.net.au> ---
OK .tmp is added at https://github.com/dlang/tools/commit/085dc5d000b828be9a3c2dc79548352f63b52db4 to work around a Windows problem so removing it without an alternative wouldn't be good.

--
May 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #5 from Andrew <andrew@ugh.net.au> ---
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.

--
May 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #6 from Andrew <andrew@ugh.net.au> ---
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.

--
May 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17216

Andrew <andrew@ugh.net.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|dmd                         |tools

--
June 04, 2020
https://issues.dlang.org/show_bug.cgi?id=17216

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |pro.mathias.lang@gmail.com
         Resolution|---                         |MOVED

--- Comment #7 from Mathias LANG <pro.mathias.lang@gmail.com> ---
This issue has been moved to https://github.com/dlang/tools/issues/406

--