Differences between revisions 1 and 2
Revision 1 as of 2009-03-27 22:31:30
Size: 6813
Editor: PeterJeremy
Comment:
Revision 2 as of 2009-03-27 23:02:42
Size: 7395
Editor: PeterJeremy
Comment:
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
 * Unpack the attached shar archive  * Unpack the attached shar archive: [[attachment:sage-3.4.shar]]
Line 31: Line 31:

== Current Status ==

Sage compiles and some (simple) operations work. A large number of the self-tests fail with the error `ValueError: invalid literal for int() with base 10: '539.621'` (the value is always the same) and a python backtrace - which makes me believe that the python built by sage is faulty. The FreeBSD port for python includes a number of patches (see [[http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/python25/files/]]) as well as some build process patches and it seems likely that some of these changes need to be applied.

Sage FreeBSD 8-current/amd64 build notes for Sage 3.4

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 3.2.48)
  • Install ports/devel/gmake
  • Install ports/lang/gcc43 - FreeBSD no longer ships with a Fortran compiler by default. I tried using g95 but ran into problems.

It's possible 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.

  • Unpack sage-3.4.tar
  • cd sage-3.4

  • 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/gfortran43 local/bin/gfortran

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

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

  • Unpack the attached shar archive: sage-3.4.shar

  • Apply patches to base build system
    • patch < spkg/patches/base.patch

  • Build Sage
    • CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib gmake

Current Status

Sage compiles and some (simple) operations work. A large number of the self-tests fail with the error ValueError: invalid literal for int() with base 10: '539.621' (the value is always the same) and a python backtrace - which makes me believe that the python built by sage is faulty. The FreeBSD port for python includes a number of patches (see http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/python25/files/) as well as some build process patches and it seems likely that some of these changes need to be applied.

Notes on spkgs and attached patches

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).

base.patch

  • The patch to base/sage-spkg enables the local patching that the rest of the patches rely on
  • The patch to standard/deps ensures that bash is used.

atlas-3.8.3.p0

Various fixes to make it compile on FreeBSD

  • sysctl is not in the default user path so use an explicit pathname

  • The newer AMD CPUs all identify as 'Athlon' so use the existence of multiple cores to distinguish between K7 (i386) and later (Hammer) CPUs.
  • Correct various sysctl OIDs to match the names FreeBSD uses.
  • FreeBSD uses an '_fbsd' suffix on the ELF format supported by ld

  • Treat shared libraries the same as Linux
  • (I no longer recall why it is patched to use libclapack.so rather than liblapack.so - this may no longer be necessary)

clisp-2.46.p7

The FreeBSD/amd64 process memory map is incompatible with the memory mapping done by clisp. The patch moves the memory map down 8 bits. An alternative (used by the FreeBSD clisp port) is to pass --disable-mmap to configure.

eclib-20080310.p7

Various 'make' fixes - see above.

ecm-6.2.1.p0

Portability fixes so the configure script works with a POSIX shell.

fortran-20071120.p5

FreeBSD doesn't have a '-f' option on readlink

freetype-2.3.5.p0

Various 'make' fixes - see above.

gap-4.4.12.p1

Patches (mostly taken from the FreeBSD port) to make gap compile on FreeBSD.

gmp-mpir-0.9

Various 'make' fixes - see above.

iml-1.0.1.p11

Remove a stray warning by not attempting to execute ${CFLAGS}

libgcrypt-1.4.3.p0

Chase shared library name difference on FreeBSD.

libgpg_error-1.6.p0

Chase shared library name difference on FreeBSD.

libm4ri-20090128

The configure script is pretty much beyond redemption on FreeBSD. Instead fix the autoconf inputs to support FreeBSD and re-run autoconf. The libm4ri fixes have all be forwarded to the libm4ri maintainer and accepted by them.

Also ensure that CPPFLAGS from the environment is passed into the libm4ri build process.

linbox-1.1.6

Detect FreeBSD and appropriately select BLAS and Atlas libraries.

matplotlib-0.98.5.3rc0-svn6910.p3

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

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.

mpfr-2.4.1

Portability fixes so the configure script works with a POSIX shell.

ntl-5.4.2.p6

Correctly pass -fPIC when building the shared library.

numpy-1.2.0.p0

Correctly pass -fPIC when building the shared library. Various fixes to handle correct fortran and library detection on FreeBSD.

pari-2.3.3.p0

FreeBSD refers to the x86_64 architecture under its original name of 'amd64' so use this as an alias for x86_64.

r-2.6.1.p22

Pass CFLAGS, CPPFLAGS and LDFLAGS from the environment into the build process.

readline-5.2.p6

Chase shared library name difference on FreeBSD.

sage-3.4

FreeBSD does not include a definition for log2() in libm. Use a simplistic definition of log2(x) = log2(e) * ln(x)

sage_scripts-3.4

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.

singular-3-0-4-4-20080711.p4

Correct configure script for amd64 by patching the autoconf inputs and re-running autoconf.

Several other trivial fixes to handle FreeBSD/amd64.

The rationale behind original code to disable __cplusplus in cf_gmp.h is unclear. The result on FreeBSD is definitely broken as cf_gmp.h includes gmp.h which includes string.h - which results in strcat() and friends being declared without a surrounding extern "C" {...} block. This causes the code to linvoke (non-existent) C++ versions of strcat(char *, const char *), rather than the standard C library strcat(). Commenting out this code fixes the problem.

tachyon-0.98beta.p8

tachyon does include BSD support (though the code advises that it hasn't been tested for a while). Looking though the source code, there's no obvious bitrot so add FreeBSD support to the spkh-install script. As noted, I haven't added support for either threaded or 64-bit tachyon. The former shouldn't be too difficult to add and the MacOS-X port implies it is optional. The 64-bit support is solely an optimisation - a test to detect wrap-around of long integers is removed since wrap-around isn't possible with 64-bit longs.