Skip to content

Commit c9aeab8

Browse files
committed
add README about sagemath; get pari to build
1 parent 0c83eea commit c9aeab8

File tree

9 files changed

+119
-38
lines changed

9 files changed

+119
-38
lines changed

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ CORE = $(dir $(shell ls core/*/Makefile))
66
PYTHON = $(dir $(shell ls python/*/Makefile))
77
WEB = $(dir $(shell ls web/*/Makefile))
88
DESKTOP = $(dir $(shell ls desktop/*/Makefile))
9+
SAGEMATH = $(dir $(shell ls sagemath/*/Makefile))
910

10-
ALL = ${CORE} ${PYTHON} ${WEB} ${DESKTOP}
11+
ALL = ${CORE} ${PYTHON} ${WEB} ${DESKTOP} ${SAGEMATH}
1112

1213
export PATH := ${CWD}/bin:${CWD}/core/zig/dist:$(PATH)
1314

@@ -86,6 +87,21 @@ clean-desktop:
8687
./bin/make-all clean ${DESKTOP}
8788

8889

90+
# SageMath
91+
92+
.PHONY: sagemath
93+
sagemath:
94+
./bin/make-all all ${SAGEMATH}
95+
96+
.PHONY: test-sagemath
97+
test-sagemath: sagemath
98+
./bin/make-all test ${SAGEMATH}
99+
100+
.PHONY: clean-sagemath
101+
clean-sagemath:
102+
./bin/make-all clean ${SAGEMATH}
103+
104+
89105
# Test
90106

91107
.PHONY: test

README.md

Lines changed: 32 additions & 31 deletions
Large diffs are not rendered by default.

bin/compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python-native
22
import os, subprocess, sys
33

4-
RUN = "npx --yes wasi-js"
4+
RUN = "wasi-js"
55

66
SCRIPT_DIR = r"""SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"""
77

python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ The quick summary is that in each case pypy is twice as fast as pylang \(basical
128128
129129
Email [[email protected]](mailto:[email protected]) or [@wstein389](https://twitter.com/wstein389) if find this interesting and want to help out.
130130
131-
**CoWasm is an open source 3\-clause BSD licensed project. It includes components and dependencies that may be licensed in other ways, but nothing is GPL licensed.**
131+
**CoWasm is an open source 3\-clause BSD licensed project. It includes components and dependencies that may be licensed in other ways, but nothing is GPL licensed,** _**except**_ **some code in the sagemath subdirectory \(which nothing else depends on\).**

sagemath/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Sagemath Component of CoWasm
2+
3+
The goal of the packages in this directory is a full port of
4+
https://www.sagemath.org/ to WebAssembly.
5+
6+
**WARNING:** Unless the rest of CoWasm, there is code in this directory
7+
that is licensed under the GPL. No code in the other packages (core, python, web, etc.,) depends on this code.
8+

sagemath/gmp/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ ${DIST_WASM}/.built: ${BUILD_WASM}/.build
2727
cd ${BUILD_WASM} && make -j4 install
2828
touch ${DIST_WASM}/.built
2929

30+
test:
31+
echo "No GMP tests yet"

sagemath/pari/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ include ../build/Makefile-rules
1313
#GMP_WASM = $(shell cowasm-package-path @cowasm/gmp)
1414
#POSIX_WASM = $(shell cowasm-package-path @cowasm/posix-wasm)
1515

16-
${DIST_WASM}/.built: node_modules ${BUILD_WASM}/.build
16+
${BUILD_WASM}/.patched: ${BUILD_WASM}/.build
17+
cd ${BUILD_WASM} && \
18+
cat ${SRC}/patches/01-pipes.patch | patch -p1
19+
touch ${BUILD_WASM}/.patched
20+
21+
${DIST_WASM}/.built: node_modules ${BUILD_WASM}/.patched
1722
cd ${BUILD_WASM} && \
1823
CC="zcc" \
1924
AR="zig ar" \
@@ -30,4 +35,8 @@ ${DIST_WASM}/.built: node_modules ${BUILD_WASM}/.build
3035
make -j8 AR="zig ar" RANLIB="zig ranlib" gp
3136
cd ${BUILD_WASM}/O* && \
3237
make AR="zig ar" RANLIB="zig ranlib" install
38+
cp ${BUILD_WASM}/O*/gp-sta.wasm ${DIST_WASM}/bin
39+
touch ${DIST_WASM}/.built
3340

41+
test: ${DIST_WASM}/.built
42+
echo "7*17*17" | ./dist/wasm/bin/gp |grep 2023

sagemath/pari/TODO.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
WASM Pari is definitely being built without GMP. This
2-
is making it MUCH MUCH slower.
1+
This is just a very minimal first proof of concept build. It does work though, if you type
2+
3+
```sh
4+
./dist/wasm/bin/gp
5+
```
6+
7+
## [ ] Build dynamically linked
8+
9+
The current build is statically linked, so it can't be run as part of the dash shell.
10+
11+
## [ ] Support Readline (via editline + compat support or hacking)
12+
13+
My understanding is nobody has ever built pari using libedit, so this
14+
could be a little challenging.
15+
16+
## [ ] Support GMP
17+
18+
WASM Pari is definitely being built without GMP right now, since we haven't
19+
even tried. This is making it MUCH MUCH slower.
320

421
Here is how to tell if GMP is being used or not:
22+
523
```sh
624
~/jsage/packages/pari$ make run-wasm</dev/null |grep kernel
725
wasm running wasi (portable C kernel) 32-bit version
@@ -12,4 +30,4 @@ GPRC Done.
1230
amd64 running linux (x86-64/GMP-6.2.1 kernel) 64-bit version
1331
```
1432

15-
Note "portable C kernel" for the wasm version.
33+
Note "portable C kernel" for the wasm version.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
WASM doesn't have popen or pipes, since you can't even create other processes.
2+
So #ifdef UNIX is obviously not enough.
3+
We just patch the use of this to disable
4+
it explicitly. Also the fallback code
5+
returns NULL instead of 0, so we fix that.
6+
7+
8+
--- native/src/language/es.c 2022-10-30 09:07:08
9+
+++ wasm/src/language/es.c 2023-02-02 13:59:56
10+
@@ -3315,6 +3315,8 @@
11+
# define O_RDONLY 0
12+
#endif
13+
14+
+#undef HAVE_PIPES
15+
+
16+
pariFILE *
17+
newfile(FILE *f, const char *name, int type)
18+
{
19+
@@ -4990,7 +4992,7 @@
20+
{
21+
#ifndef HAVE_PIPES
22+
pari_err(e_ARCH,"pipes");
23+
- return NULL;/*LCOV_EXCL_LINE*/
24+
+ return 0; //NULL;/*LCOV_EXCL_LINE*/
25+
#else
26+
FILE *f;
27+
check_secure(s);

0 commit comments

Comments
 (0)