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