Sage FreeBSD 8.x build notes for Sage 4.3

Note that this is a work-in-progress and not currently complete

Contents

Overall build environment differences

Preparatory work

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

Building Sage

On FreeBSD 8.x

FreeBSD 7.x hasn't been tested with Sage 4.3 but is expected to work.

Note that it's not currently possible to use gcc44/g++44 to build Sage - configuration errors in the FreeBSD port of gcc44 means that the wrong shared libraries get used if this is attempted. See http://www.freebsd.org/cgi/query-pr.cgi?pr=129518

The gmake to make symlink is necessary to compile (eg) eclib - which is documented as requiring GNU make, and has this symlink as a suggested workaround.

Current Status

Currently, the following tests fail on FreeBSD 8.0-STABLE/amd64. Full logs at sage-4.3.freebsd8.0-amd64.test.log.

The actual failures indicate that the port still needs significant work and include:

Notes on spkgs and attached patches

base.patch

?atlas-3.8.3.p9

Various fixes to make it compile on FreeBSD

Trac ticket: #?

cliquer-1.2.p2

FreeBSD uses the same invocation as Linux to build shared libraries. This patch is necessary to allow cliquer to build.

Trac ticket: #7824

?gap-4.4.10.p12

Patches (mostly taken from the FreeBSD port) to make gap compile on FreeBSD 8.x. These patches should be optional on FreeBSD/7.x.

Trac ticket: #?

libgcrypt-1.4.4.p1

Chase shared library name difference on FreeBSD. Sage local patch. Otherwise the gnutls build fails similar to:

(cd /home/peter/sage/sage-4.3/spkg/build/gnutls-2.2.1.p4/src/libextra; /bin/sh ../libtool  --tag=CC --mode=relink gcc -std=gnu99 -g -O2 -D_REENTRANT -D_THREAD_SAFE -pipe -I/home/peter/sage/sage-4.3/local/include -g -O2 -D_REENTRANT -D_THREAD_SAFE -Wno-pointer-sign -no-undefined -L../lib/.libs -L/home/peter/sage/sage-4.3/local/lib -lopencdk -L/usr/local/lib -L/usr/local/lib -lgcrypt -L/usr/local/lib -lgpg-error -L/usr/local/lib -lintl -L/usr/local/lib -liconv -L/home/peter/sage/sage-4.3/local/lib -lz -R/home/peter/sage/sage-4.3/local/lib -R/usr/local/lib -version-info 27:2:1 -o libgnutls-extra.la -rpath /home/peter/sage/sage-4.3/local/lib gnutls_extra.lo gnutls_openpgp.lo gnutls_ia.lo openpgp/libgnutls_openpgp.la ../lgl/liblgnu.la ../lib/libgnutls.la minilzo/libminilzo.la )  
gcc -std=gnu99 -shared  .libs/gnutls_extra.o .libs/gnutls_openpgp.o .libs/gnutls_ia.o -Wl,--whole-archive openpgp/.libs/libgnutls_openpgp.a ../lgl/.libs/liblgnu.a minilzo/.libs/libminilzo.a -Wl,--no-whole-archive  -Wl,--rpath -Wl,/home/peter/sage/sage-4.3/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/home/peter/sage/sage-4.3/spkg/build/gnutls-2.2.1.p4/src/lib/.libs -L/home/peter/sage/sage-4.3/local/lib -lopencdk -L/usr/local/lib -lz -lgcrypt -lintl -liconv -lgpg-error -lgnutls  -Wl,-soname -Wl,libgnutls-extra.so.27 -o .libs/libgnutls-extra.so.27
/usr/bin/ld: /home/peter/sage/sage-4.3/local/lib/libgcrypt.a(libgcrypt_la-visibility.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/home/peter/sage/sage-4.3/local/lib/libgcrypt.a: could not read symbols: Bad value
libtool: install: error: relink `libgnutls-extra.la' with the above command before installing it
*** Error code 1

Stop in /home/peter/sage/sage-4.3/spkg/build/gnutls-2.2.1.p4/src/libextra.
*** Error code 1

Trac ticket: #7823

?matplotlib-0.99.1.p2

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 #5873

?numpy-1.2.0.p0

Trac ticket: #?

pari-2.3.3.p5

FreeBSD refers to the x86_64 architecture under its original name of 'amd64' so use this as an alias for x86_64. The `-fPIC' fix is needed to correct:

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/peter/sage/sage-4.3/local/lib -lgmp 
/usr/bin/ld: mp.o: relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
mp.o: could not read symbols: Bad value
*** Error code 1

Stop in /home/peter/sage/sage-4.3/spkg/build/pari-2.3.3.p5/src/Ofreebsd-amd64.

Trac ticket: #7825 Reported upstream as http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1022

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

Trac ticket: #?

readline-6.0.p1

readline-6.0.p1/spkg-install contains a typo in some FreeBSD-specific code, leading to the following error:

...
/bin/sh ../support/shlib-install -O freebsd8.0 -d /home/peter/sage/sage-4.3/local/lib -b /home/peter/sage/sage-4.3/local/bin -i "/usr/bin/install -c -m 644" libreadline.so.6.0
install: you may need to run ldconfig
make[1]: Leaving directory `/home/peter/sage/sage-4.3/spkg/build/readline-6.0.p1/src/shlib'
ln: SAGE_LOCAL/lib/libreadline.so: No such file or directory

The affected code is no longer required with readline-6.0 so delete it.

FreeBSD 3.x and later default to ELF, rather then a.out. A utility objformat(1) was temporarily introduced to enable third-party applications to determine te object format. This has now been deleted and code should assume ELF format if it does not exist. Explicitly linking libreadline against libtermcap is necessary to ensure that dependencies are picked up.

Trac ticket #7821

?sage-4.1

Trac ticket: #?

sage_scripts-4.3

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.