[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Add native ruby binding to Subversion distribution

From: Kevin Pilch-Bisson <kevin_at_pilch-bisson.net>
Date: 2001-10-30 03:21:39 CET

On Mon, Oct 29, 2001 at 04:41:27PM -0600, Karl Fogel wrote:
> Thanks, Yoshiki!
>
> Given past experience and the complexity of our configuration system,
> I think it's good practice for any non-trivial configuration change to
> be reviewed by another pair of eyes. Maybe -- Kevin Pilch-Bisson?
> Got time to look over this? (I'd do it myself, but I'm a sieve when
> it comes to spotting config issues :-( ...)
>
I'd be happy to look it over. I'll try to get to it tomorrow, but I
can't promise anything. :(
>
> -K
>
> Yoshiki Hayashi <yoshiki@xemacs.org> writes:
> > Here's the new version of build system patch. The basic
> > idea is the same as my previous patch so the explanation is
> > included mostly as is. Please read bindings/ruby/native as
> > bindings/ruby.
> >
> > I asked about LDFLAG kludge to Greg Stein on IRC but today
> > IRC server is flaky and couldn't ask the question I wanted
> > to ask. This patch adds -lpthread to LDFLAG if APR is
> > compiled with pthread. The problem is, if you load Svn.so
> > linked without -lpthread option, Ruby interpreter cannot
> > find libpthread and stop execution saying missing symbol or
> > something.
> >
> > Greg said -lpthread should be picked up by APR and I thought
> > so but it is not. The problem is the way APR checks CFLAGS
> > to gcc and LDFLAGS. First, APR tries to add one of
> > following CFLAGS will be necessary to build pthread support.
> > -kthread -pthread -pthreads -mthreads -Kthread -threads -mt
> >
> > Second, it tries to add -lpthread -lpthreads -lc_r to
> > LDFLAGS if first step failed.
> >
> > Here's how it works on my system (Debian unstable):
> >
> > 1. APR picks up -pthread as CFLAGS. It allows you to
> > compile and link pthread programs.
> >
> > 2. If I enable second check regardless of the result of
> > first check, -lpthread will not be added to LDFLAGS
> > because -pthread CFLAGS is all you need.
> >
> > 3. If I reverse the order of CFLAGS and LDFLAGS checking,
> > APR correctly picks up -lpthread and Ruby binding are
> > happy without LDFLAGS kludge.
> >
> > It looks like I should post patch to dev@apr to do #3. I
> > don't know if it will bring any portability problem but APR
> > people can probably figure it out. Anyway, I must go now.
> > The time of the last train is approaching. ;-)
> >
> > Yoshiki Hayashi <yoshiki@xemacs.org> writes:
> >
> > > Here's a patch to build native Ruby binding inside
> > > Subversion distribution. All you have to do is:
> >
> > > 2. Apply following patch.
> > >
> > > 3. Add attached rb-config.rb and svn-ruby.m4 files to
> > > ac-helpers directory.
> > >
> > > The default is not to build Ruby binding so you need to add
> > > --enable-ruby-binding to configure. The reason is I'm not
> > > sure it can be built on every system. I can only test it on
> > > Debian unstable. However, it would be very nice if it can
> > > be added to Subversion distribution and people can test it
> > > so that I can shake out some bugs. I expect the default to
> > > be --enable-ruby-binding in the future.
> > >
> > > It installs Svn.la to
> > > /usr/local/lib/site_ruby/1.6/i386-linux on my machine.
> > > Probably Debian package or other package on FHS compliant
> > > system doesn't like it but I decided to ignore it at this
> > > point.
> > >
> > > What this patch does is to add dso type to gen-make.py and
> > > build.conf. The main purpose is to add new link rule and to
> > > be able to add more targets which creates Svn.la. The name
> > > of dso rule consists of language name and .la name
> > > concatenated with underscore like Ruby_Svn. This allows you
> > > to add Python_Svn to create another Svn.la at the later time.
> > >
> > > There's one problem with this patch, though. It adds hack
> > > in SVN_FIND_RUBY to add -lpthread to LDFLAGS if -pthread is
> > > present in CFLAGS. You can link without -lpthread but if
> > > you try to load the Svn.so from Ruby interpreter, it barfs
> > > on error that it cannot find libpthread.so. If
> > > ruby/native/Svn.so is linked with -lpthread, it will be
> > > loaded successfully. I don't know the correct answer to
> > > this problem. I thought APR should add -lpthread but the
> > > magical undocumented -pthread flag of GCC allows you to
> > > compile and link C programs without problem. The linking
> > > problem only occurs when a library linked with thread
> > > enabled APR is dlopened by the program not linked with
> > > pthread. Any ideas?
> > >
> > > I appreciate any feedback.
> > >
> > > ChangeLog and patch are attached below.
> > >
> > > Makefile.in
> > >
> > > (RUBY_INCLUDES, ruby_moddir): New var.
> > > (LDFLAGS): Now the value is determined by configure.
> > > (COMPILE_RUBY_MOD, MODULE): New var.
> > > (INSTAL_RUBY_MOD, RUBY): New var.
> > >
> > > gen-make.py
> > >
> > > * Use $(MODULE) to link when target type is dso.
> > > * Add new 'ruby-mod' custom rule to compile Ruby module.
> > > * Add new target type dso. It is similar to lib but has
> > > different target name convention and link command.
> > >
> > > build.conf
> > >
> > > * New target Ruby_Svn.
> > >
> > > configure.in
> > >
> > > * Include new helper macro from svn-ruby.m4
> > > * Call AC_LIBTOOL_DLOPEN to check whether the system
> > > supports dlopen.
> > > * Call SVN_FIND_RUBY to determine if it can/should build
> > > Ruby binding.
> > > * (BUILD_RULES, INSTALL_RULES): Add Ruby rule when
> > > Berkeley DB is present. Fs binding depends on it.
> > >
> > > svn-ruby.m4
> > >
> > > New file.
> > >
> > > (SVN_FIND_RUBY): New function. If --enable-ruby-binding is
> > > given and correct inperter is found, add rules to build
> > > and install Ruby binding.
> > >
> > > rb-config.m4
> > >
> > > New file.
> > >
> > > Return the location of header file or install directory
> > > depending on the command line argument.
> >
> > Index: ./Makefile.in
> > ===================================================================
> > --- ./.svn/text-base/Makefile.in Mon Oct 29 20:13:52 2001
> > +++ ./Makefile.in Mon Oct 29 21:08:56 2001
> > @@ -53,18 +53,23 @@
> > APACHE_INCLUDES = @APACHE_INCLUDES@
> > APACHE_TARGET = @APACHE_TARGET@
> >
> > +RUBY_INCLUDES = @RUBY_INCLUDES@
> > +ruby_moddir = @ruby_moddir@
> > +
> > MKDIR = @MKDIR@
> >
> > CFLAGS = @CFLAGS@
> > CPPFLAGS = @CPPFLAGS@
> > -LDFLAGS =
> > +LDFLAGS = @LDFLAGS@
> >
> > COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES)
> > LT_COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $<
> >
> > COMPILE_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(APACHE_INCLUDES) $(INCLUDES) -o $@ -c $<
> > +COMPILE_RUBY_MOD = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(RUBY_INCLUDES) $(INCLUDES) -o $@ -c $<
> >
> > LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(LT_LDFLAGS) $(COMPILE) $(LDFLAGS) -rpath $(libdir)
> > +MODULE = $(LIBTOOL) $(LTFLAGS) $(LT_LDFLAGS) $(COMPILE) -module -avoid-version $(LDFLAGS) -rpath $(libdir)
> >
> > INSTALL = @INSTALL@
> > INSTALL_LIB = $(LIBTOOL) --mode=install $(INSTALL)
> > @@ -74,8 +79,10 @@
> > INSTALL_INCLUDE = $(INSTALL) -m 644
> > INSTALL_MOD_SHARED = @APXS@ -i -a
> > INSTALL_MOD_STATIC = $(INSTALL) -m 644
> > +INSTALL_RUBY_MOD = $(INSTALL_LIB)
> >
> > PYTHON = @PYTHON@
> > +RUBY = @RUBY@
> >
> > all: external-all local-all
> > clean: external-clgan local-clean
> > Index: ./gen-make.py
> > ==================================================================
> > --- ./.svn/text-base/gen-make.py Mon Oct 8 17:55:01 2001
> > +++ ./gen-make.py Mon Oct 29 21:09:19 2001
> > @@ -115,6 +115,11 @@
> > # something we don't know, so just include it directly
> > libs.append(lib)
> >
> > + if parser.get(target, 'type') == 'dso':
> > + link = '$(MODULE)'
> > + else:
> > + link = '$(LINK)'
> > +
> > targ_varname = string.replace(target, '-', '_')
> > ldflags = parser.get(target, 'link-flags')
> > add_deps = parser.get(target, 'add-deps')
> > @@ -122,11 +127,11 @@
> > ofile.write('%s_DEPS = %s %s\n'
> > '%s_OBJECTS = %s\n'
> > '%s: $(%s_DEPS)\n'
> > - '\tcd %s && $(LINK) -o %s %s $(%s_OBJECTS) %s $(LIBS)\n\n'
> > + '\tcd %s && %s -o %s %s $(%s_OBJECTS) %s $(LIBS)\n\n'
> > % (targ_varname, string.join(objects + deps), add_deps,
> > targ_varname, objnames,
> > tpath, targ_varname,
> > - path, tfile, ldflags, targ_varname, string.join(libs)))
> > + path, link, tfile, ldflags, targ_varname, string.join(libs)))
> >
> > custom = parser.get(target, 'custom')
> > if custom == 'apache-mod':
> > @@ -137,6 +142,14 @@
> > ofile.write('%s%s: %s\n\t$(COMPILE_APACHE_MOD)\n'
> > % (src[:-2], objext, src))
> > ofile.write('\n')
> > + elif custom == 'ruby-mod':
> > + # special build, needing Ruby includes
> > + ofile.write('# build these special -- use RUBY_INCLUDES\n')
> > + for src in sources:
> > + if src[-2:] == '.c':
> > + ofile.write('%s%s: %s\n\t$(COMPILE_RUBY_MOD)\n'
> > + % (src[:-2], objext, src))
> > + ofile.write('\n')
> >
> > for g_name, g_targets in install.items():
> > target_names = [ ]
> > @@ -303,6 +316,10 @@
> > install = 'lib'
> > elif type == 'doc':
> > pass
> > + elif type == 'dso':
> > + ignore, tname = string.split(name, '_')
> > + tfile = tname + '.la'
> > + self.objext = '.lo'
> > else:
> > raise GenMakeError('ERROR: unknown build type: ' + type)
> >
> > @@ -325,6 +342,7 @@
> > _default_sources = {
> > 'lib' : '*.c',
> > 'exe' : '*.c',
> > + 'dso' : '*.c',
> > 'doc' : '*.texi',
> > }
> >
> > Index: ./build.conf
> > ===================================================================
> > --- ./.svn/text-base/build.conf Mon Oct 29 20:13:52 2001
> > +++ ./build.conf Mon Oct 29 21:10:56 2001
> > @@ -145,6 +145,14 @@
> > # there are some .c files included by others, so *.c isn't appropriate
> > sources = hashtable.c xmlparse.c xmlrole.c xmltok.c
> >
> > +[Ruby_Svn]
> > +type = dso
> > +path = subversion/bindings/ruby
> > +libs = libsvn_client libsvn_wc libsvn_ra libsvn_repos libsvn_fs
> > + libsvn_delta libsvn_subr $(SVN_APR_LIBS)
> > +custom = ruby-mod
> > +install = ruby-mod
> > +
> > # ----------------------------------------------------------------------------
> > #
> > # TESTING TARGETS
> > Index: ./configure.in
> > ===================================================================
> > --- ./.svn/text-base/configure.in Mon Oct 29 20:14:01 2001
> > +++ ./configure.in Mon Oct 29 21:11:57 2001
> > @@ -31,6 +31,7 @@
> > sinclude(ac-helpers/svn-macros.m4)
> > sinclude(ac-helpers/neon.m4)
> > sinclude(ac-helpers/apr.m4)
> > +sinclude(ac-helpers/svn-ruby.m4)
> >
> > dnl Grab the libtool macros
> > sinclude(ac-helpers/libtool.m4)
> > @@ -95,6 +96,7 @@
> >
> > dnl Check for libtool -- we'll definitely need it for all our shared libs!
> > echo "configuring libtool now"
> > +AC_LIBTOOL_DLOPEN
> > AC_PROG_LIBTOOL
> >
> > NEON_WANTED=0.17.2
> > @@ -103,6 +105,12 @@
> > dnl find Apache
> > SVN_FIND_APACHE
> >
> > +dnl find Ruby
> > +
> > +SVN_FIND_RUBY
> > +
> > +AC_SUBST(LDFLAGS)
> > +
> > dnl Check for libraries --------------------
> >
> > dnl AC_CHECK_LIB() calls go here, if we ever need any
> > @@ -119,8 +127,8 @@
> > INSTALL_RULES="install-lib install-bin install-include"
> > BUILD_RULES="lib bin test"
> > if test "$svn_lib_berkeley_db" = "yes"; then
> > - BUILD_RULES="lib fs-lib bin fs-bin $BUILD_APACHE_RULE test fs-test"
> > - INSTALL_RULES="install-lib install-fs-lib install-bin install-fs-bin $INSTALL_APACHE_RULE install-include"
> > + BUILD_RULES="lib fs-lib bin fs-bin $BUILD_APACHE_RULE $BUILD_RUBY_RULE test fs-test"
> > + INSTALL_RULES="install-lib install-fs-lib install-bin install-fs-bin $INSTALL_APACHE_RULE $INSTALL_RUBY_RULE install-include"
> > FS_TEST_DEPS="\$(FS_TEST_DEPS)"
> > FS_TEST_PROGRAMS="\$(FS_TEST_PROGRAMS)"
> > fi
> > AC_DEFUN(SVN_FIND_RUBY,[
> >
> > AC_ARG_ENABLE(ruby-binding,
> > [ --enable-ruby-binding Turn on native Ruby binding support],
> > [
> > if test "$enableval" = "yes"; then
> > ruby_binding="yes"
> > fi
> > ])
> >
> > AC_PATH_PROG(RUBY, ruby)
> > if test "$ruby_binding" = "yes"; then
> > if test "$RUBY" = ""; then
> > AC_MSG_ERROR(Unable to find ruby interpreter)
> > fi
> > if test "$enable_shared" = "no"; then
> > AC_MSG_ERROR(Ruby binding requires shared library)
> > fi
> > AC_MSG_CHECKING(for Ruby header)
> > ruby_header="`$RUBY ${abs_srcdir}/ac-helpers/rb-config.rb include`"
> > if test "$ruby_header" = ""; then
> > AC_MSG_ERROR([no - Unable to locate ruby.h])
> > else
> > AC_MSG_RESULT($ruby_header)
> > RUBY_INCLUDES="-I$ruby_header"
> > /* ### Kludge to avoid linking error with pthread. */
> > case "$EXTRA_CFLAGS" in
> > *-pthread*)
> > LDFLAGS="$LDFLAGS -lpthread"
> > ;;
> > esac
> > BUILD_RUBY_RULE=ruby-mod
> > INSTALL_RUBY_RULE=install-ruby-mod
> > ruby_moddir="`$RUBY ${abs_srcdir}/ac-helpers/rb-config.rb site-install`"
> > fi
> > fi
> > AC_SUBST(RUBY_INCLUDES)
> > AC_SUBST(BUILD_RUBY_RULE)
> > AC_SUBST(INSTALL_RUBY_RULE)
> > AC_SUBST(ruby_moddir)
> >
> > ])
> > begin
> > require 'rbconfig'
> > rescue LoadError
> > exit 1
> > end
> >
> > command = ARGV.shift
> >
> > if command == 'include' then
> > if File.exists?(File.join(Config::CONFIG['archdir'], 'ruby.h')) then
> > print Config::CONFIG['archdir']
> > end
> > elsif command == 'site-install' then
> > print Config::CONFIG['sitearchdir']
> > end
> >
> >
> > --
> > Yoshiki Hayashi
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> > For additional commands, e-mail: dev-help@subversion.tigris.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Pilch-Bisson                    http://www.pilch-bisson.net
     "Historically speaking, the presences of wheels in Unix
     has never precluded their reinvention." - Larry Wall
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • application/pgp-signature attachment: stored
Received on Sat Oct 21 14:36:46 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.