Since the versions starting from phobos 2.087 have this
merged pull request: dlang/phobos#6966
It is no longer necessary to manually create the symlink.
This reverts commit 81121388003524852b37a72a0506bfa3da2c5c15.
Upstream phobos still does not generate the symlink, even though the PR
adding it was merged before the 2.086.0 release. We therefore need to
keep this workaround in the snap package.
The phobos makefile during the "install" task does not create the
Since the versions starting from phobos 2.086 have this
merged pull request: https://github.com/dlang/phobos/pull/6966
it is no longer necessary to manually create the symlink.
Added the missing sys link of libphobos
The phobos makefile during the "install" task does not create the
symbolic link of libphobos2.so.X.Y.Z to libphobos2.so.X.Y, this causes
problems loading the shared phobos library, so we go to create the
symbolic link manually.
Makes LD_LIBRARY_PATH more priority
An expert user might want to replace the shared phobos library
with a compiled by him, generally using LD_LIBRARY_PATH to
specify the path of a temporary library.
Unfortunately rpath has more priority than LD_LIBRARY_PATH,
so in the presence of the snap package it would be impossible to
use LD_LIBRARY_PATH.
Fortunately GNU-LD.SO contains the functionality new-dtags, which
allows to give more priority to LD_LIBRARY_PATH.
So just enable it to change how the linker works as follows:
path specified with LD_LIBRARY_PATH -> if missing -> RPATH in our package -> if missing -> path specified in ld.so.conf -> default path of ld.so (/usr/lib and /lib)
In order to use phobos as a shared library, the linker needs
to know where to look for the library (the .so file), generally
all libraries are placed in /usr/lib or in /usr/lib/x86_64-linux-gnu.
Unfortunately the path in which the snaps are installed
(/snap/<snap name)> is not configured in /etc/ld.so.conf,
which describes the path where the linker can look for libraries,
because of this it would be impossible to load the phobos shared
library contained in this snap package.
To make up for this lack we can use the rpath, which allows us to
specify in the compiled executable the position in which the linker
should go looking before using ld.so.conf.
By setting the path for all the executables compiled by dmd
contained in our package, we will force the linker to search first in our
path, in this way it will be possible to use the shared phobos library
because the linker will have the possibility to find it within the
path specified with rpath.
In short, the linker will search like this:
RPATH in our package -> if missing -> path specified with LD_LIBRARY_PATH -> if missing -> path specified in ld.so.conf -> default path of ld.so (/usr/lib and /lib)
Using rpath it will not cause any incompatibility problem with the
compiled executables because in case of lack of the specified path it
will go anyway to look for ld.so.conf
Furthermore the use of rpath will increase the security of the
executables linked with the shared phobos library because it will be
impossible to replace the library in the presence of the snap package.