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