Differences between revisions 1 and 10 (spanning 9 versions)
Revision 1 as of 2009-06-27 07:26:40
Size: 27937
Editor: PeterJeremy
Comment: Create as copy of Sage 3.4 on FreeBSD page
Revision 10 as of 2009-08-07 11:16:50
Size: 28128
Editor: PeterJeremy
Comment: Continue documenting the necessary patches.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Sage FreeBSD 7.x/amd64 and 8-current/amd64 build notes for Sage 3.4 = = Sage FreeBSD 7.x and 8.x build notes for Sage 4.1 =

Note that this page is under construction and currently incomplete. In particular, it still includes references to sage-3.4 in areas that have not been converted to sage-4.1.
Line 11: Line 13:
 * Install ports/shells/bash or ports/shells/bash3 (I used 3.2.48)  * Install ports/shells/bash or ports/shells/bash3 (I used 4.0.24)
Line 13: Line 15:
 * Install ports/lang/gcc43 - FreeBSD no longer ships with a Fortran compiler by default.  I tried using g95 but ran into problems.  * Install ports/lang/gcc43 - FreeBSD no longer ships with a Fortran compiler by default.
Line 15: Line 17:
 * Install ports/converters/libiconv - This may be optional but is definitely used if found
 
 * Install ports/converters/libiconv
Line 24: Line 26:
 * Unpack sage-3.4.tar
 * `cd sage-3.4`
 * Unpack [[attachment:sage-3.4.tgz]]. This installs the symlinks listed below as well as various patches. Note that the patches in spkg/patches.save are not currently applied.
 * Unpack sage-4.1.tar
 * `cd sage-4.1`
 * `mkdir -p local/bin spkg/patches`
 * Create symlinks to mask name differences.
  . `ln -s /usr/local/bin/gmake local/bin/make`
  . `ln -s /usr/local/bin/bash local/bin/sh`
  . `ln -s /usr/local/bin/gcc43 local/bin/gcc`
  . `ln -s /usr/local/bin/g++43 local/bin/g++`
  . `ln -s /usr/local/bin/gfortran43 local/bin/gfortran`
 * Copy the patches listed below into `spkg/patches`
Line 28: Line 37:
  . `SAGE_FORTRAN_LIB=/usr/local/lib/gcc-4.3.4/libgfortran.so gmake`   . `SAGE_FORTRAN=/usr/local/bin/gfortran43 SAGE_FORTRAN_LIB=/usr/local/lib/gcc43/libgfortran.so gmake`

{{{#!wiki comment
Line 45: Line 55:
}}}
Line 47: Line 57:
{{{#!wiki comment
Line 75: Line 85:
}}}
}#}}
}}}

{{{#!wiki comment
Line 96: Line 108:
}#}}
Line 100: Line 113:
A number of the following patches change `make` to `${MAKE}` and/or use `gmake` instead of `make` on FreeBSD. The former is the recommended way to recursively invoke make to ensure that the subordinate make is the same as the parent make (and also ensures that the two make instances will communicate on things like '-jX').  The latter fixes date from early versions of this patchset before I decided to symlink GNU make as local/bin/make and should no longer be necessary (though I haven't verified this). A number of the following patches change `make` to `${MAKE}`. This the recommended way to recursively invoke make to ensure that the subordinate make is the same as the parent make (and also ensures that the two make instances will communicate on things like '-jX').
Line 106: Line 119:
 * The patch to standard/deps ensures that bash is used.

=== atlas-3.8.3.p0 ===
/* * The patch to standard/deps ensures that bash is used. */

=== atlas-3.8.3.p5 ===
Line 110: Line 123:
{{{#!wiki comment
Line 113: Line 127:
}}}
Line 114: Line 129:
 * Building the `libclapack.so` should result in a `libclapack.so` being created. This appears to be a copy-and-paste error in atlas and has been reported as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728935&group_id=23725
 * Treat shared libraries the same as Linux - otherwise they aren't correctly detected by (eg) numpy. (sage-specific)
 * Building the `libclapack.so` should result in a `libclapack.so` being created. This appears to be a copy-and-paste error in atlas and has been reported as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728935&group_id=23725 (Note that this is not relevant to sage as libclapack is not built or used).
 * numpy on FreeBSD expects atlas to build different and (according to the FreeBSD numpy port, static) threaded libraries: libatlas_r instead of libatlas and libalapack_r instead of liblapack. libatlas_r is built as part of the threaded version of atlas. libalapack_r is a FreeBSD special which explicitly combines all of liblapack from the atlas lapack build with the threaded atlas version of liblapack.
Line 120: Line 135:
  libraries f77blas,cblas,atlas_r not found in /home/pjeremy/sage-3.4/local/lib   libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
Line 123: Line 138:
/home/pjeremy/sage-3.4/spkg/build/numpy-1.2.0.p0/src/numpy/distutils/system_info.py:1340: UserWarning:  /usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1383: UserWarning:
Line 131: Line 146:
  libraries f77blas,cblas,atlas_r not found in /home/pjeremy/sage-3.4/local/lib
  libraries lapack_atlas not found in /home/pjeremy/sage-3.4/local/lib
  libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
  libraries lapack_atlas not found in /usr/home/peter/sage-4.1/local/lib
Line 136: Line 151:
/home/pjeremy/sage-3.4/spkg/build/numpy-1.2.0.p0/src/numpy/distutils/system_info.py:1247: UserWarning:  /usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1290: UserWarning:
Line 143: Line 158:
/home/pjeremy/sage-3.4/local/bin/gfortran -Wall build/temp.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/lapack_litemodule.o build/temp.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/python_xerbla.o -L/home/pjeremy/sage-3.4/local/lib -L/usr/local/lib/gcc-4.3.4/gcc/x86_64-portbld-freebsd7.0/4.3.4 -llapack -lblas -lgfortran -o build/lib.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/lapack_lite.so
build/temp.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/lapack_litemodule.o(.text+0x41): In function `check_object':
numpy/linalg/lapack_litemodule.c:103: undefined reference to `PyType_IsSubtype'
build/temp.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/lapack_litemodule.o(.text+0x7b):numpy/linalg/lapack_litemodule.c:114: undefined reference to `PyErr_Format'
build/temp.freebsd-7.0-STABLE-amd64-2.5/numpy/linalg/lapack_litemodule.o(.text+0xb7):numpy/linalg/lapack_litemodule.c:109: undefined reference to `PyErr_Format'
...
}}}
}}}

{{{#!wiki comment
Line 153: Line 163:
}}}
{{{#!wiki comment
Line 156: Line 167:
}}}
{{{#!wiki comment
Line 159: Line 171:
}}}
{{{#!wiki comment
Line 162: Line 175:
}}}
{{{#!wiki comment
Line 165: Line 179:
}}}
{{{#!wiki comment
Line 168: Line 183:
}}}
{{{#!wiki comment
Line 186: Line 202:
}}}
}#}}
}}}
{{{#!wiki comment
Line 190: Line 207:
}}}
{{{#!wiki comment
Line 193: Line 211:
}}}
{{{#!wiki comment
Line 204: Line 223:
}}}
}#}}
}}}
{{{#!wiki comment
Line 217: Line 237:
}}}
}#}}
}}}
{{{#!wiki comment
Line 223: Line 244:
}}}
{{{#!wiki comment
Line 226: Line 248:

=== matplotlib-0.98.5.3rc0-svn6910.p3 ===
}}}

=== matplotlib-0.98.5.3rc0-svn6910.p4 ===
Line 241: Line 264:
}}} }#}}
Line 255: Line 278:
}}} }#}}
Line 263: Line 286:
{{{#!wiki comment
Line 265: Line 289:
}}}
{{{#!wiki comment
Line 268: Line 293:
}}}
{{{#!wiki comment
Line 272: Line 298:
}}}
{{{#!wiki comment
Line 276: Line 303:
gcc -o libpari-gmp.so.2.3.3 -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl,-shared,-soname=libpari-gmp.so.2 mp.o mpinl.o Flx.o Qfb.o RgX.o alglin1.o alglin2.o arith1.o arith2.o base1.o base2.o base3.o base4.o base5.o bibli1.o bibli2.o buch1.o buch2.o buch3.o buch4.o galconj.o gen1.o gen2.o gen3.o ifactor1.o perm.o polarit1.o polarit2.o polarit3.o rootpol.o subcyclo.o subgroup.o trans1.o trans2.o trans3.o anal.o compat.o default.o errmsg.o es.o init.o intnum.o members.o sumiter.o aprcl.o elldata.o elliptic.o galois.o groupid.o kummer.o mpqs.o nffactor.o part.o stark.o subfield.o thue.o -lc -lm -L/home/pjeremy/sage-3.4/local/lib -lgmp  gcc -o libpari-gmp.so.2.3.3 -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl,-shared,-soname=libpari-gmp.so.2 mp.o mpinl.o Flx.o Qfb.o RgX.o alglin1.o alglin2.o arith1.o arith2.o base1.o base2.o base3.o base4.o base5.o bibli1.o bibli2.o buch1.o buch2.o buch3.o buch4.o galconj.o gen1.o gen2.o gen3.o ifactor1.o perm.o polarit1.o polarit2.o polarit3.o rootpol.o subcyclo.o subgroup.o trans1.o trans2.o trans3.o anal.o compat.o default.o errmsg.o es.o init.o intnum.o members.o sumiter.o aprcl.o elldata.o elliptic.o galois.o groupid.o kummer.o mpqs.o nffactor.o part.o stark.o subfield.o thue.o -lc -lm -L/home/pjeremy/sage-3.4/local/lib -lgmp
Line 282: Line 309:
}}}
}#}}
}}}
{{{#!wiki comment
Line 288: Line 316:

=== r-2.6.1.p22 ===
Pass CFLAGS, CPPFLAGS and LDFLAGS from the environment into the build process.
}}}

=== r-2.6.1.p23 ===
Pass CFLAGS, CPPFLAGS and LDFLAGS from the environment into the build process.  This also corrects a typo in CPPFLAGS.
Line 298: Line 327:
{{{#!wiki comment
Line 302: Line 332:
gcc -shared -o libreadline.so.5 readline.so vi_mode.so funmap.so keymaps.so parens.so search.so rltty.so complete.so bind.so isearch.so display.so signals.so util.so kill.so undo.so macro.so input.so callback.so terminal.so text.so nls.so misc.so xmalloc.so history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so tilde.so compat.so  gcc -shared -o libreadline.so.5 readline.so vi_mode.so funmap.so keymaps.so parens.so search.so rltty.so complete.so bind.so isearch.so display.so signals.so util.so kill.so undo.so macro.so input.so callback.so terminal.so text.so nls.so misc.so xmalloc.so history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so tilde.so compat.so
Line 304: Line 334:
gcc -shared -o libhistory.so.5 history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so xmalloc.so  gcc -shared -o libhistory.so.5 history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so xmalloc.so
Line 315: Line 345:
}}} }#}}
Line 318: Line 348:
}}}
{{{#!wiki comment
Line 321: Line 352:

=== sage_scripts-3.4 ===
}}}

=== sage_scripts-4.1.rc1 ===
Line 325: Line 357:
{{{#!wiki comment
Line 365: Line 398:
}}}

}#}}
}}}
{{{#!wiki comment
Line 379: Line 412:
}}} }#}}
Line 400: Line 433:
}}}
}#}}
}}}
{{{#!wiki comment
Line 406: Line 440:
}}}

Sage FreeBSD 7.x and 8.x build notes for Sage 4.1

Note that this page is under construction and currently incomplete. In particular, it still includes references to sage-3.4 in areas that have not been converted to sage-4.1.

Contents

Overall build environment differences

  • sh and /bin/sh are a POSIX shell, rather than bash.

  • make is the BSD make, not GNU make

Preparatory work

  • Install ports/shells/bash or ports/shells/bash3 (I used 4.0.24)
  • Install ports/devel/gmake
  • Install ports/lang/gcc43 - FreeBSD no longer ships with a Fortran compiler by default.
  • Install ports/devel/autoconf262
  • Install ports/converters/libiconv

It's likely there are other dependencies, I haven't tried building sage in a clean (tinderbox) environment.

Building Sage

The Sage build chain automatically unpacks and builds each spkg, however in order to build on FreeBSD, a number of spkgs need patching. Rather than manually unpack, patch and repack each spkg, I have instead modified base/sage-spkg to automatically apply a local patch if it exists.

On FreeBSD 7.x

  • Unpack sage-4.1.tar
  • cd sage-4.1

  • mkdir -p local/bin spkg/patches

  • Create symlinks to mask name differences.
    • ln -s /usr/local/bin/gmake local/bin/make

    • ln -s /usr/local/bin/bash local/bin/sh

    • ln -s /usr/local/bin/gcc43 local/bin/gcc

    • ln -s /usr/local/bin/g++43 local/bin/g++

    • ln -s /usr/local/bin/gfortran43 local/bin/gfortran

  • Copy the patches listed below into spkg/patches

  • Build Sage
    • SAGE_FORTRAN=/usr/local/bin/gfortran43 SAGE_FORTRAN_LIB=/usr/local/lib/gcc43/libgfortran.so gmake

Current Status

Notes on spkgs and attached patches

A number of the following patches change make to ${MAKE}. This the recommended way to recursively invoke make to ensure that the subordinate make is the same as the parent make (and also ensures that the two make instances will communicate on things like '-jX').

base.patch

base.txt

  • The patch to base/sage-spkg enables the local patching that the rest of the patches rely on. Note that this patch is not intended to be merged into sage but provides a convenient mechanism to apply local patches without requiring that the spkg files are locally re-rolled.

atlas-3.8.3.p5

Various fixes to make it compile on FreeBSD

  • FreeBSD uses an '_fbsd' suffix on the ELF format supported by ld - prevents ld: unrecognised emulation mode: elf_x86_64 error during atlas build. Reported upstream as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728930&group_id=23725

  • Building the libclapack.so should result in a libclapack.so being created. This appears to be a copy-and-paste error in atlas and has been reported as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728935&group_id=23725 (Note that this is not relevant to sage as libclapack is not built or used).

  • numpy on FreeBSD expects atlas to build different and (according to the FreeBSD numpy port, static) threaded libraries: libatlas_r instead of libatlas and libalapack_r instead of liblapack. libatlas_r is built as part of the threaded version of atlas. libalapack_r is a FreeBSD special which explicitly combines all of liblapack from the atlas lapack build with the threaded atlas version of liblapack.

numpy error from last point above:

atlas_blas_info:
  libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
  NOT AVAILABLE

/usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1383: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
...
atlas_info:
  libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
  libraries lapack_atlas not found in /usr/home/peter/sage-4.1/local/lib
numpy.distutils.system_info.atlas_info
  NOT AVAILABLE

/usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1290: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
...

matplotlib-0.98.5.3rc0-svn6910.p4

Add hooks to ensure that the local Sage versions of dependencies are used by FreeBSD. Otherwise you get:

BUILDING MATPLOTLIB
            matplotlib: 0.98.6svn
                python: 2.5.2 (r252:60911, Apr  1 2009, 08:50:05)  [GCC
                        4.3.4 20090326 (prerelease)]
              platform: freebsd7

REQUIRED DEPENDENCIES
                 numpy: no
                        * You must install numpy 1.1 or later to build
                        * matplotlib.
Error building matplotlib package.
}#}}

Add support for FreeBSD later than 6.x.  Otherwise you get :
{{{
REQUIRED DEPENDENCIES
Traceback (most recent call last):
  File "setup.py", line 119, in <module>
    if not check_for_numpy():
  File "/home/pjeremy/sage-3.4/spkg/build/matplotlib-0.98.5.3rc0-svn6910.p3/src/setupext.py", line 499, in check_for_numpy
    add_base_flags(module)
  File "/home/pjeremy/sage-3.4/spkg/build/matplotlib-0.98.5.3rc0-svn6910.p3/src/setupext.py", line 320, in add_base_flags
    [os.path.join(p, 'include') for p in basedir[sys.platform] ])
KeyError: 'freebsd7'
Error building matplotlib package.
}#}}

gcc4.3 (though not gcc4.2) appears to define putchar() in a way that breaks the putchar() definitions inside ttconv.  I couldn't quickly identify what the underlying cause was so I took the easy way out and undef'd the offending putchar() macro.

Individual character bounding boxes in AFM files do not have to be integral so convert each bounding box to a list of floats, rather than a list of ints.  This corrects a problem where most of the tests would fail with `ValueError: invalid literal for int() with base 10: '539.621'`.

All three sub-patches are in [[http://trac.sagemath.org/sage_trac/ticket/5873|#5873]]

{{{#!wiki comment
=== mpfr-2.4.1 ===
Portability fixes so the configure script works with a POSIX shell.

r-2.6.1.p23

Pass CFLAGS, CPPFLAGS and LDFLAGS from the environment into the build process. This also corrects a typo in CPPFLAGS.

Note that FreeBSD needs the path to libiconv to be explicitly specified. In theory, --with-libiconv-prefix should work but configure script is broken and ignores that path when looking for libiconv. Hard-wire /usr/local/include and /usr/local/lib via xxFLAGS.

Note that the X11 detection in spkg-install will not work anywhere other than Linux. This needs future work.

These patches are all local to Sage.

sage_scripts-4.1.rc1

Patch sage-spkg to apply local patches. This patch also disables deletion of the spkg/build/FOO temporary directories - which was useful during porting. This latter patch can be safely removed.