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