bfb6af
From 83b4921f10f9df96ec359e20489864080f7b37ca Mon Sep 17 00:00:00 2001
bfb6af
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
bfb6af
Date: Thu, 12 Jan 2012 17:05:19 +0100
bfb6af
Subject: [PATCH] Do not set RPATH by default
bfb6af
MIME-Version: 1.0
bfb6af
Content-Type: text/plain; charset=UTF-8
bfb6af
Content-Transfer-Encoding: 8bit
bfb6af
bfb6af
Former behavior can be forced by setting USE_MM_LD_RUN_PATH
bfb6af
environment variable to 1.
bfb6af
bfb6af
This is copy from `perl' package.
bfb6af
See <https://bugzilla.redhat.com/show_bug.cgi?id=773622>.
bfb6af
bfb6af
Signed-off-by: Petr Písař <ppisar@redhat.com>
bfb6af
---
bfb6af
 lib/ExtUtils/Liblist.pm   |  5 +++++
bfb6af
 lib/ExtUtils/MM_Unix.pm   |  2 +-
bfb6af
 lib/ExtUtils/MakeMaker.pm | 56 ++++++++++++++++++++++++++++++++++++++++++++++-
bfb6af
 3 files changed, 61 insertions(+), 2 deletions(-)
bfb6af
bfb6af
diff --git a/lib/ExtUtils/Liblist.pm b/lib/ExtUtils/Liblist.pm
bfb6af
index 15eed3c..219e96b 100644
bfb6af
--- a/lib/ExtUtils/Liblist.pm
bfb6af
+++ b/lib/ExtUtils/Liblist.pm
bfb6af
@@ -89,6 +89,11 @@ libraries.  LD_RUN_PATH is a colon separated list of the directories
bfb6af
 in LDLOADLIBS. It is passed as an environment variable to the process
bfb6af
 that links the shared library.
bfb6af
 
bfb6af
+Fedora extension: This generation of LD_RUN_PATH is disabled by default.
bfb6af
+To use the generated LD_RUN_PATH for all links, set the USE_MM_LD_RUN_PATH
bfb6af
+MakeMaker object attribute / argument, (or set the $USE_MM_LD_RUN_PATH
bfb6af
+environment variable).
bfb6af
+
bfb6af
 =head2 BSLOADLIBS
bfb6af
 
bfb6af
 List of those libraries that are needed but can be linked in
bfb6af
diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm
bfb6af
index 6233513..198f05e 100644
bfb6af
--- a/lib/ExtUtils/MM_Unix.pm
bfb6af
+++ b/lib/ExtUtils/MM_Unix.pm
bfb6af
@@ -1045,7 +1045,7 @@ sub xs_make_dynamic_lib {
bfb6af
     }
bfb6af
 
bfb6af
     my $ld_run_path_shell = "";
bfb6af
-    if ($self->{LD_RUN_PATH} ne "") {
bfb6af
+    if (($self->{LD_RUN_PATH} ne "") && ($self->{USE_MM_LD_RUN_PATH})) {
bfb6af
         $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
bfb6af
     }
bfb6af
 
bfb6af
diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm
bfb6af
index 3d4913e..b52c96d 100644
bfb6af
--- a/lib/ExtUtils/MakeMaker.pm
bfb6af
+++ b/lib/ExtUtils/MakeMaker.pm
bfb6af
@@ -317,7 +317,7 @@ sub full_setup {
bfb6af
     PERM_DIR PERM_RW PERM_RWX MAGICXS
bfb6af
     PL_FILES PM PM_FILTER PMLIBDIRS PMLIBPARENTDIRS POLLUTE
bfb6af
     PREREQ_FATAL PREREQ_PM PREREQ_PRINT PRINT_PREREQ
bfb6af
-    SIGN SKIP TEST_REQUIRES TYPEMAPS UNINST VERSION VERSION_FROM XS
bfb6af
+    SIGN SKIP TEST_REQUIRES TYPEMAPS UNINST USE_MM_LD_RUN_PATH VERSION VERSION_FROM XS
bfb6af
     XSBUILD XSMULTI XSOPT XSPROTOARG XS_VERSION
bfb6af
     clean depend dist dynamic_lib linkext macro realclean tool_autosplit
bfb6af
 
bfb6af
@@ -503,6 +503,26 @@ sub new {
bfb6af
         $self->_PRINT_PREREQ;
bfb6af
    }
bfb6af
 
bfb6af
+    # USE_MM_LD_RUN_PATH - another RedHatism to disable automatic RPATH generation
bfb6af
+    if ( ( ! $self->{USE_MM_LD_RUN_PATH} )
bfb6af
+       &&( ("@ARGV" =~ /\bUSE_MM_LD_RUN_PATH(=([01]))?\b/)
bfb6af
+        ||( exists( $ENV{USE_MM_LD_RUN_PATH} )
bfb6af
+           &&( $ENV{USE_MM_LD_RUN_PATH} =~ /([01])?$/ )
bfb6af
+           )
bfb6af
+        )
bfb6af
+       )
bfb6af
+    {
bfb6af
+       my $v = $1;
bfb6af
+       if( $v )
bfb6af
+       {
bfb6af
+           $v = ($v=~/=([01])$/)[0];
bfb6af
+       }else
bfb6af
+       {
bfb6af
+           $v = 1;
bfb6af
+       };
bfb6af
+       $self->{USE_MM_LD_RUN_PATH}=$v;
bfb6af
+    };
bfb6af
+
bfb6af
     print "MakeMaker (v$VERSION)\n" if $Verbose;
bfb6af
     if (-f "MANIFEST" && ! -f "Makefile" && ! $UNDER_CORE){
bfb6af
         check_manifest();
bfb6af
@@ -2797,6 +2817,40 @@ precedence.  A typemap in the current directory has highest
bfb6af
 precedence, even if it isn't listed in TYPEMAPS.  The default system
bfb6af
 typemap has lowest precedence.
bfb6af
 
bfb6af
+=item USE_MM_LD_RUN_PATH
bfb6af
+
bfb6af
+boolean
bfb6af
+The Fedora perl MakeMaker distribution differs from the standard
bfb6af
+upstream release in that it disables use of the MakeMaker generated
bfb6af
+LD_RUN_PATH by default, UNLESS this attribute is specified , or the
bfb6af
+USE_MM_LD_RUN_PATH environment variable is set during the MakeMaker run.
bfb6af
+
bfb6af
+The upstream MakeMaker will set the ld(1) environment variable LD_RUN_PATH
bfb6af
+to the concatenation of every -L ld(1) option directory in which a -l ld(1)
bfb6af
+option library is found, which is used as the ld(1) -rpath option if none
bfb6af
+is specified. This means that, if your application builds shared libraries
bfb6af
+and your MakeMaker application links to them, that the absolute paths of the
bfb6af
+libraries in the build tree will be inserted into the RPATH header of all
bfb6af
+MakeMaker generated binaries, and that such binaries will be unable to link
bfb6af
+to these libraries if they do not still reside in the build tree directories
bfb6af
+(unlikely) or in the system library directories (/lib or /usr/lib), regardless
bfb6af
+of any LD_LIBRARY_PATH setting. So if you specified -L../mylib -lmylib , and
bfb6af
+ your 'libmylib.so' gets installed into /some_directory_other_than_usr_lib,
bfb6af
+ your MakeMaker application will be unable to link to it, even if LD_LIBRARY_PATH
bfb6af
+is set to include /some_directory_other_than_usr_lib, because RPATH overrides
bfb6af
+LD_LIBRARY_PATH.
bfb6af
+
bfb6af
+So for Fedora MakeMaker builds LD_RUN_PATH is NOT generated by default for
bfb6af
+every link. You can still use explicit -rpath ld options or the LD_RUN_PATH
bfb6af
+environment variable during the build to generate an RPATH for the binaries.
bfb6af
+
bfb6af
+You can set the USE_MM_LD_RUN_PATH attribute to 1 on the MakeMaker command
bfb6af
+line or in the WriteMakefile arguments to enable generation of LD_RUN_PATH
bfb6af
+for every link command.
bfb6af
+
bfb6af
+USE_MM_LD_RUN_PATH will default to 1 (LD_RUN_PATH will be used) IF the
bfb6af
+$USE_MM_LD_RUN_PATH environment variable is set during a MakeMaker run.
bfb6af
+
bfb6af
 =item VENDORPREFIX
bfb6af
 
bfb6af
 Like PERLPREFIX, but only for the vendor install locations.
bfb6af
-- 
bfb6af
2.13.6
bfb6af