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