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