[Bug 208120] devel/cmake: Strips necessary rpath when installing any GNU compiler from ports

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Dec 11 17:02:07 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208120

Tijl Coosemans <tijl at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tijl at FreeBSD.org

--- Comment #19 from Tijl Coosemans <tijl at FreeBSD.org> ---
If an executable depends on a library (including indirect dependencies) that
needs a particular rpath then that executable should also be linked with that
rpath.  Here's an example that shows why:

program links to libA which links to (old) libgcc_s
        links to libB which requires new libgcc_s

If program does not have an rpath then rtld(1) will load old libgcc_s as part
of loading libA and then fail when loading libB.

Translated to Fortran ports this becomes:

If a port installs an executable that depends on a library from another port
(including indirect dependencies) that has USES=fortran then that port should
also set USES=fortran.

It doesn't matter what compiler that port is compiled with (including clang!)
so there are no (simple) hacks you can add to files under Mk or to cmake to
detect this case.  Just add USES=fortran (perhaps with a comment that explains
why).

That said, I recently found out that gfortran, g++ and gcj call the gcc backend
with -shared-libgcc which means they link pretty much every program and library
with libgcc_s.  Clang, clang++ and gcc don't do that and instead link with
"-lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed".  Because libgcc (static
library) contains all symbols from libgcc_s except _Unwind_*, libgcc_s is
almost never needed, only for code that needs stack unwinding (for instance to
throw and catch exceptions).  Because Fortran as far as I know doesn't support
exceptions, patching gfortran to remove -shared-libgcc would remove pretty much
all links to libgcc_s from Fortran libraries.  They would still link to
libgfortran but there's no libgfortran in base to cause trouble.  There could
still be trouble when mixing libraries compiled with different versions of
gfortran, which may happen on user systems when the default gcc version has
been changed.  In this case it would still be good if ports that depend on
ports that have USES=fortran also set USES=fortran.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the kde-freebsd mailing list