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

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