diff --git a/packages/libpari/0001-Make-Configure-script-verbose.patch b/packages/libpari/0001-Make-Configure-script-verbose.patch new file mode 100644 index 00000000..06946241 --- /dev/null +++ b/packages/libpari/0001-Make-Configure-script-verbose.patch @@ -0,0 +1,23 @@ +From befdbb64fc403ff383ea656f9b237f3a989e8603 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Julian=20R=C3=BCth?= +Date: Wed, 15 Feb 2023 14:24:37 +0100 +Subject: [PATCH 1/5] Make Configure script verbose + +--- + Configure | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Configure b/Configure +index 0cbbc6b..d0516ae 100755 +--- a/Configure ++++ b/Configure +@@ -15,6 +15,7 @@ + # + # Perl's Configure and GNU autoconfig were of much help in writing these files. + # $Id$ ++set -v + + TOP=`pwd` + MAKE=${MAKE:-make} +-- +2.39.1 diff --git a/packages/libpari/0002-Do-not-run-get_cc-when-cross-compiling.patch b/packages/libpari/0002-Do-not-run-get_cc-when-cross-compiling.patch new file mode 100644 index 00000000..e479db72 --- /dev/null +++ b/packages/libpari/0002-Do-not-run-get_cc-when-cross-compiling.patch @@ -0,0 +1,198 @@ +From 2e1eff4255f2d330776a93cc768f773775408ca9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Julian=20R=C3=BCth?= +Date: Wed, 15 Feb 2023 14:31:29 +0100 +Subject: [PATCH 2/5] Do not run get_cc when cross compiling + +because it tries to run native executables +--- + Configure | 13 ++++- + config/get_cc | 154 -------------------------------------------------- + 2 files changed, 10 insertions(+), 157 deletions(-) + delete mode 100644 config/get_cc + +diff --git a/Configure b/Configure +index d0516ae..be61179 100755 +--- a/Configure ++++ b/Configure +@@ -68,9 +68,16 @@ EOT + exec 5>> $config_log + + ####################### CONFIGURE - COMPILATION ############################# +-# $_cc_list (includes 'optimization'), extraflag +-. ./get_cc +-# ++# Set variables as ./get_cc would (which does not support cross compilation) ++__gnuc__=clang ++optimization=full ++DBGFLAGS= ++OPTFLAGS=-O2 ++exe_suffix= ++suffix= ++ASMINLINE= ++KERNELCFLAGS= ++ + . ./get_mt + # doubleformat, sizeof_long + . ./get_double_format +diff --git a/config/get_cc b/config/get_cc +deleted file mode 100644 +index 2d61d38..0000000 +--- a/config/get_cc ++++ /dev/null +@@ -1,154 +0,0 @@ +-# Exported variables +-_cc_list="__gnuc__ CC CFLAGS optimization DBGFLAGS OPTFLAGS exe_suff suffix ASMINLINE KERNELCFLAGS" +- +-# Which optimization ? +-if test "$fastread" != yes; then +- cat << EOT +-========================================================================== +-The default is to fully optimize the compilation. You may choose to build +- an executable for debugging or profiling instead. Choose among : +- full debugging profiling gcov +-EOT +- echo $n ..."Which optimization do you prefer ? $c" +- dflt=$optimization; rep='full debugging profiling gcov'; . ./myread +- optimization=$ans +-fi +- +-case "$osname" in +- os2) exe_suff=.exe; extraflag="-Zexe";; +- emscripten) exe_suff=.js;; +- cygwin|mingw) exe_suff=.exe; extraflag="";; +-# On Darwin, by default, the full library search path is searched for a .dylib +-# before a .a can be considered, preventing users to install their libraries +-# in a simple way (e.g. the readline / Editline conflict). Override this. +- darwin) exe_suff=; extraflag=-Wl,-search_paths_first;; +- *) exe_suff=; extraflag="";; +-esac +- +-if test -z "$CC"; then +- echo Choosing C compiler ... +- if test -n "$gcc"; then CC=$gcc; else CC=$cc; fi +-fi +- +-if test "$fastread" != yes; then +- cat << EOT +-========================================================================== +-Only ANSI C and C++ compilers are supported. Choosing the GNU compiler +-gcc/g++ enables the inlining of kernel routines (about 20% speedup; if you +-use g++, include the -fpermissive flag). We strongly recommand using gcc all +-the way through. +-EOT +- echo $n ..."Which C compiler shall I use ? $c" +- dflt=$CC; rep=; . ./myread +- CC=$ans +-fi +-if test -z "$CC"; then cat <&1 |\ +- grep ' version ' | tr '\n' , | sed -e 's/ *,$//' |\ +- sed -e 's/(.*) *\((.*)\)/\1/'` +- echo GNU compatible compiler: $__gnuc__ +- fi +- . cleanup_exe +-fi +- +-# Which Flags for Compiler ? +-cflags= +-ASMINLINE= +-if test -n "$__gnuc__"; then +- __GNUC__="-D__GNUC__" +- warn="-Wall" +- OPTFLAGS=-O3 +- ASMINLINE=yes +- OPTFLAGS="$OPTFLAGS $warn" +- cmd="$CC $CFLAGS $extraflag -ffp-contract=off -o $exe gnu.c" +- . log_cmd +- if test -s $exe; then +- OPTFLAGS="$OPTFLAGS -ffp-contract=off" +- fi +- . cleanup_exe +- cmd="$CC $CFLAGS $extraflag -fno-strict-aliasing -o $exe gnu.c" +- . log_cmd +- if test -s $exe; then +- OPTFLAGS="$OPTFLAGS -fno-strict-aliasing" +- fi +- . cleanup_exe +- case "$optimization" in +- full) KERNELCFLAGS=-funroll-loops;; +- esac +- +- DBGFLAGS=${DBGFLAGS:-"-g $warn"} +- # Specific optimisations for some architectures +- case "$arch" in +- sparcv8*) cflags=-mv8;; +- esac +- # problems on some architectures +- case "$osname" in +- os2) cflags="$cflags -Zmt -Zsysv-signals";; +- nextstep) cflags="$cflags -traditional-cpp";; +- esac +- +- PRFFLAGS="-pg $OPTFLAGS" +- GCOVFLAGS="-fprofile-arcs -ftest-coverage" +-else +- DBGFLAGS=${DBGFLAGS:-'-g'} +- PRFFLAGS='-pg' +- case "$osname-$arch" in +- hpux-*) # -Ae is for ANSI C + defines HPUX_SOURCE +- OPTFLAGS=-O; cflags=-Ae;; +- aix-*) OPTFLAGS='-O2 -qtune=auto -qmaxmem=8192' +- cflags='-qlanglvl=ansi';; +- osf1-*) OPTFLAGS='-O4 -migrate -ifo -Olimit 9999';; +- sunos-*) OPTFLAGS=-fast; PRFFLAGS='-pg -Bstatic';; +- solaris-*) OPTFLAGS='-fast -fsimple=1'; PRFFLAGS=-xpg; +- case "$arch" in +- sparc*) OPTFLAGS="$OPTFLAGS -xalias_level=any";; +- esac;; +- concentrix-*) OPTFLAGS=-Ogi;; +- *) OPTFLAGS=-O;; +- esac +- PRFFLAGS="$PRFFLAGS $OPTFLAGS" +-fi +- +-case "$optimization" in +- full) suffix=; cflags="$OPTFLAGS $cflags";; +- profiling) suffix=.prf; cflags="$PRFFLAGS $cflags";; +- debugging) suffix=.dbg; cflags="-DMEMSTEP=1048576 $DBGFLAGS $cflags";; +- gcov) suffix=.gcov; cflags="$GCOVFLAGS $cflags";; +-esac +- +-CFLAGS="$cflags $CFLAGS $CPPFLAGS" +-if test "$fastread" != yes; then +- echo $n ..."With which flags ? $c" +- dflt=$CFLAGS; rep=; . ./myread +- CFLAGS=$ans +-fi +-- +2.39.1 diff --git a/packages/libpari/0003-Do-not-run-get_double_format-when-cross-compiling.patch b/packages/libpari/0003-Do-not-run-get_double_format-when-cross-compiling.patch new file mode 100644 index 00000000..9978688b --- /dev/null +++ b/packages/libpari/0003-Do-not-run-get_double_format-when-cross-compiling.patch @@ -0,0 +1,87 @@ +From 211fb65f69a20c5e806a58b7ad07d541324de419 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Julian=20R=C3=BCth?= +Date: Wed, 15 Feb 2023 15:13:02 +0100 +Subject: [PATCH 3/5] Do not run get_double_format when cross compiling + +--- + Configure | 6 +++-- + config/get_double_format | 51 ---------------------------------------- + 2 files changed, 4 insertions(+), 53 deletions(-) + delete mode 100644 config/get_double_format + +diff --git a/Configure b/Configure +index be61179..6468d04 100755 +--- a/Configure ++++ b/Configure +@@ -79,8 +79,10 @@ ASMINLINE= + KERNELCFLAGS= + + . ./get_mt +-# doubleformat, sizeof_long +-. ./get_double_format ++# Set variables as ./get_double_format would (which does not support cross compilation) ++doubleformat=- ++_format='not needed (64bit)' ++sizeof_long=8 + # asmarch, pretty + . ./get_kernel + # _dl_list, DLCFLAGS, update CFLAGS +diff --git a/config/get_double_format b/config/get_double_format +deleted file mode 100644 +index 3c5a3d7..0000000 +--- a/config/get_double_format ++++ /dev/null +@@ -1,51 +0,0 @@ +-exe=$osname-$arch-endian$$$exe_suff +-cmd="$CC $CFLAGS $extraflag endian.c -o $exe"; . log_cmd +-if test -r $exe; then +- doubleformat=`$RUNTEST $exe`; +-else +- echo "***************************************************************" +- echo "Cannot compile endian.c. Aborting. PLEASE REPORT!" +- exit 1 +-fi +-. cleanup_exe +-case "$doubleformat" in +- *IEEE*) +- echo "***************************************************************" +- echo "Your 'double' type does not follow the IEEE754 format. Aborting" +- echo "PLEASE REPORT! (dbltor/rtodbl need to be fixed)"; exit 1;; +- -) sizeof_long=8;; +- *) sizeof_long=4;; +-esac +-echo "Given the previous choices, sizeof(long) is $sizeof_long chars." +- +-if test "$fastread" != yes; then +-cat << EOT +-If your hardware supports different size of longs (e.g SGI/MIPS), and you +-want to use a different word size than the above. You should probably have +-specified some exotic compilation flag CFLAG (e.g -o32,-n32). +- +-EOT +- +- if test $doubleformat != "-"; then +-cat << EOT +-For 32-bit architecture, PARI needs to know the format of your 'double' type. +-PARI assumes doubles are stored in IEEE754 format [ (sign, exponent, mantissa +-high) on one word, (mantissa low) on another ]; assuming a +- union { double d; ulong l[2]; } x; +-are the double exponent and sign stored on x.i[0] (0) or on x.i[1] (1) ? +- +-Using \$CC \$CFLAGS with +- CC =$CC +- CFLAGS=$CFLAGS +-the answer is: $doubleformat. +-EOT +- fi +-fi +-case $doubleformat in +- 0) _format='l[0], l[1]';; +- 1) _format='l[1], l[0]';; +- -) _format='not needed (64bit)';; +-esac +-cat < +Date: Wed, 15 Feb 2023 15:22:15 +0100 +Subject: [PATCH 4/5] Do not run get_gmp when cross-compiling + +--- + Configure | 10 +++-- + config/get_gmp | 102 ------------------------------------------------- + 2 files changed, 6 insertions(+), 106 deletions(-) + delete mode 100644 config/get_gmp + +diff --git a/Configure b/Configure +index 6468d04..0481968 100755 +--- a/Configure ++++ b/Configure +@@ -98,10 +98,12 @@ sizeof_long=8 + ####################### CONFIGURE - LIBRARIES ############################### + # Looking for libraries: gmp, X11, fltk, Qt, readline + echo Checking for optional libraries and headers... +-# $_gmp_list +-if test "$kernlvl1" = "gmp"; then +- . ./get_gmp +-fi ++# Set variables like ./get_gmp would (which does not support cross compilation) ++gmp=yes ++GMPLIBS="-L$PREFIX/lib -lgmp" ++GMPINCLUDE= ++kernlvl1=gmp ++. ./get_pretty + # $_graphic_list + . ./get_graphic_lib + # $_readline_list (includes 'readline') +diff --git a/config/get_gmp b/config/get_gmp +deleted file mode 100644 +index 3fd6487..0000000 +--- a/config/get_gmp ++++ /dev/null +@@ -1,102 +0,0 @@ +-#exported variables +-_gmp_list="gmp GMPLIBS GMPINCLUDE" +-gmp= +-case "$with_gmp" in +- yes|"");; +- *) +- if test -z "$with_gmp_lib"; then +- with_gmp_lib="$with_gmp/lib" +- fi +- if test -z "$with_gmp_include"; then +- with_gmp_include="$with_gmp/include" +- fi;; +-esac +- +-pth="$with_gmp_include" +-x=`./locate 'gmp.h' '' $pth` +-case $x in +- ?:/*|/*) gmp_include=`dirname $x` +- echo ..."Found gmp header in $gmp_include" +- GMPINCLUDE="-I$gmp_include" +- ;; +-esac +- +-try() { GMPLIBS=$1; cmd="$cmd0 $1"; . log_cmd; } +- +-exe=$osname-$arch-gmp$$$exe_suff +-cmd0="$CC $CFLAGS $extraflag $GMPINCLUDE -o $exe gmp_version.c" +- +-if test -n "$with_gmp_lib"; then +- gmp=$with_gmp_lib +- try "-L$gmp -lgmp" +-fi +-if test ! -r $exe; then +- try "-lgmp" +-fi +-if test ! -r $exe; then +- lib=gmp; . ./locatelib +- if test -n "$gmp"; then +- try "-L$gmp -lgmp" +- fi +-fi +- +-if test -r $exe; then +- gmp_version=`env LD_LIBRARY_PATH="$LD_LIBRARY_PATH$dir_sep$gmp" $RUNTEST $exe`; +-fi +-case "$gmp_version" in +- unsupported) gmp= +- echo "### Your GMP library ABI is unsupported.";; +- "") gmp= +- cmd="$CC $CFLAGS $extraflag $GMPINCLUDE -o $exe ansi.c $GMPLIBS" +- . log_cmd +- if test -r $exe; then +- echo "### Your version of GMP is too old for PARI. Please upgrade" +- else +- echo "### Your GMP library is incompatible with the compiler settings." +- fi;; +- *) if test -z "$gmp"; then gmp=yes; fi;; +-esac +- +-if test -n "$gmp"; then +- cmd="$CC $CFLAGS $extraflag $GMPINCLUDE -o $exe gmp_mismatch.c $GMPLIBS" +- . log_cmd +- if test ! -r $exe; then +- gmp= +- echo "### GMP headers mismatch: try both --with-gmp-lib and --with-gmp-include" +- fi +-fi +- +-. cleanup_exe +- +-if test -z "$gmp"; then +- echo "### Building without GNU MP support" +-else +- if test "$fastread" = yes; then +- echo "Using GNU MP, version $gmp_version" +- else +- cat << EOM +-========================================================================== +-GNU MP library can be used as an alternate multiprecision kernel, which +-is faster than PARI's native one as soon as integers larger than 10^100 +-are considered. Unfortunately, with GNU MP, libpari is binary incompatible +-with the native one. Despite this, you should only answer 'no' to the +-following question if you plan to use libpari (not only the gp shell) +-and have stringent backward compatibility requirements. +-EOM +- echo $n "Do you want to use GNU MP library instead of the native kernel? $c" +- if test "$with_gmp" = yes; then dflt=y; else dflt=n; fi +- rep='y n'; . ./myread +- case $ans in +- n) gmp=;; +- esac +- fi +-fi +- +-if test -n "$gmp"; then +- kernlvl1=gmp +-else +- kernlvl1=none +- GMPINCLUDE= +- GMPLIBS= +-fi +-. get_pretty +-- +2.39.1 diff --git a/packages/libpari/0005-Do-not-run-get_readline-when-cross-compiling.patch b/packages/libpari/0005-Do-not-run-get_readline-when-cross-compiling.patch new file mode 100644 index 00000000..d7ea2bf6 --- /dev/null +++ b/packages/libpari/0005-Do-not-run-get_readline-when-cross-compiling.patch @@ -0,0 +1,134 @@ +From 8eef5039d1989638ad2d03a9e22204fe5a7216a0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Julian=20R=C3=BCth?= +Date: Wed, 15 Feb 2023 15:22:32 +0100 +Subject: [PATCH 5/5] Do not run get_readline when cross-compiling + +--- + Configure | 10 ++--- + config/get_readline | 94 --------------------------------------------- + 2 files changed, 5 insertions(+), 99 deletions(-) + delete mode 100644 config/get_readline + +diff --git a/Configure b/Configure +index 0481968..e786055 100755 +--- a/Configure ++++ b/Configure +@@ -106,11 +106,11 @@ kernlvl1=gmp + . ./get_pretty + # $_graphic_list + . ./get_graphic_lib +-# $_readline_list (includes 'readline') +-case "$without_readline" in +- yes);; +- *) . ./get_readline +-esac ++# Set variables like ./get_readline would (which does not support cross compilation) ++readline=yes ++readline_version=8.1 # probably does not matter ++RLINCLUDE= ++RLLIBS=-lreadline + ############################################################################# + case $kernlvl1 in + gmp) libpari_base=pari-gmp;; +diff --git a/config/get_readline b/config/get_readline +deleted file mode 100644 +index 2972140..0000000 +--- a/config/get_readline ++++ /dev/null +@@ -1,94 +0,0 @@ +-#exported variables +-_readline_list="readline readline_version RLINCLUDE RLLIBS" +-readline= +-case "$with_readline" in +- yes|"");; +- *) +- if test -z "$with_readline_lib"; then +- with_readline_lib="$with_readline/lib" +- fi +- if test -z "$with_readline_include"; then +- with_readline_include="$with_readline/include" +- fi;; +-esac +- +-pth="$with_readline_include" +-x=`./locate 'readline/readline.h' '' $pth` +-case $x in +- ?:/*|/*) rl_include=`dirname $x` +- echo ..."Found readline header in $rl_include" +- if (echo $rl_include | grep "readline$" > /dev/null); then +- rl_include=`dirname $rl_include` +- RLINCLUDE="-I$rl_include" +- fi +- ;; +-esac +- +-exe=$osname-$arch-rlv$$$exe_suff +-cmd0="$CC $CFLAGS $extraflag $RLINCLUDE -o $exe rl_version.c" +-try() { RLLIBS=$1; cmd="$cmd0 $1"; . log_cmd; } +- +-if test -n "$with_readline_lib"; then +- readline=$with_readline_lib +- rl="-L$readline -lreadline" +-else +- rl="-lreadline" +-fi +- +-# try linking without locatelib (without -L except --with-xxx-lib) +-for tlib in "" tinfow tinfo ncursesw ncurses termcap; do +- t=$rl +- if test -n "$tlib"; then # need a termcap compatible library? +- eval with="\$with_${tlib}_lib" +- if test -n "$with"; then +- t="$t -L$with -l$tlib" +- else +- t="$t -l$tlib" +- fi +- fi +- try "$t" +- if test -r $exe; then break; fi +-done +- +-readline_version= +-if test -r $exe; then +- readline_version=`env LD_LIBRARY_PATH="$LD_LIBRARY_PATH$dir_sep$readline" $RUNTEST $exe`; +-fi +-. cleanup_exe +- +-case "$readline_version" in +-*Editline*|*EditLine*) readline= +- echo "###" +- echo "### Editline wrapper detected, building without readline support" +- echo "###";; +-"") readline= +- echo "###" +- echo "### Readline library does not seem to work. Maybe install libncurses?" +- echo "###";; +-*) if test -z "$readline"; then readline=yes; fi;; +-esac +- +-if test -n "$readline"; then +- if test "$fastread" != yes; then +- cat << EOM +-========================================================================== +-GNU readline provides line editing in the gp shell, with history and +-context-dependent completions. You should really answer 'yes' to the +-following question, unless you are trying to overcome a problem in +-the default build. +-EOM +- echo $n "Do you want to use GNU readline library within GP ? $c" +- rep='y n'; dflt=y; . ./myread +- case $ans in +- n) readline=;; +- esac +- fi +-fi +- +-if test -z "$readline"; then +- echo "### Building without GNU readline support" +- RLLIBS= +- RLINCLUDE= +-else +- echo "Using GNU readline, version $readline_version" +-fi +-- +2.39.1 diff --git a/packages/libpari/meta.yaml b/packages/libpari/meta.yaml new file mode 100644 index 00000000..44a21871 --- /dev/null +++ b/packages/libpari/meta.yaml @@ -0,0 +1,44 @@ +package: + name: libpari + version: 2.15.4 +source: + url: http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-2.15.4.tar.gz + sha256: c3545bfee0c6dfb40b77fb4bbabaf999d82e60069b9f6d28bcb6cf004c8c5c0f + patches: + - 0001-Make-Configure-script-verbose.patch + - 0002-Do-not-run-get_cc-when-cross-compiling.patch + - 0003-Do-not-run-get_double_format-when-cross-compiling.patch + - 0004-Do-not-run-get_gmp-when-cross-compiling.patch + # - 0005-Do-not-run-get_readline-when-cross-compiling.patch + - patches/get_dlcflags.patch + - patches/pari_mainstack.diff +about: + home: http://pari.math.u-bordeaux.fr + summary: + PARI/GP is a widely used computer algebra system designed for fast computations + in number theory + license: GPL-2.0-or-later +requirements: + host: + - libgmp +build: + type: static_library + script: | + export CFLAGS="-fPIC -I${WASM_LIBRARY_DIR}/include" + export PREFIX="${WASM_LIBRARY_DIR}" + emconfigure ./Configure \ + --host=wasm-emscripten \ + --prefix=${WASM_LIBRARY_DIR} \ + --with-gmp=${WASM_LIBRARY_DIR} \ + --with-gmp-include=${WASM_LIBRARY_DIR}/include \ + --with-gmp-lib=${WASM_LIBRARY_DIR}/lib \ + --without-readline \ + --static \ + --mt=pthread \ + --kernel=gmp --graphic=none + cd Oemscripten-wasm + emmake make -j ${PYODIDE_JOBS:-3} gp + emmake make install install-lib-sta +extra: + recipe-maintainers: + - mkoeppe diff --git a/packages/libpari/patches/get_dlcflags.patch b/packages/libpari/patches/get_dlcflags.patch new file mode 100644 index 00000000..65c0cc27 --- /dev/null +++ b/packages/libpari/patches/get_dlcflags.patch @@ -0,0 +1,22 @@ +Add -fno-common to DLCFLAGS on Darwin + +Submitted upstream, but upstream only applied it for PowerPC. Since this +doesn't break anything and only improves performance, add the flag +unconditionally. + +Index: config/get_dlcflags +=================================================================== +--- a/config/get_dlcflags (revision 12594) ++++ b/config/get_dlcflags (working copy) +@@ -2,10 +2,7 @@ + if test -n "$__gnuc__"; then + case $osname in + cygwin|mingw) DLCFLAGS=;; +- darwin) DLCFLAGS=-fPIC +- case $arch in +- ppc|ppc64) DLCFLAGS="$DLCFLAGS -fno-common" +- esac;; ++ darwin) DLCFLAGS="-fPIC -fno-common";; + *) DLCFLAGS=-fPIC;; + esac + else #assume native compiler diff --git a/packages/libpari/patches/pari_mainstack.diff b/packages/libpari/patches/pari_mainstack.diff new file mode 100644 index 00000000..8de6191c --- /dev/null +++ b/packages/libpari/patches/pari_mainstack.diff @@ -0,0 +1,13 @@ +diff --git a/src/language/init.c b/src/language/init.c +index 87ad9b5..f4ca990 100644 +--- a/src/language/init.c ++++ b/src/language/init.c +@@ -102,7 +102,7 @@ entree **varentries; + THREAD long *varpriority; + + THREAD pari_sp avma; +-THREAD struct pari_mainstack *pari_mainstack; ++THREAD struct pari_mainstack *pari_mainstack = NULL; + + static void ** MODULES; + static pari_stack s_MODULES;