@amritk/nish-aarch64-linux 0.47.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/nish +0 -0
- package/package.json +1 -1
- package/runtime/gfx/README.md +55 -0
- package/runtime/gfx/nish-gfx.c +1063 -0
- package/runtime/gfx/nish-gfx.h +221 -0
- package/runtime/gfx/nish-gfx.overrides.json +14 -0
- package/runtime/nish.d.ts +22 -5
- package/runtime/nish.mjs +1 -0
- package/runtime/runtime-net.c +53 -27
- package/runtime/runtime-uring.c +39 -7
- package/scripts/build.sh +88 -3
- package/std/compress/deflate.ts +1371 -704
- package/std/net/handler.ts +24 -6
- package/std/net/http-server.ts +358 -141
- package/std/net/http1-server.ts +8 -2
- package/std/raster.ts +35 -21
- package/std/synth.ts +9 -1
package/scripts/build.sh
CHANGED
|
@@ -431,6 +431,51 @@ if [ "$async_wanted" = 1 ] && [ -z "$objects_from" ]; then
|
|
|
431
431
|
esac
|
|
432
432
|
done
|
|
433
433
|
fi
|
|
434
|
+
# The graphics shim (runtime/gfx/) is selected by the IR the same way: a module
|
|
435
|
+
# that declares one of its `nishgfx_*` functions gets runtime/gfx/'s units
|
|
436
|
+
# compiled and linked against SDL3 and wgpu-native (`gfx_objects`). Any other
|
|
437
|
+
# program compiles and links none of it, so its link line and binary stay as
|
|
438
|
+
# they were. It is one rule with `callsGfx` in src/run-cache.ts, which keys a
|
|
439
|
+
# run's binary on runtime/gfx/ and the libraries; change both or neither. The
|
|
440
|
+
# libraries are not in the tree: they are read from $NISH_GFX_PREFIX/{include,lib},
|
|
441
|
+
# or from build/gfx/<platform>/, where scripts/fetch-gfx.sh puts them.
|
|
442
|
+
gfx_wanted=0
|
|
443
|
+
if [ ${#lls[@]} -gt 0 ] && grep -Eq '^declare [^"]*@nishgfx_' "${lls[@]}"; then
|
|
444
|
+
gfx_wanted=1
|
|
445
|
+
fi
|
|
446
|
+
gfx_dir=""
|
|
447
|
+
gfx_prefix=""
|
|
448
|
+
if [ "$gfx_wanted" = 1 ]; then
|
|
449
|
+
case "$profile" in
|
|
450
|
+
debug|speed|size) ;;
|
|
451
|
+
*) echo "error: the module calls runtime/gfx/, which the $profile profile cannot link: SDL3 and wgpu-native are native libraries; use the debug, speed or size profile" >&2
|
|
452
|
+
exit 2 ;;
|
|
453
|
+
esac
|
|
454
|
+
gfx_dir="$(cd "$(dirname "$0")/../runtime/gfx" 2>/dev/null && pwd -P)" || gfx_dir=""
|
|
455
|
+
if [ -z "$gfx_dir" ]; then
|
|
456
|
+
echo "error: the module calls runtime/gfx/, and $(dirname "$0")/../runtime/gfx/ is not there" >&2
|
|
457
|
+
exit 2
|
|
458
|
+
fi
|
|
459
|
+
if [ -n "${NISH_GFX_PREFIX:-}" ]; then
|
|
460
|
+
gfx_prefix=$NISH_GFX_PREFIX
|
|
461
|
+
else
|
|
462
|
+
case "$(uname -s)-$(uname -m)" in
|
|
463
|
+
Linux-x86_64) gfx_platform=linux-x86_64 ;;
|
|
464
|
+
Linux-aarch64|Linux-arm64) gfx_platform=linux-aarch64 ;;
|
|
465
|
+
Darwin-x86_64) gfx_platform=macos-x86_64 ;;
|
|
466
|
+
Darwin-arm64) gfx_platform=macos-aarch64 ;;
|
|
467
|
+
*) echo "error: the module calls runtime/gfx/, and scripts/fetch-gfx.sh pins no SDL3 or wgpu-native for $(uname -s)-$(uname -m); set NISH_GFX_PREFIX to an install of both" >&2
|
|
468
|
+
exit 2 ;;
|
|
469
|
+
esac
|
|
470
|
+
gfx_prefix="$(cd "$(dirname "$0")/.." && pwd -P)/build/gfx/$gfx_platform"
|
|
471
|
+
fi
|
|
472
|
+
for need in include/SDL3/SDL.h include/webgpu/webgpu.h include/webgpu/wgpu.h lib/libSDL3.a lib/libwgpu_native.a; do
|
|
473
|
+
if [ ! -f "$gfx_prefix/$need" ]; then
|
|
474
|
+
echo "error: the module calls runtime/gfx/, and $gfx_prefix/$need is not there: run scripts/fetch-gfx.sh, or set NISH_GFX_PREFIX to an install of SDL3 and wgpu-native" >&2
|
|
475
|
+
exit 2
|
|
476
|
+
fi
|
|
477
|
+
done
|
|
478
|
+
fi
|
|
434
479
|
if [ "$sqlite_wanted" = 1 ] && [ -z "$sqlite_dir" ]; then
|
|
435
480
|
echo "error: the module calls SQLite, and $(dirname "$0")/../runtime/sqlite/ is not there" >&2
|
|
436
481
|
exit 2
|
|
@@ -777,6 +822,46 @@ sqlite_objects() {
|
|
|
777
822
|
done < <(sqlite_unit_names)
|
|
778
823
|
}
|
|
779
824
|
|
|
825
|
+
# The units of runtime/gfx/, by name, in the order they are linked.
|
|
826
|
+
gfx_unit_names() {
|
|
827
|
+
(cd -- "$gfx_dir" && for unit in *.c; do [ -f "$unit" ] && printf '%s\n' "$unit"; done)
|
|
828
|
+
}
|
|
829
|
+
# Adds the objects of runtime/gfx/ and the libraries they call to this link.
|
|
830
|
+
# Each unit is compiled into the link's own directory, by its bare name from
|
|
831
|
+
# inside runtime/gfx/ as sqlite_units does, with the flags given less -flto:
|
|
832
|
+
# the shim is a thin layer over two native libraries, so there is nothing for
|
|
833
|
+
# LTO to see through. The libraries are static archives; what else each needs
|
|
834
|
+
# is the system's: on Linux, pthreads and dlopen (SDL opens its Wayland and
|
|
835
|
+
# X11 client libraries at run time) and libm; on macOS, the frameworks SDL's
|
|
836
|
+
# Cocoa driver and wgpu-native's Metal backend call. Nothing is added for a
|
|
837
|
+
# module that does not call runtime/gfx/.
|
|
838
|
+
gfx_libs=()
|
|
839
|
+
gfx_objects() {
|
|
840
|
+
local unit flag
|
|
841
|
+
local -a flags
|
|
842
|
+
[ "$gfx_wanted" = 1 ] || return 0
|
|
843
|
+
make_work
|
|
844
|
+
mkdir -p -- "$work/gfx"
|
|
845
|
+
flags=()
|
|
846
|
+
for flag in "$@"; do
|
|
847
|
+
case "$flag" in -flto) ;; *) flags+=("$flag") ;; esac
|
|
848
|
+
done
|
|
849
|
+
while IFS= read -r unit; do
|
|
850
|
+
(cd -- "$gfx_dir" && exec "$CC" "${flags[@]}" -I. -I"$gfx_prefix/include" -c "$unit" -o "$work/gfx/${unit%.c}.o") ||
|
|
851
|
+
{ echo "error: runtime/gfx/$unit did not compile" >&2; exit 1; }
|
|
852
|
+
inputs+=("$work/gfx/${unit%.c}.o")
|
|
853
|
+
done < <(gfx_unit_names)
|
|
854
|
+
gfx_libs=(-L"$gfx_prefix/lib" -lSDL3 -lwgpu_native)
|
|
855
|
+
case "$(uname -s)" in
|
|
856
|
+
Darwin)
|
|
857
|
+
for flag in Cocoa CoreFoundation CoreVideo Foundation IOKit Carbon Metal QuartzCore; do
|
|
858
|
+
gfx_libs+=(-framework "$flag")
|
|
859
|
+
done
|
|
860
|
+
gfx_libs+=(-weak_framework UniformTypeIdentifiers) ;;
|
|
861
|
+
*) gfx_libs+=(-pthread -ldl) ;;
|
|
862
|
+
esac
|
|
863
|
+
}
|
|
864
|
+
|
|
780
865
|
if [ -n "$sqlite_to" ]; then
|
|
781
866
|
mkdir -p -- "$sqlite_to"
|
|
782
867
|
sqlite_to=$(cd -- "$sqlite_to" && pwd)
|
|
@@ -855,7 +940,7 @@ fi
|
|
|
855
940
|
# under `set -u` is a fatal "unbound variable" -- bash 4.4 made it legal, which is
|
|
856
941
|
# why Linux never noticed. `pgo`, `elf`, `strip_flag` and `libs` are all empty on
|
|
857
942
|
# ordinary builds, so please do not simplify these back.
|
|
858
|
-
case "$profile" in debug|speed|size) sqlite_objects "${compile[@]}" ;; esac
|
|
943
|
+
case "$profile" in debug|speed|size) sqlite_objects "${compile[@]}"; gfx_objects "${compile[@]}" ;; esac
|
|
859
944
|
# A package's own C sources join the inputs here, after the runtime's halves
|
|
860
945
|
# and SQLite were decided from the IR alone, so a source can neither stand in
|
|
861
946
|
# for runtime.c nor be taken for one of its siblings. clang compiles each by
|
|
@@ -868,10 +953,10 @@ if [ ${#link_libs[@]} -gt 0 ] || [ ${#link_sources[@]} -gt 0 ]; then
|
|
|
868
953
|
fi
|
|
869
954
|
case "$profile" in
|
|
870
955
|
debug)
|
|
871
|
-
"$CC" "${common[@]}" "${inputs[@]}" ${link_libs[@]+"${link_libs[@]}"} -lm -o "$out" ;;
|
|
956
|
+
"$CC" "${common[@]}" "${inputs[@]}" ${link_libs[@]+"${link_libs[@]}"} ${gfx_libs[@]+"${gfx_libs[@]}"} -lm -o "$out" ;;
|
|
872
957
|
speed|size)
|
|
873
958
|
"$CC" "${common[@]}" "${optimise[@]}" ${lto_parts[@]+"${lto_parts[@]}"} \
|
|
874
|
-
"${gc[@]}" ${strip_flag[@]+"${strip_flag[@]}"} "${inputs[@]}" ${link_libs[@]+"${link_libs[@]}"} -lm -o "$out" ;;
|
|
959
|
+
"${gc[@]}" ${strip_flag[@]+"${strip_flag[@]}"} "${inputs[@]}" ${link_libs[@]+"${link_libs[@]}"} ${gfx_libs[@]+"${gfx_libs[@]}"} -lm -o "$out" ;;
|
|
875
960
|
wasm|wasm-host)
|
|
876
961
|
# A region's chunks come from malloc, and the freestanding wasm runtime
|
|
877
962
|
# (runtime-wasm.c) has none, so IR that makes or enters one is refused here
|