Sage FreeBSD 8.x build notes for Sage 4.5

Note that this is a work-in-progress and not currently complete. If you wish to assist, please contact me via [email protected]

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.5 but is expected to work, though additional work will be required on cephes.

Note that the LD_LIBRARY_PATH is needed to work arounf configuration errors in the FreeBSD port of gcc45 - 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

Sage does not currently build on FreeBSD. The currently outstanding issues are scipy not recognizing the Fortran compiler (see the scipy-0.7.p5 section below for more details) and missing lgammal in cephes (see the cephes-2.8 section before for more details).

Notes on spkgs and attached patches

base.patch

atlas-3.8.3.p12

liblapack.so includes undefined references to __powidf2 and __powisf2, which are defined in libgcc (no other Sage shared libraries appear to rely on libgcc helper functions). Unfortunately, for reasons I don't fully understand, linking liblapack.so against libgcc.a fails, even when building a normal executable. One example of the resultant error occurs when configuring numpy:

gcc _configtest.o -L/tank/obj/sage/sage-4.5/local/lib -llapack -lf77blas -lcblas -latlas -o _configtest
/usr/local/bin/ld: _configtest: hidden symbol `__powidf2' in /usr/local/lib/gcc45/gcc/x86_64-portbld-freebsd8.1/4.5.1/libgcc.a(_powidf2.o) is referenced by DSO
/usr/local/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
/usr/local/bin/ld: _configtest: hidden symbol `__powidf2' in /usr/local/lib/gcc45/gcc/x86_64-portbld-freebsd8.1/4.5.1/libgcc.a(_powidf2.o) is referenced by DSO
/usr/local/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
failure.
removing: _configtest.c _configtest.o
Status: 255

The fix is to add a dependency on libgcc_s.so when (re-)building liblapack.so in make_correct_shared.sh.

Trac ticket: #9600

cephes-2.8

FreeBSD does not yet include a full C99 libm so cephes is also used on FreeBSD. The overall approach used on the FreeBSD is for cephes to create complex.h, math.h and libm.so which are installed under $SAGE_LOCAL and contain the missing C99 functions then fall back to the FreeBSD base versions for functions existing in FreeBSD. This mean that references to <math.h>, <complex.h> or -lm will appear to reference a complete set of C99 functions, split over two physical locations.

Other changes:

Areas still needing work:

Trac ticket: #9543

cvxopt-0.9.p8

Needs patch to ensure that $SAGE_LOCAL/include is included in the search path to correctly pick up the C99 functions that do not exist in the FreeBSD base system (see comments on cephes).

Trac ticket: #?

flintqs-20070817.p5

TonelliShanks.h references int32_t but does not directly include <stdint.h>. On FreeBSD using gcc45 (but not the base gcc), this causes compilation to fail with:

g++ -ansi -c TonelliShanks.cpp -o TonelliShanks.o -I/tank/obj/sage/sage-4.5/local/include -Wall -Wno-sign-compare -fomit-frame-pointer -O2
In file included from TonelliShanks.cpp:31:0:
TonelliShanks.h:41:8: error: 'int32_t' does not name a type
TonelliShanks.h:43:51: error: 'int32_t' has not been declared
TonelliShanks.cpp:67:1: error: 'int32_t' does not name a type
TonelliShanks.cpp:136:54: error: 'int32_t' has not been declared
TonelliShanks.cpp: In function 'void sqrtmodpk(__mpz_struct*, __mpz_struct*, __mpz_struct*, __mpz_struct*, int)':
TonelliShanks.cpp:140:11: error: 'int32_t' was not declared in this scope
TonelliShanks.cpp:140:19: error: expected ';' before 'i'
TonelliShanks.cpp:140:25: error: 'i' was not declared in this scope
make[2]: *** [TonelliShanks.o] Error 1
make[2]: Leaving directory `/tank/obj/sage/sage-4.5/spkg/build/flintqs-20070817.p5/src'
Error building William Hart's Quadratic Sieve

As a work-around, make TonelliShanks.h idempotent on FreeBSD (it probably should be on all architectures but making the patch FreeBSD-specific simplifies testing).

Trac ticket: #9545

matplotlib-0.99.3

Add support for FreeBSD later than 6.x. Otherwise you get :

BUILDING MATPLOTLIB
            matplotlib: 0.99.1
                python: 2.6.2 (r262:71600, Jan  3 2010, 12:58:40)  [GCC
                        4.2.1 20070719  [FreeBSD]]
              platform: freebsd8

REQUIRED DEPENDENCIES
Traceback (most recent call last):
  File "setup.py", line 123, in <module>
    if not check_for_numpy():
  File "/home/peter/sage/sage-4.4.4/spkg/build/matplotlib-0.99.1.p2/src/setupext.py", line 506, in check_for_numpy
    add_base_flags(module)
  File "/home/peter/sage/sage-4.4.4/spkg/build/matplotlib-0.99.1.p2/src/setupext.py", line 327, in add_base_flags
    [os.path.join(p, 'include') for p in basedir[sys.platform] ])
KeyError: 'freebsd8'

Trac #5873 Reported upstream as https://sourceforge.net/tracker/?func=detail&aid=3031051&group_id=80706&atid=560722

numpy-1.3.0.p3

BUILDING MATPLOTLIB
            matplotlib: 0.99.1
                python: 2.6.2 (r262:71600, Jan  3 2010, 12:58:40)  [GCC
                        4.2.1 20070719  [FreeBSD]]
              platform: freebsd8

REQUIRED DEPENDENCIES
                 numpy: no
                        * You must install numpy 1.1 or later to build
                        * matplotlib.

Trac ticket: #7831

pari-2.3.5.p1

The Configure script does not detect log2, which it should. (This appears to be an intrinsic bug because it doesn't detect either exp2 or log2 on Linux). The top line of spkg-install is also corrupt.

These are left for now because #9343 includes a new pari - which I have not checked yet.

sage-4.5

Remaining issues include:

Trac ticket: #?

sage_scripts-4.5

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.

scipy-0.7.p5

scipy uses local/lib/python2.5/site-packages/numpy/distutils/fcompiler/gnu.py to locate a Fortran compiler. This code only looks for g77, f77, gfortran and f95. Whilst it has some patches to look in sage_fortran, this does not appear to work for scipy, at least on FreeBSD. The work-around is to create a symlink to the actual Fortran compiler in local/bin, otherwise the scipy build fails with:

building 'mach' library
using additional config_fc from setup script for fortran compiler: {'noopt': ('scipy/integrate/setup.py', 1)}
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
Traceback (most recent call last):
  File "setup.py", line 92, in <module>
    setup_package()
  File "setup.py", line 84, in setup_package
    configuration=configuration )
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/core.py", line 184, in setup
    return old_setup(**new_attr)
  File "/tmp/sage-4.5/local/lib/python/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/tmp/sage-4.5/local/lib/python/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/tmp/sage-4.5/local/lib/python/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/command/build.py", line 37, in run
    old_build.run(self)
  File "/tmp/sage-4.5/local/lib/python/distutils/command/build.py", line 134, in run
    self.run_command(cmd_name)
  File "/tmp/sage-4.5/local/lib/python/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/tmp/sage-4.5/local/lib/python/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/command/build_clib.py", line 93, in run
    self.build_libraries(self.libraries)
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/command/build_clib.py", line 104, in build_libraries
    self.build_a_library(build_info, lib_name, libraries)
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/command/build_clib.py", line 157, in build_a_library
    fcompiler.customize(base_config_fc)
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/fcompiler/__init__.py", line 449, in customize
    self.find_executables()
  File "/tmp/sage-4.5/local/lib/python2.6/site-packages/numpy/distutils/fcompiler/__init__.py", line 342, in find_executables
    raise CompilerNotFound('%s: f90 nor f77' % ctype)
numpy.distutils.fcompiler.CompilerNotFound: gnu95: f90 nor f77
Error building scipy.

Further investigation is required to identify the underlying cause (since there doesn't appear to be a problem on Linux).

Trac ticket: #?

singular-3.1.0.4.p7

By default, you get the following, which is corrected by the patch to singuname.sh:

make[2]: Entering directory `/home/peter/sage/sage-4.4.4/spkg/build/singular-3-1-0-4-20090818.p2/src'
make[2]: *** No rule to make target `distclean'.  Stop.
make[2]: Leaving directory `/home/peter/sage/sage-4.4.4/spkg/build/singular-3-1-0-4-20090818.p2/src'
rm: /home/peter/sage/sage-4.4.4/local/bin/Singular*: No such file or directory
creating cache ./config.cache
checking uname for singular... unknown
configure: error: Unknown architecture: Check singuname.sh
Unable to configure Singular.

Correct configure script for amd64 by patching the autoconf inputs and re-running autoconf. This corrects a problem where linking libsingular.so reports lots of undefined references to both internal om* functions and functions within libncurses.

Several other trivial fixes to support dynamic linking on FreeBSD/amd64.

Trac ticket: #7832