nandi/clonimpublic Fork
⑂ a52696f
Commits
⬇ Clone ▾
git clone https://git.rickub.com/nandi/clonim.git
git clone ssh://git@rickub.com/nandi/clonim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

release: publish compiler and static runtime

nandithebull committed 2026-09-20T22:17:26-07:00 Browse files
a52696f parent: 0c2e37c
modified .github/workflows/release.yml +13 -22
@@ -69,35 +69,24 @@ jobs:
6969 nim c -d:release --app:staticlib --nimMainPrefix:ClonimRuntime \
7070 --hints:off --warnings:off --nimcache:lib/nimcache-release \
7171 -o:lib/libclonim_runtime.a src/runtime_lib.nim
72- nim c -d:release --hints:off --warnings:off \
72+ nim c -d:release -d:releaseCompiler --hints:off --warnings:off \
7373 -o:bin/clonim src/clonim.nim
7474
7575 - name: Package release
76- env:
77- ARCHIVE_ROOT: clonim-linux-x86_64
7876 run: |
79- install -Dm755 bin/clonim "dist/$ARCHIVE_ROOT/bin/clonim"
80- install -Dm644 lib/libclonim_runtime.a \
81- "dist/$ARCHIVE_ROOT/lib/libclonim_runtime.a"
82- install -Dm644 lib/libclonim_runtime_debug.a \
83- "dist/$ARCHIVE_ROOT/lib/libclonim_runtime_debug.a"
84- install -Dm644 src/app_runtime.nim \
85- "dist/$ARCHIVE_ROOT/src/app_runtime.nim"
86- install -Dm644 src/runtime_types.nim \
87- "dist/$ARCHIVE_ROOT/src/runtime_types.nim"
88- cp -R stdlib "dist/$ARCHIVE_ROOT/stdlib"
89- cp README.md "dist/$ARCHIVE_ROOT/README.md"
90- tar -C dist -czf "dist/$ARCHIVE_ROOT.tar.gz" "$ARCHIVE_ROOT"
77+ install -Dm755 bin/clonim dist/clonim-linux-x86_64
78+ install -Dm644 lib/libclonim_runtime.a dist/libclonim_runtime.a
9179 cd dist
92- sha256sum "$ARCHIVE_ROOT.tar.gz" > "$ARCHIVE_ROOT.tar.gz.sha256"
80+ sha256sum clonim-linux-x86_64 libclonim_runtime.a > SHA256SUMS
9381
9482 - name: Upload workflow artifact
9583 uses: actions/upload-artifact@v4
9684 with:
9785 name: clonim-${{ steps.release.outputs.tag }}-linux-x86_64
9886 path: |
99- dist/clonim-linux-x86_64.tar.gz
100- dist/clonim-linux-x86_64.tar.gz.sha256
87+ dist/clonim-linux-x86_64
88+ dist/libclonim_runtime.a
89+ dist/SHA256SUMS
10190 if-no-files-found: error
10291 retention-days: 90
10392
@@ -109,11 +98,13 @@ jobs:
10998 body: |
11099 Linux x86_64 release of clonim.
111100
112- The archive contains the compiler, its matched private static
113- runtime archives, runtime interface, and clonim standard library.
101+ Download `clonim-linux-x86_64` and `libclonim_runtime.a` into the
102+ same directory. Generated programs statically link the runtime and
103+ are standalone. Nim must be installed as the native-code backend.
114104 draft: false
115105 prerelease: false
116106 files: |
117- dist/clonim-linux-x86_64.tar.gz
118- dist/clonim-linux-x86_64.tar.gz.sha256
107+ dist/clonim-linux-x86_64
108+ dist/libclonim_runtime.a
109+ dist/SHA256SUMS
119110 fail_on_unmatched_files: true
@@ -69,35 +69,24 @@ jobs:
69 nim c -d:release --app:staticlib --nimMainPrefix:ClonimRuntime \69 nim c -d:release --app:staticlib --nimMainPrefix:ClonimRuntime \
70 --hints:off --warnings:off --nimcache:lib/nimcache-release \70 --hints:off --warnings:off --nimcache:lib/nimcache-release \
71 -o:lib/libclonim_runtime.a src/runtime_lib.nim71 -o:lib/libclonim_runtime.a src/runtime_lib.nim
72- nim c -d:release --hints:off --warnings:off \72+ nim c -d:release -d:releaseCompiler --hints:off --warnings:off \
73 -o:bin/clonim src/clonim.nim73 -o:bin/clonim src/clonim.nim
74 74
75 - name: Package release75 - name: Package release
76- env:
77- ARCHIVE_ROOT: clonim-linux-x86_64
78 run: |76 run: |
79- install -Dm755 bin/clonim "dist/$ARCHIVE_ROOT/bin/clonim"77+ install -Dm755 bin/clonim dist/clonim-linux-x86_64
80- install -Dm644 lib/libclonim_runtime.a \78+ install -Dm644 lib/libclonim_runtime.a dist/libclonim_runtime.a
81- "dist/$ARCHIVE_ROOT/lib/libclonim_runtime.a"
82- install -Dm644 lib/libclonim_runtime_debug.a \
83- "dist/$ARCHIVE_ROOT/lib/libclonim_runtime_debug.a"
84- install -Dm644 src/app_runtime.nim \
85- "dist/$ARCHIVE_ROOT/src/app_runtime.nim"
86- install -Dm644 src/runtime_types.nim \
87- "dist/$ARCHIVE_ROOT/src/runtime_types.nim"
88- cp -R stdlib "dist/$ARCHIVE_ROOT/stdlib"
89- cp README.md "dist/$ARCHIVE_ROOT/README.md"
90- tar -C dist -czf "dist/$ARCHIVE_ROOT.tar.gz" "$ARCHIVE_ROOT"
91 cd dist79 cd dist
92- sha256sum "$ARCHIVE_ROOT.tar.gz" > "$ARCHIVE_ROOT.tar.gz.sha256"80+ sha256sum clonim-linux-x86_64 libclonim_runtime.a > SHA256SUMS
93 81
94 - name: Upload workflow artifact82 - name: Upload workflow artifact
95 uses: actions/upload-artifact@v483 uses: actions/upload-artifact@v4
96 with:84 with:
97 name: clonim-${{ steps.release.outputs.tag }}-linux-x86_6485 name: clonim-${{ steps.release.outputs.tag }}-linux-x86_64
98 path: |86 path: |
99- dist/clonim-linux-x86_64.tar.gz87+ dist/clonim-linux-x86_64
100- dist/clonim-linux-x86_64.tar.gz.sha25688+ dist/libclonim_runtime.a
89+ dist/SHA256SUMS
101 if-no-files-found: error90 if-no-files-found: error
102 retention-days: 9091 retention-days: 90
103 92
@@ -109,11 +98,13 @@ jobs:
109 body: |98 body: |
110 Linux x86_64 release of clonim.99 Linux x86_64 release of clonim.
111 100
112- The archive contains the compiler, its matched private static101+ Download `clonim-linux-x86_64` and `libclonim_runtime.a` into the
113- runtime archives, runtime interface, and clonim standard library.102+ same directory. Generated programs statically link the runtime and
103+ are standalone. Nim must be installed as the native-code backend.
114 draft: false104 draft: false
115 prerelease: false105 prerelease: false
116 files: |106 files: |
117- dist/clonim-linux-x86_64.tar.gz107+ dist/clonim-linux-x86_64
118- dist/clonim-linux-x86_64.tar.gz.sha256108+ dist/libclonim_runtime.a
109+ dist/SHA256SUMS
119 fail_on_unmatched_files: true110 fail_on_unmatched_files: true
modified README.md +6 -7
@@ -23,13 +23,12 @@ and flags slowdowns above 10% versus the latest compatible run. Requires Jolt
2323 and a clean working tree. Use `just bench-store 15` to change the threshold;
2424 see [benchmark history](bench/README.md) for metrics and exit codes.
2525
26-`just release` also builds clonim's private static runtime archives. Generated
27-programs link the matching debug or release archive, so their finished binaries
28-are standalone. Version tags matching `v*` trigger the release workflow, which
29-runs the test suite and publishes a Linux x86_64 bundle plus its SHA-256 file to
30-GitHub Releases. The bundle contains the compiler, both internal runtime
31-archives, their small Nim interface, and the clonim source-level standard
32-library; users still need Nim installed as the native-code backend.
26+`just release` builds the compiler and its private static runtime. Version tags
27+matching `v*` trigger the release workflow, which publishes the Linux x86_64
28+compiler and `libclonim_runtime.a` as individual assets (plus `SHA256SUMS`). Put
29+the compiler and archive in the same directory. Generated programs statically
30+link the runtime and are standalone; users still need Nim installed as the
31+native-code backend.
3332
3433 Source-level libraries are loaded explicitly. Use
3534 `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for
@@ -23,13 +23,12 @@ and flags slowdowns above 10% versus the latest compatible run. Requires Jolt
23 and a clean working tree. Use `just bench-store 15` to change the threshold;23 and a clean working tree. Use `just bench-store 15` to change the threshold;
24 see [benchmark history](bench/README.md) for metrics and exit codes.24 see [benchmark history](bench/README.md) for metrics and exit codes.
25 25
26-`just release` also builds clonim's private static runtime archives. Generated26+`just release` builds the compiler and its private static runtime. Version tags
27-programs link the matching debug or release archive, so their finished binaries27+matching `v*` trigger the release workflow, which publishes the Linux x86_64
28-are standalone. Version tags matching `v*` trigger the release workflow, which28+compiler and `libclonim_runtime.a` as individual assets (plus `SHA256SUMS`). Put
29-runs the test suite and publishes a Linux x86_64 bundle plus its SHA-256 file to29+the compiler and archive in the same directory. Generated programs statically
30-GitHub Releases. The bundle contains the compiler, both internal runtime30+link the runtime and are standalone; users still need Nim installed as the
31-archives, their small Nim interface, and the clonim source-level standard31+native-code backend.
32-library; users still need Nim installed as the native-code backend.
33 32
34 Source-level libraries are loaded explicitly. Use33 Source-level libraries are loaded explicitly. Use
35 `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for34 `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for
modified justfile +1 -1
@@ -14,7 +14,7 @@ runtime-libs:
1414
1515 # Build with optimisations on (compiler and, via -d:release, the programs it emits)
1616 release: runtime-libs
17- nim c -d:release --hints:off --warnings:off -o:{{bin}} src/clonim.nim
17+ nim c -d:release -d:releaseCompiler --hints:off --warnings:off -o:{{bin}} src/clonim.nim
1818
1919 # Run every example against tests/<name>.expected
2020 test: build
@@ -14,7 +14,7 @@ runtime-libs:
14 14
15 # Build with optimisations on (compiler and, via -d:release, the programs it emits)15 # Build with optimisations on (compiler and, via -d:release, the programs it emits)
16 release: runtime-libs16 release: runtime-libs
17- nim c -d:release --hints:off --warnings:off -o:{{bin}} src/clonim.nim17+ nim c -d:release -d:releaseCompiler --hints:off --warnings:off -o:{{bin}} src/clonim.nim
18 18
19 # Run every example against tests/<name>.expected19 # Run every example against tests/<name>.expected
20 test: build20 test: build
modified src/clonim.nim +34 -0
@@ -6,6 +6,29 @@
66 import std/[hashes, os, osproc, sequtils, strutils, times]
77 import runtime, compiler
88
9+when defined(releaseCompiler):
10+ const
11+ EmbeddedAppRuntime = staticRead("app_runtime.nim")
12+ EmbeddedRuntimeTypes = staticRead("runtime_types.nim")
13+ EmbeddedCoreStdlib = staticRead("../stdlib/clonim/core.clj")
14+
15+ proc embeddedRoot(): string =
16+ ## Materialize the compiler-only inputs under a content-keyed cache. The
17+ ## runtime implementation remains the separately shipped static archive.
18+ var h: Hash = hash(EmbeddedAppRuntime)
19+ h = h !& hash(EmbeddedRuntimeTypes)
20+ h = h !& hash(EmbeddedCoreStdlib)
21+ result = getTempDir() / "clonim-runtime" / $(!$h)
22+ let files = [
23+ (result / "src" / "app_runtime.nim", EmbeddedAppRuntime),
24+ (result / "src" / "runtime_types.nim", EmbeddedRuntimeTypes),
25+ (result / "stdlib" / "clonim" / "core.clj", EmbeddedCoreStdlib),
26+ ]
27+ for (path, contents) in files:
28+ createDir(path.parentDir)
29+ if not fileExists(path) or getFileSize(path) != contents.len:
30+ writeFile(path, contents)
31+
932 proc usage() =
1033 echo """clonim — a Clojure compiler hosted on Nim
1134
@@ -23,6 +46,8 @@ options:
2346
2447 proc srcDir(): string =
2548 ## Where generated programs find the private runtime interface.
49+ when defined(releaseCompiler):
50+ return embeddedRoot() / "src"
2651 for cand in [getAppDir(), getAppDir().parentDir / "src",
2752 getAppDir().parentDir.parentDir / "src"]:
2853 if fileExists(cand / "app_runtime.nim"): return cand
@@ -31,6 +56,11 @@ proc srcDir(): string =
3156 proc runtimeLib(release: bool): string =
3257 ## Release archives place the private runtime beside bin/. A source checkout
3358 ## builds the same archive into lib/ on first use.
59+ when defined(releaseCompiler):
60+ let shipped = getAppDir() / "libclonim_runtime.a"
61+ if fileExists(shipped): return shipped
62+ raise newException(IOError,
63+ "missing runtime library beside compiler: " & shipped)
3464 let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a")
3565 let installed = getAppDir().parentDir / "lib" / libName
3666 let source = srcDir() / "runtime_lib.nim"
@@ -83,6 +113,10 @@ proc main() =
83113 var outBin = ""
84114 var verbose = false
85115 var release = cmd == "build"
116+ when defined(releaseCompiler):
117+ # The distributed compiler ships one release-mode runtime archive. Nim's
118+ # debug and release modes are not ABI-compatible, so `run` uses it too.
119+ release = true
86120 var sourceRoots: seq[string] = @[]
87121 var i = 2
88122 while i < argv.len:
@@ -6,6 +6,29 @@
6 import std/[hashes, os, osproc, sequtils, strutils, times]6 import std/[hashes, os, osproc, sequtils, strutils, times]
7 import runtime, compiler7 import runtime, compiler
8 8
9+when defined(releaseCompiler):
10+ const
11+ EmbeddedAppRuntime = staticRead("app_runtime.nim")
12+ EmbeddedRuntimeTypes = staticRead("runtime_types.nim")
13+ EmbeddedCoreStdlib = staticRead("../stdlib/clonim/core.clj")
14+
15+ proc embeddedRoot(): string =
16+ ## Materialize the compiler-only inputs under a content-keyed cache. The
17+ ## runtime implementation remains the separately shipped static archive.
18+ var h: Hash = hash(EmbeddedAppRuntime)
19+ h = h !& hash(EmbeddedRuntimeTypes)
20+ h = h !& hash(EmbeddedCoreStdlib)
21+ result = getTempDir() / "clonim-runtime" / $(!$h)
22+ let files = [
23+ (result / "src" / "app_runtime.nim", EmbeddedAppRuntime),
24+ (result / "src" / "runtime_types.nim", EmbeddedRuntimeTypes),
25+ (result / "stdlib" / "clonim" / "core.clj", EmbeddedCoreStdlib),
26+ ]
27+ for (path, contents) in files:
28+ createDir(path.parentDir)
29+ if not fileExists(path) or getFileSize(path) != contents.len:
30+ writeFile(path, contents)
31+
9 proc usage() =32 proc usage() =
10 echo """clonim — a Clojure compiler hosted on Nim33 echo """clonim — a Clojure compiler hosted on Nim
11 34
@@ -23,6 +46,8 @@ options:
23 46
24 proc srcDir(): string =47 proc srcDir(): string =
25 ## Where generated programs find the private runtime interface.48 ## Where generated programs find the private runtime interface.
49+ when defined(releaseCompiler):
50+ return embeddedRoot() / "src"
26 for cand in [getAppDir(), getAppDir().parentDir / "src",51 for cand in [getAppDir(), getAppDir().parentDir / "src",
27 getAppDir().parentDir.parentDir / "src"]:52 getAppDir().parentDir.parentDir / "src"]:
28 if fileExists(cand / "app_runtime.nim"): return cand53 if fileExists(cand / "app_runtime.nim"): return cand
@@ -31,6 +56,11 @@ proc srcDir(): string =
31 proc runtimeLib(release: bool): string =56 proc runtimeLib(release: bool): string =
32 ## Release archives place the private runtime beside bin/. A source checkout57 ## Release archives place the private runtime beside bin/. A source checkout
33 ## builds the same archive into lib/ on first use.58 ## builds the same archive into lib/ on first use.
59+ when defined(releaseCompiler):
60+ let shipped = getAppDir() / "libclonim_runtime.a"
61+ if fileExists(shipped): return shipped
62+ raise newException(IOError,
63+ "missing runtime library beside compiler: " & shipped)
34 let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a")64 let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a")
35 let installed = getAppDir().parentDir / "lib" / libName65 let installed = getAppDir().parentDir / "lib" / libName
36 let source = srcDir() / "runtime_lib.nim"66 let source = srcDir() / "runtime_lib.nim"
@@ -83,6 +113,10 @@ proc main() =
83 var outBin = ""113 var outBin = ""
84 var verbose = false114 var verbose = false
85 var release = cmd == "build"115 var release = cmd == "build"
116+ when defined(releaseCompiler):
117+ # The distributed compiler ships one release-mode runtime archive. Nim's
118+ # debug and release modes are not ABI-compatible, so `run` uses it too.
119+ release = true
86 var sourceRoots: seq[string] = @[]120 var sourceRoots: seq[string] = @[]
87 var i = 2121 var i = 2
88 while i < argv.len:122 while i < argv.len: