なかだです。

At Wed, 8 Dec 2004 00:16:05 +0900,
Takahiro Kambe wrote in [ruby-dev:25105]:
> > enable と disable のどっちをデフォルトにするかが悩ましいとこ
> > ろではありますが。
> 明らかに disable なポリシーを持つプラットフォームについてデフォルトを
> disable, それ以外は enable とかできるでしょうか?
> 
> 基本的にELFな実行形式を使用しているシステムに共通する問題と思います。

全部まとめて、ELF環境ではデフォルトenableにしてみました。もしか
して、-Wl,-export-dynamicもELFに共通でしょうか。

* configure.in (enable_rpath): use rpath flag to embed the library
  path into extensions on ELF environment.  [ruby-dev:25035]


Index: configure.in =================================================================== RCS file: /cvs/ruby/src/ruby/configure.in,v retrieving revision 1.258 diff -U2 -p -d -r1.258 configure.in --- configure.in 7 Dec 2004 06:44:42 -0000 1.258 +++ configure.in 7 Dec 2004 15:47:34 -0000 @@ -784,12 +784,4 @@ linux* | gnu* | k*bsd*-gnu) LDFLAGS="$LDFLAGS -rdynamic" fi;; -netbsd*|openbsd*) - if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]] - then - netbsd_elf=yes - else - netbsd_elf=no - fi - ;; esac LIBEXT=a @@ -859,6 +851,9 @@ if test "$with_dln_a_out" != yes; then osf*) : ${LDSHARED="ld -shared -expect_unresolved \"*\""} rb_cv_dlopen=yes ;; - linux* | gnu* | k*bsd*-gnu) - : ${LDSHARED="$CC -shared"} + linux* | gnu* | k*bsd*-gnu | netbsd*) + : ${LDSHARED='${CC} -shared'} + if test "$rb_cv_binary_elf" = yes; then + LDFLAGS="$LDFLAGS -Wl,-export-dynamic" + fi rb_cv_dlopen=yes ;; interix*) : ${LDSHARED="$CC -shared"} @@ -874,11 +869,4 @@ if test "$with_dln_a_out" != yes; then fi rb_cv_dlopen=yes ;; - netbsd*) : ${LDSHARED='${CC} -shared'} - if test "$rb_cv_binary_elf" = yes; then - LDFLAGS="$LDFLAGS -Wl,-export-dynamic" - LIBPATHFLAG=" -L'%1\$-s'" - RPATHFLAG=" -Wl,-R'%1\$-s'" - fi - rb_cv_dlopen=yes ;; openbsd*) : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"} if test "$rb_cv_binary_elf" = yes; then @@ -951,4 +939,12 @@ if test "$with_dln_a_out" != yes; then esac AC_MSG_RESULT($rb_cv_dlopen) + + AC_ARG_ENABLE(rpath, + [ --disable-rpath embedd run path.], + [enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"]) + if test "$enable_rpath" = yes; then + LIBPATHFLAG=" -L'%1\$-s'" + RPATHFLAG=" -Wl,-R'%1\$-s'" + fi fi AC_SUBST(LINK_SO) @@ -1161,5 +1157,5 @@ if test "$enable_shared" = 'yes'; then LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' ;; - linux* | gnu* | k*bsd*-gnu) + linux* | gnu* | k*bsd*-gnu | atheos*) 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' @@ -1177,5 +1173,4 @@ if test "$enable_shared" = 'yes'; then LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)' LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)' - LIBRUBYARG_SHARED='-Wl,-R -Wl,${libdir} -L${libdir} -L. -l$(RUBY_SO_NAME)' if test "$rb_cv_binary_elf" = yes; then # ELF platforms LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so' @@ -1189,4 +1184,12 @@ if test "$enable_shared" = 'yes'; then ;; solaris*) + SOLIBS='$(LIBS)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY) lib$(RUBY_SO_NAME).so' + if test "$GCC" = yes; then + LIBRUBY_DLDFLAGS="$DLDFLAGS "'-Wl,-h,$(@F)' + else + enable_rpath=no + fi XLDFLAGS="$XLDFLAGS "'-R${libdir}' ;; @@ -1220,8 +1223,4 @@ if test "$enable_shared" = 'yes'; then LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib' ;; - atheos*) - 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' - ;; interix*) LIBRUBYARG_SHARED='-L${libdir} -L. -l$(RUBY_SO_NAME)' @@ -1231,4 +1230,8 @@ if test "$enable_shared" = 'yes'; then esac fi +if test "$enable_rpath" = yes; then + LIBRUBYARG_SHARED='-Wl,-R -Wl,$(libdir) -L$(libdir) -L. '"$LIBRUBYARG_SHARED" +fi + XLDFLAGS="$XLDFLAGS -L." AC_SUBST(ARCHFILE) Index: runruby.rb =================================================================== RCS file: /cvs/ruby/src/ruby/runruby.rb,v retrieving revision 1.2 diff -U2 -p -d -r1.2 runruby.rb --- runruby.rb 8 Apr 2004 10:45:19 -0000 1.2 +++ runruby.rb 7 Dec 2004 06:11:02 -0000 @@ -45,7 +45,12 @@ end ENV["RUBYLIB"] = $:.replace(libs).join(File::PATH_SEPARATOR) -if File.file?(File.join(archdir, config['LIBRUBY_SO'])) and - e = config['LIBPATHENV'] and !e.empty? - ENV[e] = [abs_archdir, ENV[e]].compact.join(File::PATH_SEPARATOR) +libruby_so = File.join(abs_archdir, config['LIBRUBY_SO']) +if File.file?(libruby_so) + if e = config['LIBPATHENV'] and !e.empty? + ENV[e] = [abs_archdir, ENV[e]].compact.join(File::PATH_SEPARATOR) + end + if /linux/ =~ RUBY_PLATFORM + ENV["LD_PRELOAD"] = [libruby_so, ENV["LD_PRELOAD"]].compact.join(' ') + end end
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦