Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2009-08-07 11:16:50
Size: 28128
Editor: PeterJeremy
Comment: Continue documenting the necessary patches.
Revision 12 as of 2009-08-09 19:25:48
Size: 29404
Editor: PeterJeremy
Comment: Note ecl needs POSIX semaphores
Deletions are marked like this. Additions are marked like this.
Line 18: Line 18:

It's likely there are other dependencies, I haven't tried building sage in a clean (tinderbox) environment.
 * 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.
Line 22: Line 23:

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.
Line 116: Line 115:
Line 118: Line 116:
Line 122: Line 121:
[[attachment:atlas-3.8.3.p5.patch]]
Line 123: Line 124:
 * 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
 * Treat shared libraries the same as Linux - otherwise they aren't correctly detected by (eg) numpy. (sage-specific)
Line 127: Line 130:
}}}
 * 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
Line 133: Line 134:
{{{ {#{{
Line 264: Line 265:
}#}} }}}
Line 278: Line 279:
}#}} }}}
Line 294: Line 295:
{{{#!wiki comment
Line 296: Line 297:
Correctly pass `-fPIC` when building the shared library.
Various fixes to handle correct fortran and library detection on FreeBSD.
}}}
[[attachment:numpy-1.3.0.p0.patch]]

 * `__init__.py` needs a sage-specific patch to prefer sage_fortran on FreeBSD.
 * 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 [[http://mail.scipy.org/pipermail/numpy-discussion/2009-August/044523.html|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.
Line 349: Line 352:
{{{#!wiki comment
=== 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-4.1.rc1 ===

=== sage-4.1 ===
[[attachment:sage-4.1.patch]]
 * Compiling `sage/combinat/partitions_c.cc` fails because FreeBSD 7.x does not define `sqrtl` (it was introduced in FreeBSD 8.0). As a hackish workaround, define sqrtl to be sqrt.
 * FreeBSD does not include a definition for log2() in libm. Use a simplistic definition of log2(x) = log2(e) * ln(x) - this is numerically poor but can be cleaned up later if required.

=== sage_scripts-4.1 ===

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

Building Sage

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

atlas-3.8.3.p5.patch

Various fixes to make it compile on FreeBSD

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

numpy-1.2.0.p0

numpy-1.3.0.p0.patch

  • __init__.py needs a sage-specific patch to prefer sage_fortran on FreeBSD.

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

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-4.1

sage-4.1.patch

  • Compiling sage/combinat/partitions_c.cc fails because FreeBSD 7.x does not define sqrtl (it was introduced in FreeBSD 8.0). As a hackish workaround, define sqrtl to be sqrt.

  • FreeBSD does not include a definition for log2() in libm. Use a simplistic definition of log2(x) = log2(e) * ln(x) - this is numerically poor but can be cleaned up later if required.

sage_scripts-4.1

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.