ports/176901: [bsd.cmake.mk] disable rpath removal
Dmitry Marakasov
amdmi3 at FreeBSD.org
Wed Mar 13 01:50:00 UTC 2013
>Number: 176901
>Category: ports
>Synopsis: [bsd.cmake.mk] disable rpath removal
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Mar 13 01:50:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Dmitry Marakasov
>Release: FreeBSD 9.0-RELEASE-p3 amd64
>Organization:
>Environment:
System: FreeBSD hades.panopticon 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Wed Jun 13 17:39:20 MSK 2012 root at hades.panopticon:/usr/obj/usr/src/sys/HADES amd64
>Description:
When cmake builds a binary or a library, it adds an RPATH to it pointing to the build directory. This is needed so when a binary is ran from the build directory, it's able to find all its libraries without using LD_LIBRARY_PATH.
When cmake installs binaries, RPATHs are removed, as installed software will pick its libraries from the systemwide path known to dynamic linker. However, cmake removes _all_ RPATHs, including ones explicitly provided via e.g. LDFLAGS.
The problem arises when the port is build with newer gcc (USE_GCC=4.6+). The resulting binaries may depend on C++ features (for example, C++11 bits) support for whuch is only present in newer gcc's libstdc++ (/usr/local/lib/gcc46/libstdc++.so), but not in the base system /usr/lib/libstdc++.so. The former rpath is added by bsd.gcc.mk, but it has no effect as cmake removes it. In result, a binary will use /usr/lib/libstdc++.so, and won't run with the following message:
/usr/lib/libstdc++.so.6: version GLIBCXX_3.4.11 required by <binary> not found
This may be fixed by adding LD_LIBRARY_PATH=/usr/local/lib/gcc46 to the environement.
To fix that globally I propose the attached path. It disables adding build rpath to the binaries (we don't need it since ports are not intended to be ran from work/ anyway), which as well makes cmake _not_ remove RPATHs from installed binaries. With it, binaries use correct libstdc++ from the newer gcc and run without LD_LIBRARY_PATH hacks.
I'm not sure which side effects it may have, so exp-run is advised.
>How-To-Repeat:
>Fix:
--- bsd.cmake.mk.patch begins here ---
Index: Mk/bsd.cmake.mk
===================================================================
--- Mk/bsd.cmake.mk (revision 311274)
+++ Mk/bsd.cmake.mk (working copy)
@@ -61,7 +61,8 @@
-DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" \
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \
- -DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES
+ -DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES \
+ -DCMAKE_SKIP_BUILD_RPATH:BOOL=YES
#
# Default build type and sourcedir
--- bsd.cmake.mk.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list