summaryrefslogtreecommitdiff
path: root/vere/ext/gmp/gen/README.md
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
committerpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
commitfcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch)
tree51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/ext/gmp/gen/README.md
claude is gud
Diffstat (limited to 'vere/ext/gmp/gen/README.md')
-rw-r--r--vere/ext/gmp/gen/README.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/vere/ext/gmp/gen/README.md b/vere/ext/gmp/gen/README.md
new file mode 100644
index 0000000..ebc0bca
--- /dev/null
+++ b/vere/ext/gmp/gen/README.md
@@ -0,0 +1,74 @@
+# Generated architecture specific `.c`, `.s`, and `.h` files
+
+To generate these, first run the `./configure` script under the unpacked GMP dependency directory with the following options:
+
+macOS:
+```terminal
+./configure --with-pic --disable-shared
+```
+
+linux-x86_64:
+```terminal
+./configure --with-pic --disable-shared --host=x86_64-linux-musl
+```
+
+linux-aarch64:
+```terminal
+./configure --with-pic --disable-shared --host=aarch64-linux-musl
+```
+
+windows (from wsl):
+```terminal
+CC_FOR_BUILD=gcc ./configure --host=x86_64-w64-mingw32 --disable-shared
+```
+
+Next, navigate under `mpn/` and run the following to generate the assembly files:
+
+```bash
+for file in $(find . -maxdepth 1 -print | grep "\.asm$"); do
+ filename_no_path="${file#"./"}";
+ filename="${filename_no_path%.*}";
+ echo "m4 -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_${filename} -DPIC $file > ${filename}.s";
+ m4 -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_${filename} -DPIC $file > ${filename}.s;
+done
+```
+
+Next, copy the generated `mpn/*.s` files under the appropriate path, e.g.,
+`aarch64-macos/mpn/.`
+
+Now, under the GMP root dir run `make` and copy these files as well:
+
+- `config.h`
+- `mp_bases.h`
+- `fac_table.h`
+- `fib_table.h`
+- `trialdivtab.h`
+- `sieve_table.h`
+- `mpn/fib_table.c`
+- `mpn/jacobitab.h`
+- `mpn/mp_bases.c`
+- `mpn/perfsqr.h`
+
+e.g.
+```bash
+cp {config.h, mp_bases.h,fac_table.h,fib_table.h,trialdivtab.h,sieve_table.h} aarch64-macos/.
+cp {mpn/fib_table.c,mpn/jacobitab.h,mpn/mp_bases.c,mpn/perfsqr.h} aarch64-macos/mpn/.
+```
+
+## Some additional snippets
+
+### Write the generated assembly file paths into a file `ssources`
+
+```bash
+for file in $(find ./mpn -maxdepth 1 -print | grep "\.s" | sort); do
+ echo $(realpath $file) >> ssources;
+done
+```
+
+### Write the relevant C source file paths into a file `csources`
+
+```bash
+for file in $(find ./mpn -maxdepth 1 -print | grep "\.c" | sort); do
+ echo $(realpath $file) >> csources;
+done
+```