Permalink
Browse files

merge revision(s) 27939,29703,29704,30164:

	* ruby.c (ruby_init_loadpath_safe): use real path for non-shared
	  build.
	* configure.in (LIBRUBY_RELATIVE): use rpath token expansion.
	* tool/rbinstall.rb (bin-comm): prepend prolog shell script if
	  necessary.
	* ruby.c (ruby_init_loadpath_safe): relatively called non-shared
	  binary cannot be found in PATH, so use given pathname.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@35755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 2c7e082 commit ac3be749d5e94731559e50cf1d9d3dafe11f04d9 @nobu nobu committed May 22, 2012
Showing with 55 additions and 10 deletions.
  1. +13 −0 ChangeLog
  2. +10 −3 configure.in
  3. +6 −3 ruby.c
  4. +23 −1 tool/rbinstall.rb
  5. +3 −3 version.h
View
@@ -1,3 +1,16 @@
+Tue May 22 11:09:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ruby.c (ruby_init_loadpath_safe): use real path for non-shared
+ build.
+
+ * configure.in (LIBRUBY_RELATIVE): use rpath token expansion.
+
+ * tool/rbinstall.rb (bin-comm): prepend prolog shell script if
+ necessary.
+
+ * ruby.c (ruby_init_loadpath_safe): relatively called non-shared
+ binary cannot be found in PATH, so use given pathname.
+
Mon May 21 16:27:24 2012 Akinori MUSHA <knu@iDaemons.org>
* ext/syslog/syslog.c (mSyslog_inspect): Make sure self is a
View
@@ -2107,6 +2107,8 @@ AC_ARG_ENABLE(shared,
AS_HELP_STRING([--enable-shared], [build a shared library for Ruby]),
[enable_shared=$enableval])
LIBRUBYARG_SHARED='-l$(RUBY_SO_NAME)'
+libprefix='$(libdir)'
+LIBRUBY_RELATIVE=no
if test "$enable_shared" = 'yes'; then
LIBRUBY='$(LIBRUBY_SO)'
LIBRUBYARG='$(LIBRUBYARG_SHARED)'
@@ -2122,6 +2124,10 @@ if test "$enable_shared" = 'yes'; then
[linux* | gnu* | k*bsd*-gnu | atheos* | kopensolaris*-gnu], [
LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
+ if test "$load_relative" = yes; then
+ LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../lib'"
+ LIBRUBY_RELATIVE=yes
+ fi
],
[freebsd*|dragonfly*], [
SOLIBS='$(LIBS)'
@@ -2175,8 +2181,7 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_LDSHARED='$(CC) -dynamiclib'
if test "$load_relative" = yes; then
libprefix='@executable_path/../lib'
- else
- libprefix='$(libdir)'
+ LIBRUBY_RELATIVE=yes
fi
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-install_name '${libprefix}'/$(LIBRUBY_SO)'
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-current_version $(MAJOR).$(MINOR).$(TEENY)'
@@ -2194,10 +2199,12 @@ if test "$enable_shared" = 'yes'; then
])
fi
if test "$enable_rpath" = yes; then
- LIBRUBY_RPATHFLAGS="${linker_flag}-R ${linker_flag}\$(libdir) -L\$(libdir)"
+ test -z "$LIBRUBY_RPATHFLAGS" || LIBRUBY_RPATHFLAGS="$LIBRUBY_RPATHFLAGS "
+ LIBRUBY_RPATHFLAGS="$LIBRUBY_RPATHFLAGS${linker_flag}-R ${linker_flag}${libprefix} -L\$(libdir)"
LIBRUBYARG_SHARED="$LIBRUBY_RPATHFLAGS $LIBRUBYARG_SHARED"
LIBRUBYARG_STATIC="$LIBRUBY_RPATHFLAGS $LIBRUBYARG_STATIC"
fi
+AC_SUBST(LIBRUBY_RELATIVE)
LDFLAGS="-L. $LDFLAGS"
AC_SUBST(ARCHFILE)
View
9 ruby.c
@@ -370,9 +370,12 @@ ruby_init_loadpath_safe(int safe_level)
#elif defined(HAVE_DLADDR)
Dl_info dli;
if (dladdr((void *)(VALUE)expand_include_path, &dli)) {
- VALUE fname = rb_str_new_cstr(dli.dli_fname);
- sopath = rb_file_absolute_path(fname, Qnil);
- rb_str_resize(fname, 0);
+ VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
+ char fbuf[MAXPATHLEN];
+ char *f = dln_find_file_r(dli.dli_fname, getenv(PATH_ENV), fbuf, sizeof(fbuf));
+ VALUE fname = rb_str_new_cstr(f ? f : dli.dli_fname);
+ rb_str_freeze(fname);
+ sopath = rb_realpath_internal(Qnil, fname, 1);
}
else {
sopath = rb_str_new(0, 0);
View
@@ -300,6 +300,7 @@ def prepare(mesg, basedir, subdirs=nil)
dll = CONFIG["LIBRUBY_SO"]
lib = CONFIG["LIBRUBY"]
arc = CONFIG["LIBRUBY_A"]
+load_relative = configure_args.include?("--enable-load-relative")
install?(:local, :arch, :bin, :'bin-arch') do
prepare "binary commands", bindir
@@ -371,6 +372,23 @@ def prepare(mesg, basedir, subdirs=nil)
install_recursive "doc/capi", capidir, :mode => $data_mode
end
+if load_relative
+ PROLOG_SCRIPT = <<EOS
+#!/bin/sh\n# -*- ruby -*-
+bindir=`#{CONFIG["CHDIR"]} "${0%/*}" 2>/dev/null; pwd`
+EOS
+ if CONFIG["LIBRUBY_RELATIVE"] != 'yes' and libpathenv = CONFIG["LIBPATHENV"]
+ pathsep = File::PATH_SEPARATOR
+ PROLOG_SCRIPT << <<EOS
+prefix="${bindir%/bin}"
+export #{libpathenv}="$prefix/lib${#{libpathenv}#{pathsep}+#{pathsep}$#{libpathenv}}"
+EOS
+ end
+ PROLOG_SCRIPT << %Q[exec "$bindir/#{ruby_install_name}" -x "$0" "$@"\n]
+else
+ PROLOG_SCRIPT = nil
+end
+
install?(:local, :comm, :bin, :'bin-comm') do
prepare "command scripts", bindir
@@ -416,7 +434,11 @@ def prepare(mesg, basedir, subdirs=nil)
shebang = f.gets
body = f.read
end
- shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
+ if PROLOG_SCRIPT
+ shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
+ else
+ shebang.sub!(/\A\#!.*?ruby\b/) {"#!" + ruby_shebang}
+ end
shebang.sub!(/\r$/, '')
body.gsub!(/\r$/, '')
View
@@ -1,13 +1,13 @@
#define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 322
+#define RUBY_PATCHLEVEL 323
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2012
#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 21
-#define RUBY_RELEASE_DATE "2012-05-21"
+#define RUBY_RELEASE_DAY 22
+#define RUBY_RELEASE_DATE "2012-05-22"
#include "ruby/version.h"

0 comments on commit ac3be74

Please sign in to comment.