Blame SOURCES/ExtUtils-MakeMaker-7.16-USE_MM_LD_RUN_PATH.patch

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