Skip to content

Platform Tips (v0.1.0alpha)

fschopp edited this page Jul 13, 2011 · 2 revisions

RedHat/CentOS

The following note is not MADlib-specific, but nonetheless important to know.

  • For building against PostgreSQL, several "-devel" packages are needed:
    • openssl-devel

Solaris 10

Requirements:

  • gcc 3.4.3 (sic!, shipped with Solaris 10)
  • Oracle Solaris Studio 12.2 (freely available on the Oracle Web page) * This provides liblapack as part of libsunperf
  • Some patches (part of the script below): * By default, gcc on Solaris is setup to pass option "-z text" to the linker when "-shared" is present. From briefly glancing over the man pages I think this is wrong. We therefore override the specs. * There is a bug in the Sun/Oracle-provided math_c99.h, see http://gcc.gnu.org/PR19933, requiring a patch in our student.c

Solaris Pre-Installation Script

Instructions:

  1. Read and understand the following script. It is provided "as is", without any warranties.
  2. Run the following script from root directory of the MADlib sources, before running python setup.py install.
#!/usr/bin/env bash

# This script does:
# 1. Create a gcc in $HOME/bin that overrides the default gcc specs in
#    /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/specs
#    The overridden specs are stored in $HOME/etc/madlib_gcc_specs
# 2. Patch some source files to adapt to Solaris idiosyncrasies
#
# The assumption is that $HOME/bin is the first item in the $PATH variable
# (this should be set in .bashrc).

mkdir -p $HOME/bin
mkdir -p $HOME/etc

cat > $HOME/bin/gcc <<-EOF
	#!/bin/sh
	/usr/sfw/bin/gcc -m64 -specs=$HOME/etc/madlib_gcc_specs "\$@"
EOF
chmod 755 $HOME/bin/gcc

# For whatever reason, the gcc 3.4.3 spec file contains 
# %{shared:-G -dy %{!mimpure-text:-z text}} and thus calls the linker with
# option -z text if -shared is set. We do not want that because it generates
# linker errors:
# ld: fatal: relocations remain against allocatable but non-writable sections
cat > $HOME/etc/madlib_gcc_specs <<-"EOF"
	*link:
	%{h*} %{v:-V}    %{b} %{Wl,*:%*}    %{static:-dn -Bstatic}    %{shared:-G -dy %{!mimpure-text:-z textoff}}    %{symbolic:-Bsymbolic -G -dy -z text}    %(link_arch)    %{Qy:} %{!Qn:-Qy}
EOF

# We use GNU patch instead of the Solaris one.
# 1. The first patch is to correct the issue outined here:
#    http://gcc.gnu.org/PR19933
# 2. The second patch changes -lapack to -lsunperf, which contains LAPACK.
#    -Wl,-R tells the linker to include the full path to the library
gpatch -p0 <<-"EOF"
	--- methods/regress/src/pg_gp/student.c	2011-01-26 12:36:39.000000000 -0800
	+++ methods/regress/src/pg_gp/student.solaris.c	2011-01-30 00:52:24.000000000 -0800
	@@ -66,6 +66,12 @@
	 #include "student.h"
	 
	 #include <math.h>
	+// Fixing problem with Solaris 10 header file
	+// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19933
	+#if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__)
	+#undef  NAN
	+#define NAN             (__builtin_nan(""))
	+#endif
	 
	 
	 /* Prototypes of internal functions */
	--- methods/regress/src/pg_gp/Makefile	2011-01-26 15:53:20.000000000 -0800
	+++ methods/regress/src/pg_gp/Makefile.solaris	2011-01-30 00:59:22.000000000 -0800
	@@ -22,7 +22,7 @@
	 # COPT += -D_REENTRANT -std=gnu99
	 
	 # We want to link to the LAPACK library.
	-SHLIB_LINK += -llapack
	+SHLIB_LINK += -Wl,-R'/opt/solstudio12.2/lib/amd64' -L/opt/solstudio12.2/lib/amd64 -lsunperf
	 
	 PG_CONFIG = pg_config 
	 PGXS := $(shell $(PG_CONFIG) --pgxs) 
EOF