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