From prye at shiraz.apana.org.au  Wed Jul 23 13:08:02 2003
From: prye at shiraz.apana.org.au (Peter Rye)
Date: Wed Jul 23 14:08:04 2003
Subject: [Rd] OpenBSD 3.[23] and R-1.7.1
In-Reply-To: <Pine.LNX.4.44.0307191844510.1901-100000@gannet.stats>
References: <Pine.LNX.4.44.0307191844510.1901-100000@gannet.stats>
Message-ID: <8765lt5wnm.fsf@riesling.grape.apana.org.au>

I have been able to compile R on OpenBSD 3.[23] for the i386 platform
(still a.out at the moment).

There are problems with the naming convention for OpenBSD and the shared
libraries which prevents the build completing. I have included patches for
your consideration...I'm not an expert programmer and there may well be
better ways around the problem. I don't *think* my patches break the
configuration for other platforms.

I've also noticed a problem in building the .dvi manuals - I think it's a
texi2dvi problem - see patch below. Anyone else seen this?

Unfortunately I understand that R has another problem when being built on
an OpenBSD ELF platform. I have been unable to build it on the alpha (which
is an ELF platform), and I understand it does not build on OpenBSD-current
for i386, which will become the newest stable version in the next few
months. The OpenBSD-current for i386 will also be ELF.  On the ELF platforms,
the build dies with the following error:

dumping R code in package 'methods'
Error in .Call("R_initialize_methods_metadata", table, PACKAGE = "methods") : 
        .Call function name not in load table
Execution halted
*** Error code 1

I believe this also happens on sparc64 OpenBSD. I *think* it's related to the
ELF format.

I have tried ensuring that the main link flags include "-Wl,-E" or
"-Wl,-export-dynamic", turning off optimisation, building with
"--enable-R-shlib", and ensuring that "-fPIC" is passed to the final link
stage in addition to "-shared".
Unfortunately none of the above seem to resolve the error. Does anyone have
any other suggestions, or suggestions of how to debug the problem further?
I'd love to have R running reliably on OpenBSD platforms other than i386.

Compiler is gcc version 2.95.3 20010125 (prerelease).


My patches for OpenBSD i386 follow:

--- configure.orig	Mon Jun 16 19:33:02 2003
+++ configure	Sat Jul 19 17:32:27 2003
@@ -469,7 +469,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE build build_cpu build_vendor build_os host host_cpu host_vendor host_os R_PLATFORM R_OSTYPE config_opts WANT_R_SHLIB_TRUE WANT_R_SHLIB_FALSE LIBR MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE USE_LIBTOOL_TRUE USE_LIBTOOL_FALSE R_PRINTCMD R_PAPERSIZE R_BATCHSAVE MAIN_CFLAGS SHLIB_CFLAGS MAIN_FFLAGS SHLIB_FFLAGS MAIN_LD MAIN_LDFLAGS CPICFLAGS FPICFLAGS SHLIB_LD SHLIB_LDFLAGS CXXPICFLAGS SHLIB_CXXLD SHLIB_CXXLDFLAGS TCLTK_LIBS TCLTK_CPPFLAGS MAKE F2C R_BROWSER GETWD BUILDDIR_IS_SRCDIR AWK EGREP LN_S RANLIB ac_ct_RANLIB YACC AR AR!
FLAGS JAVAC PAGER PERL FALSE NO_PERL5 TAR DVIPS TEX LATEX MAKEINDEX PDFTEX PDFLATEX MAKEINFO_CMD INSTALL_INFO R_RD4DVI R_RD4PDF R_UNZIPCMD R_ZIPCMD CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT ECHO STRIP ac_ct_STRIP CPP LIBTOOL LIBTOOL_DEPS R_PDFVIEWER F77 FFLAGS ac_ct_F77 CXX CXXFLAGS ac_ct_CXX CXXCPP shlibpath_var LIBM FLIBS HAVE_DOUBLE_COMPLEX COMPILE_DOUBLE_COMPLEX_TRUE COMPILE_DOUBLE_COMPLEX_FALSE SHLIB_CXXFLAGS F2CFLAGS R_XTRA_CFLAGS R_XTRA_CPPFLAGS R_XTRA_CXXFLAGS R_XTRA_FFLAGS R_XTRA_LIBS XMKMF SHLIB_LIBADD SHLIB_EXT USE_EXPORTFILES_TRUE USE_EXPORTFILES_FALSE DYLIB_EXT LIBR_LDFLAGS RLAPACK_LDFLAGS LAPACK_LDFLAGS ALLOCA RMATH_HAVE_EXPM1 RMATH_HAVE_LOG1P LIBOBJS BLAS_LIBS USE_EXTERNAL_BLAS_TRUE USE_EXTERNAL_BLAS_FALSE LAPACK_LIBS USE_EXTERNAL_LAPACK_TRUE USE_EXTERNAL_LAPACK_FALSE R_GUIS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GNOME_LIBS GNOMEUI_LIBS GNOMEGNORBA_LIBS GTKXMHTML_LIBS ZVT_LIBS GNOME_LIBDIR GNOME_INCLUDEDIR GNOME_CONFIG ORBIT_CONFIG ORBIT_IDL HAVE_ORBI!
T_TRUE HAVE_ORBIT_FALSE ORBIT_CFLAGS ORBIT_LIBS HAVE_GNORBA_T!
 RUE HAVE
_GNORBA_FALSE GNORBA_CFLAGS GNORBA_LIBS GNOME_APPLETS_LIBS GNOME_CAPPLET_LIBS LIBGLADE_CONFIG LIBGLADE_CFLAGS LIBGLADE_LIBS HAVE_GNOME GNOME_IF_FILES TCL_CONFIG TK_CONFIG use_tcltk BITMAP_LIBS BUILD_XDR_TRUE BUILD_XDR_FALSE BUILD_ZLIB_TRUE BUILD_ZLIB_FALSE USE_MMAP_ZLIB_TRUE USE_MMAP_ZLIB_FALSE BUILD_BZLIB_TRUE BUILD_BZLIB_FALSE BUILD_PCRE_TRUE BUILD_PCRE_FALSE R_PROFILING PAPERCONF R_LD_LIBRARY_PATH USE_RECOMMENDED_PACKAGES_TRUE USE_RECOMMENDED_PACKAGES_FALSE LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE build build_cpu build_vendor build_os host host_cpu host_vendor host_os R_PLATFORM R_OSTYPE config_opts WANT_R_SHLIB_TRUE WANT_R_SHLIB_FALSE LIBR MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE USE_LIBTOOL_TRUE USE_LIBTOOL_FALSE R_PRINTCMD R_PAPERSIZE R_BATCHSAVE MAIN_CFLAGS SHLIB_CFLAGS MAIN_FFLAGS SHLIB_FFLAGS MAIN_LD MAIN_LDFLAGS CPICFLAGS FPICFLAGS SHLIB_LD SHLIB_LDFLAGS CXXPICFLAGS SHLIB_CXXLD SHLIB_CXXLDFLAGS TCLTK_LIBS TCLTK_CPPFLAGS MAKE F2C R_BROWSER GETWD BUILDDIR_IS_SRCDIR AWK EGREP LN_S RANLIB ac_ct_RANLIB YACC AR AR!
FLAGS JAVAC PAGER PERL FALSE NO_PERL5 TAR DVIPS TEX LATEX MAKEINDEX PDFTEX PDFLATEX MAKEINFO_CMD INSTALL_INFO R_RD4DVI R_RD4PDF R_UNZIPCMD R_ZIPCMD CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT ECHO STRIP ac_ct_STRIP CPP LIBTOOL LIBTOOL_DEPS R_PDFVIEWER F77 FFLAGS ac_ct_F77 CXX CXXFLAGS ac_ct_CXX CXXCPP shlibpath_var LIBM FLIBS HAVE_DOUBLE_COMPLEX COMPILE_DOUBLE_COMPLEX_TRUE COMPILE_DOUBLE_COMPLEX_FALSE SHLIB_CXXFLAGS F2CFLAGS R_XTRA_CFLAGS R_XTRA_CPPFLAGS R_XTRA_CXXFLAGS R_XTRA_FFLAGS R_XTRA_LIBS XMKMF SHLIB_LIBADD SHLIB_EXT MODULELIB_EXT USE_EXPORTFILES_TRUE USE_EXPORTFILES_FALSE DYLIB_EXT LIBR_LDFLAGS RLAPACK_LDFLAGS LAPACK_LDFLAGS ALLOCA RMATH_HAVE_EXPM1 RMATH_HAVE_LOG1P LIBOBJS BLAS_LIBS USE_EXTERNAL_BLAS_TRUE USE_EXTERNAL_BLAS_FALSE LAPACK_LIBS USE_EXTERNAL_LAPACK_TRUE USE_EXTERNAL_LAPACK_FALSE R_GUIS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GNOME_LIBS GNOMEUI_LIBS GNOMEGNORBA_LIBS GTKXMHTML_LIBS ZVT_LIBS GNOME_LIBDIR GNOME_INCLUDEDIR GNOME_CONFIG ORBIT_CONFIG ORBIT!
_IDL HAVE_ORBIT_TRUE HAVE_ORBIT_FALSE ORBIT_CFLAGS ORBIT_LIBS!
  HAVE_GN
ORBA_TRUE HAVE_GNORBA_FALSE GNORBA_CFLAGS GNORBA_LIBS GNOME_APPLETS_LIBS GNOME_CAPPLET_LIBS LIBGLADE_CONFIG LIBGLADE_CFLAGS LIBGLADE_LIBS HAVE_GNOME GNOME_IF_FILES TCL_CONFIG TK_CONFIG use_tcltk BITMAP_LIBS BUILD_XDR_TRUE BUILD_XDR_FALSE BUILD_ZLIB_TRUE BUILD_ZLIB_FALSE USE_MMAP_ZLIB_TRUE USE_MMAP_ZLIB_FALSE BUILD_BZLIB_TRUE BUILD_BZLIB_FALSE BUILD_PCRE_TRUE BUILD_PCRE_FALSE R_PROFILING PAPERCONF R_LD_LIBRARY_PATH USE_RECOMMENDED_PACKAGES_TRUE USE_RECOMMENDED_PACKAGES_FALSE LTLIBOBJS'
 ac_subst_files='r_cc_rules_frag r_f77_rules_frag r_cxx_rules_frag'
 
 # Initialize some variables set by options.
@@ -17689,6 +17689,7 @@
 shlib_ld="${CC}"
 shlib_cxxld="${CXX}"
 SHLIB_EXT=".so"
+MODULELIB_EXT="${SHLIB_EXT}"
 SHLIB_LIBADD=
 use_exportfiles=no
 
@@ -17838,6 +17839,7 @@
     ;;
   hpux*)
     SHLIB_EXT=".sl"
+    MODULELIB_EXT="${SHLIB_EXT}"
     case "${CC}" in
       cc|c89)
         cpicflags="+Z"
@@ -17881,6 +17883,7 @@
     ;;
   mingw*)
     SHLIB_EXT=".dll"
+    MODULELIB_EXT="${SHLIB_EXT}"
     cpicflags=
     cxxpicflags=
     fpicflags=
@@ -17893,6 +17896,11 @@
       shlib_ldflags="-Bshareable"
     fi
     ;;
+  openbsd3*)
+    PACKAGE_VERSION_MAJOR=`echo ${PACKAGE_VERSION} | sed -e "s/\.//" -e "s/\..*$//"`
+    PACKAGE_VERSION_MINOR=`echo ${PACKAGE_VERSION} | sed -e "s/.*\.\([^.][^.]*$\)/\1/"`
+    MODULELIB_EXT=".so.${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}"
+    ;;
   osf*)
     cpicflags=
     cxxpicflags=
@@ -18082,6 +18090,9 @@
       LAPACK_LDFLAGS="+s"
     fi
     ;;
+  openbsd3*)
+    DYLIB_EXT="${MODULELIB_EXT}"
+    ;;
 esac
 
 
@@ -26463,6 +26474,7 @@
 s,@XMKMF@,$XMKMF,;t t
 s,@SHLIB_LIBADD@,$SHLIB_LIBADD,;t t
 s,@SHLIB_EXT@,$SHLIB_EXT,;t t
+s,@MODULELIB_EXT@,$MODULELIB_EXT,;t t
 s,@USE_EXPORTFILES_TRUE@,$USE_EXPORTFILES_TRUE,;t t
 s,@USE_EXPORTFILES_FALSE@,$USE_EXPORTFILES_FALSE,;t t
 s,@DYLIB_EXT@,$DYLIB_EXT,;t t



--- Makeconf.in.orig    Wed Jul 23 22:03:55 2003
+++ Makeconf.in Wed Jul 23 22:04:33 2003
@@ -54,6 +54,7 @@
 @USE_LIBTOOL_TRUE@MAIN_LINK = $(LIBTOOL) --mode=link $(MAIN_LD) $(MAIN_LDFLAGS) $(LDFLAGS)
 MAKEINDEX = @MAKEINDEX@
 MKINSTALLDIRS = $(top_srcdir)/tools/mkinstalldirs
+MODULELIB_EXT = @MODULELIB_EXT@
 PERL = @PERL@
 R_GUIS = @R_GUIS@
 R_OSTYPE = @R_OSTYPE@



--- doc/manual/Makefile.in.orig	Fri Sep  6 07:44:00 2002
+++ doc/manual/Makefile.in	Thu Dec 12 17:14:51 2002
@@ -34,7 +34,8 @@
 MAKEINFO_TEXT_OPTS = --number-sections --fill-column=76 --no-split --no-headers
 TEXI2HTML = $(MAKEINFO) $(MAKEINFO_HTML_OPTS)
 TEXI2TEXT = $(MAKEINFO) $(MAKEINFO_TEXT_OPTS)
-TEXI2DVI = $(top_builddir)/bin/texi2dvi --texinfo="@set UseExternalXrefs"
+# Looks like a bug in texi2dvi to me - needs a space after the --texinfo argument 
+TEXI2DVI = $(top_builddir)/bin/texi2dvi --texinfo="@set UseExternalXrefs "
 TEXI2PDF = $(TEXI2DVI) --pdf
 PDFLATEX = @PDFLATEX@
 PDFTEX = @PDFTEX@


[Rd] OpenBSD 3.[23] and R-1.7.1
Peter Rye