plruby: --enable-static-ruby / --disable-shared ?

D

David Garamond

What about adding these configure option, so plruby.so doesn't need
libruby.so at all? But sorry, I'm still not sure how to modify
extconf.rb to accomplish this. In the Makefile I just replace LIBS=
$(LIBRUBYARG_SHARED) with $(LIBRUBYARG_STATIC).
 
T

ts

D> What about adding these configure option, so plruby.so doesn't need
D> libruby.so at all? But sorry, I'm still not sure how to modify
D> extconf.rb to accomplish this. In the Makefile I just replace LIBS=
D> $(LIBRUBYARG_SHARED) with $(LIBRUBYARG_STATIC).

What is your version of plruby and ruby ?

svg% ruby extconf.rb --with-pgsql-dir=$HOME/local/pgsql
checking for ruby_init() in -lruby-static... yes
checking for catalog/pg_proc.h... yes
checking for PQsetdbLogin() in -lpq... yes
checking for rb_hash_delete()... yes
checking for server/utils/array.h... yes
creating Makefile

========================================================================
After the installation use something like this to create the language
plruby


create function plruby_call_handler() returns language_handler
as '/usr/local/lib/ruby/site_ruby/1.8/i686-linux/plruby.so'
language 'C';

create trusted language 'plruby'
handler plruby_call_handler
lancompiler 'PL/Ruby';

========================================================================
svg%

svg% grep LIBS src/Makefile
LOCAL_LIBS =
LIBS = -lpq -lruby-static -ldl -lcrypt -lm -lc
CLEANLIBS = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $(DLLIB) $(OBJS) $(LOCAL_LIBS) $(LIBS)
svg%



Guy Decoux
 
D

David Garamond

ts said:
D> What about adding these configure option, so plruby.so doesn't need
D> libruby.so at all? But sorry, I'm still not sure how to modify
D> extconf.rb to accomplish this. In the Makefile I just replace LIBS=
D> $(LIBRUBYARG_SHARED) with $(LIBRUBYARG_STATIC).

What is your version of plruby and ruby ?

plruby 0.3.9, ruby 1.8.1 (using Ian's binary RPM).

$ ruby -v extconf.rb --with-pgsql-include=/usr/include/pgsql
ruby 1.8.1 (2004-01-01) [i686-linux-gnu]
checking for ruby_init() in -lruby-static... yes
checking for catalog/pg_proc.h... yes
checking for PQsetdbLogin() in -lpq... yes
checking for rb_hash_delete()... yes
checking for server/utils/array.h... yes
creating Makefile

========================================================================
After the installation use something like this to create the language
plruby


create function plruby_call_handler() returns language_handler
as '/usr/lib/ruby/site_ruby/1.8/i686-linux-gnu/plruby.so'
language 'C';

create trusted language 'plruby'
handler plruby_call_handler
lancompiler 'PL/Ruby';

========================================================================

$ make
/home/dave/usr/src/plruby-0.3.9/src
make[1]: Entering directory `/home/dave/usr/src/plruby-0.3.9/src'
gcc -fPIC -g -O2 -fPIC -I/usr/include/pgsql/server -DPG_PL_VERSION=74
-DPLRUBY_CALL_HANDLER=plruby_call_handler -I.
-I/usr/lib/ruby/1.8/i686-linux-gnu -I/usr/lib/ruby/1.8/i686-linux-gnu
-I. -DHAVE_CATALOG_PG_PROC_H -DHAVE_RB_HASH_DELETE
-DHAVE_SERVER_UTILS_ARRAY_H -I/usr/include/pgsql -I/usr/kerberos/include
-c plruby.c
gcc -shared -L"/usr/lib" -L"/usr/local/pgsql/lib" -o plruby.so plruby.o
-lruby -lpq -lruby-static -ldl -lcrypt -lm -lc
make[1]: Leaving directory `/home/dave/usr/src/plruby-0.3.9/src'

$ grep LIBS src/Makefile
LOCAL_LIBS =
LIBS = $(LIBRUBYARG_SHARED) -lpq -lruby-static -ldl -lcrypt -lm -lc
CLEANLIBS = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $(DLLIB) $(OBJS)
$(LOCAL_LIBS) $(LIBS)

$ ldd src/plruby.so | grep ruby
libruby.so.1.8 => /usr/lib/libruby.so.1.8 (0x40025000)
$ du -b src/plruby.so
233472 src/plruby.so



If I create with -lruby-static (no -lruby):

$ ldd src/plruby.so | grep ruby
$ du -b src/plruby.so
1904640 src/plruby.so


If I use a static ruby (ruby configured with --disable-shared), I can't
get the resulting plruby.so to work (no ruby runtime linked).

Thanks,
 
N

nobu.nokada

Hi,

At Fri, 5 Mar 2004 20:57:49 +0900,
David Garamond wrote in [ruby-talk:94325]:
If I create with -lruby-static (no -lruby):

$ ldd src/plruby.so | grep ruby
$ du -b src/plruby.so
1904640 src/plruby.so


If I use a static ruby (ruby configured with --disable-shared), I can't
get the resulting plruby.so to work (no ruby runtime linked).

Don't link libruby-static.a to shared objects. It is for
executables without libruby.so, e.g. conftest, but not for
extension libraries.
 
T

ts

n> Don't link libruby-static.a to shared objects. It is for
n> executables without libruby.so, e.g. conftest, but not for
n> extension libraries.

plruby is not an extension library.

This is just that ruby was, in this case, compiled with --enable-shared


Guy Decoux
 
T

ts

D> What about adding these configure option, so plruby.so doesn't need
D> libruby.so at all? But sorry, I'm still not sure how to modify
D> extconf.rb to accomplish this. In the Makefile I just replace LIBS=
D> $(LIBRUBYARG_SHARED) with $(LIBRUBYARG_STATIC).

Well, this is a little more complex. Try it with

ruby extconf.rb --with-pgsql-include=/usr/include/pgsql \
--with-safe-level=0 --enable-geometry --enable-network

find . -name '*so'

I'm not really sure that you want $(LIBRUBYARG_STATIC) in this case


Guy Decoux
 
D

David Garamond

ts said:
D> What about adding these configure option, so plruby.so doesn't need
D> libruby.so at all? But sorry, I'm still not sure how to modify
D> extconf.rb to accomplish this. In the Makefile I just replace LIBS=
D> $(LIBRUBYARG_SHARED) with $(LIBRUBYARG_STATIC).

Well, this is a little more complex. Try it with

ruby extconf.rb --with-pgsql-include=/usr/include/pgsql \
--with-safe-level=0 --enable-geometry --enable-network

find . -name '*so'

Thanks, with --safe-level it works (though I don't understand why/what
it does).
I'm not really sure that you want $(LIBRUBYARG_STATIC) in this case

I wanted to statically link libruby.so because I intend to distribute
plruby.so to machines where there might not be Ruby installed (or Ruby
might installed in a different location). Though thinking about it
again, I realize I can always distribute libruby.so along... :)
 
T

ts

D> Thanks, with --safe-level it works (though I don't understand why/what
D> it does).

Except that it's a very *BAD* idea and don't repeat that this option exist
(it's voluntary *NOT* documented)

D> I wanted to statically link libruby.so because I intend to distribute
D> plruby.so to machines where there might not be Ruby installed (or Ruby
D> might installed in a different location). Though thinking about it
D> again, I realize I can always distribute libruby.so along... :)

If you compile it with --enable-... and $SAFE < 3 it will create

svg% find . -name '*so'
/src/conversions/geometry/plruby_geometry.so
/src/conversions/network/plruby_network.so
/src/conversions/basic/plruby_basic.so
/src/plruby.so
svg%


This means that plruby_{basic,geometry,network}.so will also be compiled
with the static version of libruby



Guy Decoux
 
T

ts

D> I wanted to statically link libruby.so because I intend to distribute
D> plruby.so to machines where there might not be Ruby installed (or Ruby
D> might installed in a different location). Though thinking about it
D> again, I realize I can always distribute libruby.so along... :)

Try this

svg% diff -ru plruby-0.3.9 plruby-0.4.0
diff -ru plruby-0.3.9/extconf.rb plruby-0.4.0/extconf.rb
--- plruby-0.3.9/extconf.rb 2004-02-29 15:28:55.000000000 +0100
+++ plruby-0.4.0/extconf.rb 2004-03-05 15:05:12.000000000 +0100
@@ -2,6 +2,7 @@
ARGV.collect! {|x|
x.sub(/\A--with-pgsql-prefix=/, "--with-pgsql-dir=")
x.sub(/\A--enable-conversion\z/, "--enable-basic")
+ x.sub(/\A--((?:en|dis)able)-shared\z/) { "--#$1-plruby-shared" }
}

orig_argv = ARGV.dup
@@ -216,6 +217,10 @@

begin
Dir.chdir("src")
+ if CONFIG["LIBRUBYARG"] == "$(LIBRUBYARG_SHARED)" &&
+ !enable_config("plruby-shared")
+ $LIBRUBYARG = ""
+ end
$objs = ["plruby.o"] unless $objs
create_makefile("plruby#{suffix}")
version.sub!(/\.\d/, '')
diff -ru plruby-0.3.9/src/conversions/basic/extconf.rb plruby-0.4.0/src/conversions/basic/extconf.rb
--- plruby-0.3.9/src/conversions/basic/extconf.rb 2004-02-28 17:06:05.000000000 +0100
+++ plruby-0.4.0/src/conversions/basic/extconf.rb 2004-03-05 15:00:21.000000000 +0100
@@ -1,3 +1,7 @@
require 'mkmf'

+if CONFIG["LIBRUBYARG"] == "$(LIBRUBYARG_SHARED)" &&
+ !enable_config("plruby-shared")
+ $LIBRUBYARG = ""
+end
create_makefile('plruby/plruby_basic')
diff -ru plruby-0.3.9/src/conversions/geometry/extconf.rb plruby-0.4.0/src/conversions/geometry/extconf.rb
--- plruby-0.3.9/src/conversions/geometry/extconf.rb 2004-02-28 17:07:21.000000000 +0100
+++ plruby-0.4.0/src/conversions/geometry/extconf.rb 2004-03-05 15:00:54.000000000 +0100
@@ -1,3 +1,7 @@
require 'mkmf'

+if CONFIG["LIBRUBYARG"] == "$(LIBRUBYARG_SHARED)" &&
+ !enable_config("plruby-shared")
+ $LIBRUBYARG = ""
+end
create_makefile('plruby/plruby_geometry')
diff -ru plruby-0.3.9/src/conversions/network/extconf.rb plruby-0.4.0/src/conversions/network/extconf.rb
--- plruby-0.3.9/src/conversions/network/extconf.rb 2004-02-28 17:07:07.000000000 +0100
+++ plruby-0.4.0/src/conversions/network/extconf.rb 2004-03-05 15:00:42.000000000 +0100
@@ -1,3 +1,7 @@
require 'mkmf'

+if CONFIG["LIBRUBYARG"] == "$(LIBRUBYARG_SHARED)" &&
+ !enable_config("plruby-shared")
+ $LIBRUBYARG = ""
+end
create_makefile('plruby/plruby_network')
svg%



and use --disable-shared





Guy Decoux
 
D

David Garamond

ts said:
D> I wanted to statically link libruby.so because I intend to distribute
D> plruby.so to machines where there might not be Ruby installed (or Ruby
D> might installed in a different location). Though thinking about it
D> again, I realize I can always distribute libruby.so along... :)

Try this

svg% diff -ru plruby-0.3.9 plruby-0.4.0 [snip]
and use --disable-shared

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top