#9543: Enable cephes on FreeBSD
---------------------------+------------------------------------------------
Reporter: pjeremy | Owner: pjeremy
Type: defect | Status: new
Priority: major | Milestone: sage-5.0
Component: FreeBSD | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
---------------------------+------------------------------------------------
Comment (by stephen):
I could not get pjeremy's patch to work for FreeBSD. After some
searching, I found out that the problem is that his patch attempts to link
the cephes functions with /lib/libm.so. This is something that is not
meant to work for dynamic libraries. Once a dynamic library has been
created, apparently there is no mechanism for merging it with other
dynamic libraries.
My solution was to slightly modify pjeremy's patch so that it creates a
library libm_complex.so. The following patch should be applied to
pjeremy's patch:
{{{
--- cephes-2.8 2012-04-14 01:39:13.000000000 +0000
+++ cephes-2.8 2012-04-14 01:38:51.000000000 +0000
@@ -1273,11 +1273,11 @@
+# Intermediate (ar) libraries
+LIBS=c9x-complex/libmc.a double/libmd.a ldouble/libml.a single/libmf.a
+
-+all: libm.so
++all: libm_complex.so
+
-+install: libm.so complex.h math.h
++install: libm_complex.so complex.h math.h
+ ${INSTALL} -C -m 644 complex.h math.h "${SAGE_LOCAL}/include"
-+ ${INSTALL} -C -m 755 libm.so "${SAGE_LOCAL}/lib"
++ ${INSTALL} -C -m 755 libm_complex.so "${SAGE_LOCAL}/lib"
+
+check:
+ cd c9x-complex && ${MAKE} "CC=${CC}" check
@@ -1291,7 +1291,7 @@
+# TBD
+
+clean:
-+ rm -f libm.so syms.c99 syms.libm syms.wanted
++ rm -f libm_complex.so syms.c99 syms.libm syms.wanted
+ cd c9x-complex && ${MAKE} clean
+ cd double && ${MAKE} clean
+ cd ldouble && ${MAKE} clean
@@ -1300,8 +1300,8 @@
+# FreeBSD includes some but not all of the C99 maths functions. Build
+# a "new" libm.so that uses cephes functions to replace the missing ones
+# (listed in syms.wanted) and then fallback to the base libm.so
-+libm.so: ${LIBS} syms.wanted
-+ ${LD} -shared -o $@ $$(sed 's/^/-u /' syms.wanted) -L/usr/lib -lc
-lm \
++libm_complex.so: ${LIBS} syms.wanted
++ ${LD} -shared -o $@ $$(sed 's/^/-u /' syms.wanted) -L/usr/lib \
+ ${LIBS} -lgcc
+
+# List of symbols defined in the FreeBSD base libc.so and libm.so
}}}
Then I put a script in $SAGE_ROOT/local/bin called "cc" which is a wrapper
around the cc I really want to use:
{{{
#!/usr/local/bin/bash
# Intersperse a "-lm_complex" before "-lm".
n=0
for i in "$@"; do
if [ "x$i" = "x-lm" ]; then
arg[$n]="-lm_complex"
n=$((n+1))
arg[$n]="-lm"
else
arg[$n]="$i"
fi
n=$((n+1))
done
# Some configure scripts invoke the compiler with the argument "-v", and
if
# LDFLAGS are added to the arguments, this results in an error which
# ultimately stops the relevant package being built.
# Otherwise LDFLAGS needs to be added so that the linker knows where to
find
# the dynamic libraries.
if [ $n = 1 -a "x${arg[0]}" = "x-v" ]; then
exec /usr/local/bin/gcc46 "${arg[@]}"
else
exec /usr/local/bin/gcc46 -Wl,-rpath=$SAGE_ROOT/local/lib
-Wl,-rpath=/usr/local/lib/gcc46 "${arg[@]}"
fi
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9543#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.