Sage FreeBSD 8.x build notes for Sage 4.6.1-alpha2
Note that this is a work-in-progress and not currently complete. If you wish to assist, please contact me via [email protected]
Overall build environment differences
sh and /bin/sh are a POSIX shell, rather than bash.
make is the BSD make, not GNU make
- Install ports/shells/bash or ports/shells/bash3 (I used 4.1.7)
- Install ports/devel/gmake
- Install ports/lang/gcc45 - FreeBSD no longer ships with a Fortran compiler by default.
- Install ports/devel/autoconf262
- Install ports/converters/libiconv
Ensure POSIX semaphores are available. This is required for ecl (at least). These are not available by default before FreeBSD 7.3 or 8.0 and should be enabled by either kldload sem or building a kernel with options P1003_1B_SEMAPHORES. If they are not available, building ecl will fail with Bad system call.
It's possible there are other dependencies, I haven't tried building sage in a clean (tinderbox) environment.
On FreeBSD 8.x
FreeBSD 7.x hasn't been tested with Sage 4.6.1 but is expected to work, though additional work will be required on cephes.
- Unpack sage-4.6.1.tar
Unpack sage-4.6.1.alpha2.patch which includes the following:
- 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/gfortran45 local/bin/gfortran
Various patches as described below into spkg/patches
- Build Sage
LD_LIBRARY_PATH=/usr/local/lib/gcc45 SAGE_PORT=yes SAGE_FORTRAN=/usr/local/bin/gfortran45 SAGE_FORTRAN_LIB=/usr/local/lib/gcc45/libgfortran.so gmake
- Run Sage
Note that the LD_LIBRARY_PATH is needed to work around 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.
Porting still in progress and sage does not fully compile.
Notes on spkgs and attached patches
- 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.
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.
C99 defines lgammal as the long double natural log of the absolute value of the gamma function, with the sign of the result returned in the int variable signgam. cephes uses lgaml and sgnnaml (though it's documented as sgngam) instead. Rename the lgaml to lgammal and sgnnaml to signgam.
C99 defines tgammal as the long double value of the gamma function, which does not affect signgam. cephes uses gammal, which does affect sgnnaml. Rename the gammal to tgammal and localize the use of signgam within tgammal.
- Enable '-e' option on spkg-install to catch errors
(tgammal and lgammal are required by sage/symbolic/pynac.cpp)
Areas still needing work:
- cephes-2.8 is known to fail a number of its self-tests (when they are enabled).
- Missing self-test sources need to be re-added and an appropriate test suite created. Possibly mpfr could be used as a reference library.
The lgammal, signgam and tgammal changes above need to be reflected both in the self-test sources and in the double and float versions of those functions.
Based on a standalone test of cephes-2.8 on FreeBSD-7.1, the following C99 functions are currently missing: carg, cargf, cargl, cproj, cprojf, cprojl, fmodl, llrintl, logbl, lrintl, nan, nanf, nanl, nearbyintl, remainderl, remquol, rintl and tgammaf.
Trac ticket: #9543
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: *** [TonelliShanks.o] Error 1 make: 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
By default, numpy references threaded atlas libraries, as well as a custom variant on the lapack library, on FreeBSD. The reasoning behind this is unclear - there is nothing in the numpy documentation to indicate whether a threaded or non-threaded atlas is needed and the publicly available SVN logs do not mention this code. A query to the numpy mailing list elicited a response that either threaded or non-threaded atlas can be used and suggesting that the special-casing for FreeBSD may be obsolete. By default, atlas is built non-threaded and r-2.6.1.p23 assumes a non-threaded atlas and fails when only the threaded libraries are installed. Based on this, the special casing for FreeBSD was removed from numpy - it now uses the same libraries irrespective of the host OS.
$SAGE_LOCAL/include needs to be added to the search path to pick up the correct <math.h> (see cephes).
Trac ticket: #7831
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.