release: bundle Zig C toolchain
2ee9b31 parent: a146865 modified
.github/workflows/release.yml +15 -12 | @@ -67,13 +67,6 @@ jobs: | ||
| 67 | 67 | |
| 68 | 68 | - name: Build optimized compiler |
| 69 | 69 | run: | |
| 70 | - mkdir -p lib | |
| 71 | - nim c --app:staticlib --nimMainPrefix:ClonimRuntime \ | |
| 72 | - --hints:off --warnings:off --nimcache:lib/nimcache-debug \ | |
| 73 | - -o:lib/libclonim_runtime_debug.a src/runtime_lib.nim | |
| 74 | - nim c -d:release --app:staticlib --nimMainPrefix:ClonimRuntime \ | |
| 75 | - --hints:off --warnings:off --nimcache:lib/nimcache-release \ | |
| 76 | - -o:lib/libclonim_runtime.a src/runtime_lib.nim | |
| 77 | 70 | nim c -d:release -d:releaseCompiler --hints:off --warnings:off \ |
| 78 | 71 | -o:bin/clonim src/clonim.nim |
| 79 | 72 | |
| @@ -81,13 +74,23 @@ jobs: | ||
| 81 | 74 | run: | |
| 82 | 75 | appdir=dist/clonim.AppDir |
| 83 | 76 | install -Dm755 bin/clonim "$appdir/usr/bin/clonim" |
| 84 | - install -Dm644 lib/libclonim_runtime.a \ | |
| 85 | - "$appdir/usr/bin/libclonim_runtime.a" | |
| 86 | 77 | nim_bin=$(readlink -f "$(command -v nim)") |
| 87 | 78 | nim_root=$(dirname "$(dirname "$nim_bin")") |
| 88 | 79 | install -Dm755 "$nim_bin" "$appdir/usr/bin/nim" |
| 89 | 80 | cp -a "$nim_root/lib/." "$appdir/usr/lib/" |
| 90 | 81 | cp -a "$nim_root/config" "$appdir/usr/config" |
| 82 | + install -Dm755 packaging/appimage/gcc "$appdir/usr/bin/gcc" | |
| 83 | + ln -s gcc "$appdir/usr/bin/cc" | |
| 84 | + | |
| 85 | + curl --fail --location --silent --show-error \ | |
| 86 | + https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz \ | |
| 87 | + -o /tmp/zig-x86_64-linux-0.15.2.tar.xz | |
| 88 | + echo "02aa270f183da276e5b5920b1dac44a63f1a49e55050ebde3aecc9eb82f93239 /tmp/zig-x86_64-linux-0.15.2.tar.xz" \ | |
| 89 | + | sha256sum --check | |
| 90 | + mkdir -p "$appdir/usr/lib/zig" | |
| 91 | + tar --extract --xz --file /tmp/zig-x86_64-linux-0.15.2.tar.xz \ | |
| 92 | + --strip-components=1 --directory "$appdir/usr/lib/zig" | |
| 93 | + | |
| 91 | 94 | install -Dm755 packaging/appimage/AppRun "$appdir/AppRun" |
| 92 | 95 | install -Dm644 packaging/appimage/clonim.desktop \ |
| 93 | 96 | "$appdir/clonim.desktop" |
| @@ -121,9 +124,9 @@ jobs: | ||
| 121 | 124 | Linux x86_64 release of clonim. |
| 122 | 125 | |
| 123 | 126 | Download the AppImage, make it executable, and run it. It contains |
| 124 | - the compiler, Nim 2.2.12, and clonim's private static runtime. | |
| 125 | - Generated programs statically link the runtime and are standalone. | |
| 126 | - A system C compiler and linker are required to build programs. | |
| 127 | + clonim, Nim 2.2.12, Zig 0.15.2 as its C compiler/linker, and clonim's | |
| 128 | + private static runtime. It has no external build dependencies, and | |
| 129 | + generated programs statically link the clonim runtime. | |
| 127 | 130 | draft: false |
| 128 | 131 | prerelease: false |
| 129 | 132 | files: dist/clonim-linux-x86_64.AppImage |
| @@ -67,13 +67,6 @@ jobs: | |||
| 67 | 67 | ||
| 68 | - name: Build optimized compiler | 68 | - name: Build optimized compiler |
| 69 | run: | | 69 | run: | |
| 70 | - mkdir -p lib | ||
| 71 | - nim c --app:staticlib --nimMainPrefix:ClonimRuntime \ | ||
| 72 | - --hints:off --warnings:off --nimcache:lib/nimcache-debug \ | ||
| 73 | - -o:lib/libclonim_runtime_debug.a src/runtime_lib.nim | ||
| 74 | - nim c -d:release --app:staticlib --nimMainPrefix:ClonimRuntime \ | ||
| 75 | - --hints:off --warnings:off --nimcache:lib/nimcache-release \ | ||
| 76 | - -o:lib/libclonim_runtime.a src/runtime_lib.nim | ||
| 77 | nim c -d:release -d:releaseCompiler --hints:off --warnings:off \ | 70 | nim c -d:release -d:releaseCompiler --hints:off --warnings:off \ |
| 78 | -o:bin/clonim src/clonim.nim | 71 | -o:bin/clonim src/clonim.nim |
| 79 | 72 | ||
| @@ -81,13 +74,23 @@ jobs: | |||
| 81 | run: | | 74 | run: | |
| 82 | appdir=dist/clonim.AppDir | 75 | appdir=dist/clonim.AppDir |
| 83 | install -Dm755 bin/clonim "$appdir/usr/bin/clonim" | 76 | install -Dm755 bin/clonim "$appdir/usr/bin/clonim" |
| 84 | - install -Dm644 lib/libclonim_runtime.a \ | ||
| 85 | - "$appdir/usr/bin/libclonim_runtime.a" | ||
| 86 | nim_bin=$(readlink -f "$(command -v nim)") | 77 | nim_bin=$(readlink -f "$(command -v nim)") |
| 87 | nim_root=$(dirname "$(dirname "$nim_bin")") | 78 | nim_root=$(dirname "$(dirname "$nim_bin")") |
| 88 | install -Dm755 "$nim_bin" "$appdir/usr/bin/nim" | 79 | install -Dm755 "$nim_bin" "$appdir/usr/bin/nim" |
| 89 | cp -a "$nim_root/lib/." "$appdir/usr/lib/" | 80 | cp -a "$nim_root/lib/." "$appdir/usr/lib/" |
| 90 | cp -a "$nim_root/config" "$appdir/usr/config" | 81 | cp -a "$nim_root/config" "$appdir/usr/config" |
| 82 | + install -Dm755 packaging/appimage/gcc "$appdir/usr/bin/gcc" | ||
| 83 | + ln -s gcc "$appdir/usr/bin/cc" | ||
| 84 | + | ||
| 85 | + curl --fail --location --silent --show-error \ | ||
| 86 | + https://ziglang.org/download/0.15.2/zig-x86_64-linux-0.15.2.tar.xz \ | ||
| 87 | + -o /tmp/zig-x86_64-linux-0.15.2.tar.xz | ||
| 88 | + echo "02aa270f183da276e5b5920b1dac44a63f1a49e55050ebde3aecc9eb82f93239 /tmp/zig-x86_64-linux-0.15.2.tar.xz" \ | ||
| 89 | + | sha256sum --check | ||
| 90 | + mkdir -p "$appdir/usr/lib/zig" | ||
| 91 | + tar --extract --xz --file /tmp/zig-x86_64-linux-0.15.2.tar.xz \ | ||
| 92 | + --strip-components=1 --directory "$appdir/usr/lib/zig" | ||
| 93 | + | ||
| 91 | install -Dm755 packaging/appimage/AppRun "$appdir/AppRun" | 94 | install -Dm755 packaging/appimage/AppRun "$appdir/AppRun" |
| 92 | install -Dm644 packaging/appimage/clonim.desktop \ | 95 | install -Dm644 packaging/appimage/clonim.desktop \ |
| 93 | "$appdir/clonim.desktop" | 96 | "$appdir/clonim.desktop" |
| @@ -121,9 +124,9 @@ jobs: | |||
| 121 | Linux x86_64 release of clonim. | 124 | Linux x86_64 release of clonim. |
| 122 | 125 | ||
| 123 | Download the AppImage, make it executable, and run it. It contains | 126 | Download the AppImage, make it executable, and run it. It contains |
| 124 | - the compiler, Nim 2.2.12, and clonim's private static runtime. | 127 | + clonim, Nim 2.2.12, Zig 0.15.2 as its C compiler/linker, and clonim's |
| 125 | - Generated programs statically link the runtime and are standalone. | 128 | + private static runtime. It has no external build dependencies, and |
| 126 | - A system C compiler and linker are required to build programs. | 129 | + generated programs statically link the clonim runtime. |
| 127 | draft: false | 130 | draft: false |
| 128 | prerelease: false | 131 | prerelease: false |
| 129 | files: dist/clonim-linux-x86_64.AppImage | 132 | files: dist/clonim-linux-x86_64.AppImage |
modified
README.md +3 -3 | @@ -25,9 +25,9 @@ see [benchmark history](bench/README.md) for metrics and exit codes. | ||
| 25 | 25 | |
| 26 | 26 | `just release` builds the compiler and its private static runtime. Version tags |
| 27 | 27 | matching `v*` trigger the release workflow, which packages both into a single |
| 28 | -Linux x86_64 AppImage together with Nim 2.2.12. Generated programs statically | |
| 29 | -link the runtime and are standalone. The build machine needs a system C | |
| 30 | -compiler and linker, but does not need Nim installed separately. | |
| 28 | +Linux x86_64 AppImage together with Nim 2.2.12 and Zig 0.15.2 as the private C | |
| 29 | +compiler/linker. The AppImage has no external build dependencies. Generated | |
| 30 | +programs statically link the clonim runtime and are standalone. | |
| 31 | 31 | |
| 32 | 32 | Source-level libraries are loaded explicitly. Use |
| 33 | 33 | `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for |
| @@ -25,9 +25,9 @@ see [benchmark history](bench/README.md) for metrics and exit codes. | |||
| 25 | 25 | ||
| 26 | `just release` builds the compiler and its private static runtime. Version tags | 26 | `just release` builds the compiler and its private static runtime. Version tags |
| 27 | matching `v*` trigger the release workflow, which packages both into a single | 27 | matching `v*` trigger the release workflow, which packages both into a single |
| 28 | -Linux x86_64 AppImage together with Nim 2.2.12. Generated programs statically | 28 | +Linux x86_64 AppImage together with Nim 2.2.12 and Zig 0.15.2 as the private C |
| 29 | -link the runtime and are standalone. The build machine needs a system C | 29 | +compiler/linker. The AppImage has no external build dependencies. Generated |
| 30 | -compiler and linker, but does not need Nim installed separately. | 30 | +programs statically link the clonim runtime and are standalone. |
| 31 | 31 | ||
| 32 | Source-level libraries are loaded explicitly. Use | 32 | Source-level libraries are loaded explicitly. Use |
| 33 | `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for | 33 | `(require '[clonim.core :refer [now-ms]])` to load `stdlib/clonim/core.clj`. Host-dependent operations remain small runtime primitives; for |
added
packaging/appimage/gcc +11 -0 | new file mode 100755 | ||
| @@ -0,0 +1,11 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | +set -eu | |
| 3 | + | |
| 4 | +zig_root=$(CDPATH= cd -- "$(dirname -- "$0")/../lib/zig" && pwd) | |
| 5 | +cache_root=${XDG_CACHE_HOME:-${TMPDIR:-/tmp}} | |
| 6 | +ZIG_GLOBAL_CACHE_DIR="$cache_root/clonim-zig/global" | |
| 7 | +ZIG_LOCAL_CACHE_DIR="$cache_root/clonim-zig/local" | |
| 8 | +export ZIG_GLOBAL_CACHE_DIR ZIG_LOCAL_CACHE_DIR | |
| 9 | +mkdir -p "$ZIG_GLOBAL_CACHE_DIR" "$ZIG_LOCAL_CACHE_DIR" | |
| 10 | + | |
| 11 | +exec "$zig_root/zig" cc -target x86_64-linux-gnu "$@" | |
| new file mode 100755 | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | +#!/bin/sh | ||
| 2 | +set -eu | ||
| 3 | + | ||
| 4 | +zig_root=$(CDPATH= cd -- "$(dirname -- "$0")/../lib/zig" && pwd) | ||
| 5 | +cache_root=${XDG_CACHE_HOME:-${TMPDIR:-/tmp}} | ||
| 6 | +ZIG_GLOBAL_CACHE_DIR="$cache_root/clonim-zig/global" | ||
| 7 | +ZIG_LOCAL_CACHE_DIR="$cache_root/clonim-zig/local" | ||
| 8 | +export ZIG_GLOBAL_CACHE_DIR ZIG_LOCAL_CACHE_DIR | ||
| 9 | +mkdir -p "$ZIG_GLOBAL_CACHE_DIR" "$ZIG_LOCAL_CACHE_DIR" | ||
| 10 | + | ||
| 11 | +exec "$zig_root/zig" cc -target x86_64-linux-gnu "$@" | ||
added
src/app_runtime_source.nim +7 -0 | new file mode 100644 | ||
| @@ -0,0 +1,7 @@ | ||
| 1 | +## Private source interface used by the self-contained release compiler. | |
| 2 | +## Nim compiles these modules together with the generated program, avoiding a | |
| 3 | +## second copy of Nim's support runtime while keeping the result standalone. | |
| 4 | +import runtime, core, namespaces | |
| 5 | +export runtime, core, namespaces | |
| 6 | + | |
| 7 | +proc initClonimRuntime*() = discard | |
| new file mode 100644 | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | +## Private source interface used by the self-contained release compiler. | ||
| 2 | +## Nim compiles these modules together with the generated program, avoiding a | ||
| 3 | +## second copy of Nim's support runtime while keeping the result standalone. | ||
| 4 | +import runtime, core, namespaces | ||
| 5 | +export runtime, core, namespaces | ||
| 6 | + | ||
| 7 | +proc initClonimRuntime*() = discard | ||
modified
src/clonim.nim +25 -14 | @@ -8,8 +8,12 @@ import runtime, compiler | ||
| 8 | 8 | |
| 9 | 9 | when defined(releaseCompiler): |
| 10 | 10 | const |
| 11 | - EmbeddedAppRuntime = staticRead("app_runtime.nim") | |
| 11 | + EmbeddedAppRuntime = staticRead("app_runtime_source.nim") | |
| 12 | 12 | EmbeddedRuntimeTypes = staticRead("runtime_types.nim") |
| 13 | + EmbeddedRuntime = staticRead("runtime.nim") | |
| 14 | + EmbeddedCore = staticRead("core.nim") | |
| 15 | + EmbeddedNamespaces = staticRead("namespaces.nim") | |
| 16 | + EmbeddedReader = staticRead("reader.nim") | |
| 13 | 17 | EmbeddedCoreStdlib = staticRead("../stdlib/clonim/core.clj") |
| 14 | 18 | |
| 15 | 19 | proc embeddedRoot(): string = |
| @@ -17,16 +21,24 @@ when defined(releaseCompiler): | ||
| 17 | 21 | ## runtime implementation remains the separately shipped static archive. |
| 18 | 22 | var h: Hash = hash(EmbeddedAppRuntime) |
| 19 | 23 | h = h !& hash(EmbeddedRuntimeTypes) |
| 24 | + h = h !& hash(EmbeddedRuntime) | |
| 25 | + h = h !& hash(EmbeddedCore) | |
| 26 | + h = h !& hash(EmbeddedNamespaces) | |
| 27 | + h = h !& hash(EmbeddedReader) | |
| 20 | 28 | h = h !& hash(EmbeddedCoreStdlib) |
| 21 | 29 | result = getTempDir() / "clonim-runtime" / $(!$h) |
| 22 | 30 | let files = [ |
| 23 | 31 | (result / "src" / "app_runtime.nim", EmbeddedAppRuntime), |
| 24 | 32 | (result / "src" / "runtime_types.nim", EmbeddedRuntimeTypes), |
| 33 | + (result / "src" / "runtime.nim", EmbeddedRuntime), | |
| 34 | + (result / "src" / "core.nim", EmbeddedCore), | |
| 35 | + (result / "src" / "namespaces.nim", EmbeddedNamespaces), | |
| 36 | + (result / "src" / "reader.nim", EmbeddedReader), | |
| 25 | 37 | (result / "stdlib" / "clonim" / "core.clj", EmbeddedCoreStdlib), |
| 26 | 38 | ] |
| 27 | 39 | for (path, contents) in files: |
| 28 | 40 | createDir(path.parentDir) |
| 29 | - if not fileExists(path) or getFileSize(path) != contents.len: | |
| 41 | + if not fileExists(path) or readFile(path) != contents: | |
| 30 | 42 | writeFile(path, contents) |
| 31 | 43 | |
| 32 | 44 | proc usage() = |
| @@ -56,11 +68,6 @@ proc srcDir(): string = | ||
| 56 | 68 | proc runtimeLib(release: bool): string = |
| 57 | 69 | ## Release archives place the private runtime beside bin/. A source checkout |
| 58 | 70 | ## 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) | |
| 64 | 71 | let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a") |
| 65 | 72 | let installed = getAppDir().parentDir / "lib" / libName |
| 66 | 73 | let source = srcDir() / "runtime_lib.nim" |
| @@ -98,7 +105,8 @@ proc buildKey(nimSrc: string, release: bool, rtLib: string): string = | ||
| 98 | 105 | let nimExe = findExe("nim") |
| 99 | 106 | if nimExe.len > 0: |
| 100 | 107 | h = h !& hash($getLastModificationTime(nimExe)) |
| 101 | - h = h !& hash($getLastModificationTime(rtLib)) | |
| 108 | + if rtLib.len > 0: | |
| 109 | + h = h !& hash($getLastModificationTime(rtLib)) | |
| 102 | 110 | $(!$h) |
| 103 | 111 | |
| 104 | 112 | proc main() = |
| @@ -179,18 +187,21 @@ proc main() = | ||
| 179 | 187 | # and the Nim compiler itself. |
| 180 | 188 | let stamp = work / "stamp" |
| 181 | 189 | var rtLib = "" |
| 182 | - try: | |
| 183 | - rtLib = runtimeLib(release) | |
| 184 | - except IOError, OSError: | |
| 185 | - stderr.writeLine("clonim: " & getCurrentExceptionMsg()) | |
| 186 | - quit(1) | |
| 190 | + when not defined(releaseCompiler): | |
| 191 | + try: | |
| 192 | + rtLib = runtimeLib(release) | |
| 193 | + except IOError, OSError: | |
| 194 | + stderr.writeLine("clonim: " & getCurrentExceptionMsg()) | |
| 195 | + quit(1) | |
| 187 | 196 | let cached = cmd == "run" and fileExists(outBin) and fileExists(stamp) and |
| 188 | 197 | readFile(stamp) == buildKey(nimSrc, release, rtLib) |
| 189 | 198 | |
| 190 | 199 | var nimCmd = @["nim", "c", "--hints:off", "--warnings:off", |
| 191 | 200 | "--path:" & srcDir(), "--nimcache:" & (work / "cache"), |
| 192 | - "--passL:-Wl,--allow-multiple-definition", "--passL:" & rtLib, | |
| 193 | 201 | "--passL:-lm", "-o:" & outBin] |
| 202 | + when not defined(releaseCompiler): | |
| 203 | + nimCmd.add "--passL:-Wl,--allow-multiple-definition" | |
| 204 | + nimCmd.add "--passL:" & rtLib | |
| 194 | 205 | if release: nimCmd.add "-d:release" |
| 195 | 206 | nimCmd.add nimFile |
| 196 | 207 | if verbose and not cached: echo "clonim: " & nimCmd.join(" ") |
| @@ -8,8 +8,12 @@ import runtime, compiler | |||
| 8 | 8 | ||
| 9 | when defined(releaseCompiler): | 9 | when defined(releaseCompiler): |
| 10 | const | 10 | const |
| 11 | - EmbeddedAppRuntime = staticRead("app_runtime.nim") | 11 | + EmbeddedAppRuntime = staticRead("app_runtime_source.nim") |
| 12 | EmbeddedRuntimeTypes = staticRead("runtime_types.nim") | 12 | EmbeddedRuntimeTypes = staticRead("runtime_types.nim") |
| 13 | + EmbeddedRuntime = staticRead("runtime.nim") | ||
| 14 | + EmbeddedCore = staticRead("core.nim") | ||
| 15 | + EmbeddedNamespaces = staticRead("namespaces.nim") | ||
| 16 | + EmbeddedReader = staticRead("reader.nim") | ||
| 13 | EmbeddedCoreStdlib = staticRead("../stdlib/clonim/core.clj") | 17 | EmbeddedCoreStdlib = staticRead("../stdlib/clonim/core.clj") |
| 14 | 18 | ||
| 15 | proc embeddedRoot(): string = | 19 | proc embeddedRoot(): string = |
| @@ -17,16 +21,24 @@ when defined(releaseCompiler): | |||
| 17 | ## runtime implementation remains the separately shipped static archive. | 21 | ## runtime implementation remains the separately shipped static archive. |
| 18 | var h: Hash = hash(EmbeddedAppRuntime) | 22 | var h: Hash = hash(EmbeddedAppRuntime) |
| 19 | h = h !& hash(EmbeddedRuntimeTypes) | 23 | h = h !& hash(EmbeddedRuntimeTypes) |
| 24 | + h = h !& hash(EmbeddedRuntime) | ||
| 25 | + h = h !& hash(EmbeddedCore) | ||
| 26 | + h = h !& hash(EmbeddedNamespaces) | ||
| 27 | + h = h !& hash(EmbeddedReader) | ||
| 20 | h = h !& hash(EmbeddedCoreStdlib) | 28 | h = h !& hash(EmbeddedCoreStdlib) |
| 21 | result = getTempDir() / "clonim-runtime" / $(!$h) | 29 | result = getTempDir() / "clonim-runtime" / $(!$h) |
| 22 | let files = [ | 30 | let files = [ |
| 23 | (result / "src" / "app_runtime.nim", EmbeddedAppRuntime), | 31 | (result / "src" / "app_runtime.nim", EmbeddedAppRuntime), |
| 24 | (result / "src" / "runtime_types.nim", EmbeddedRuntimeTypes), | 32 | (result / "src" / "runtime_types.nim", EmbeddedRuntimeTypes), |
| 33 | + (result / "src" / "runtime.nim", EmbeddedRuntime), | ||
| 34 | + (result / "src" / "core.nim", EmbeddedCore), | ||
| 35 | + (result / "src" / "namespaces.nim", EmbeddedNamespaces), | ||
| 36 | + (result / "src" / "reader.nim", EmbeddedReader), | ||
| 25 | (result / "stdlib" / "clonim" / "core.clj", EmbeddedCoreStdlib), | 37 | (result / "stdlib" / "clonim" / "core.clj", EmbeddedCoreStdlib), |
| 26 | ] | 38 | ] |
| 27 | for (path, contents) in files: | 39 | for (path, contents) in files: |
| 28 | createDir(path.parentDir) | 40 | createDir(path.parentDir) |
| 29 | - if not fileExists(path) or getFileSize(path) != contents.len: | 41 | + if not fileExists(path) or readFile(path) != contents: |
| 30 | writeFile(path, contents) | 42 | writeFile(path, contents) |
| 31 | 43 | ||
| 32 | proc usage() = | 44 | proc usage() = |
| @@ -56,11 +68,6 @@ proc srcDir(): string = | |||
| 56 | proc runtimeLib(release: bool): string = | 68 | proc runtimeLib(release: bool): string = |
| 57 | ## Release archives place the private runtime beside bin/. A source checkout | 69 | ## Release archives place the private runtime beside bin/. A source checkout |
| 58 | ## builds the same archive into lib/ on first use. | 70 | ## 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) | ||
| 64 | let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a") | 71 | let libName = (if release: "libclonim_runtime.a" else: "libclonim_runtime_debug.a") |
| 65 | let installed = getAppDir().parentDir / "lib" / libName | 72 | let installed = getAppDir().parentDir / "lib" / libName |
| 66 | let source = srcDir() / "runtime_lib.nim" | 73 | let source = srcDir() / "runtime_lib.nim" |
| @@ -98,7 +105,8 @@ proc buildKey(nimSrc: string, release: bool, rtLib: string): string = | |||
| 98 | let nimExe = findExe("nim") | 105 | let nimExe = findExe("nim") |
| 99 | if nimExe.len > 0: | 106 | if nimExe.len > 0: |
| 100 | h = h !& hash($getLastModificationTime(nimExe)) | 107 | h = h !& hash($getLastModificationTime(nimExe)) |
| 101 | - h = h !& hash($getLastModificationTime(rtLib)) | 108 | + if rtLib.len > 0: |
| 109 | + h = h !& hash($getLastModificationTime(rtLib)) | ||
| 102 | $(!$h) | 110 | $(!$h) |
| 103 | 111 | ||
| 104 | proc main() = | 112 | proc main() = |
| @@ -179,18 +187,21 @@ proc main() = | |||
| 179 | # and the Nim compiler itself. | 187 | # and the Nim compiler itself. |
| 180 | let stamp = work / "stamp" | 188 | let stamp = work / "stamp" |
| 181 | var rtLib = "" | 189 | var rtLib = "" |
| 182 | - try: | 190 | + when not defined(releaseCompiler): |
| 183 | - rtLib = runtimeLib(release) | 191 | + try: |
| 184 | - except IOError, OSError: | 192 | + rtLib = runtimeLib(release) |
| 185 | - stderr.writeLine("clonim: " & getCurrentExceptionMsg()) | 193 | + except IOError, OSError: |
| 186 | - quit(1) | 194 | + stderr.writeLine("clonim: " & getCurrentExceptionMsg()) |
| 195 | + quit(1) | ||
| 187 | let cached = cmd == "run" and fileExists(outBin) and fileExists(stamp) and | 196 | let cached = cmd == "run" and fileExists(outBin) and fileExists(stamp) and |
| 188 | readFile(stamp) == buildKey(nimSrc, release, rtLib) | 197 | readFile(stamp) == buildKey(nimSrc, release, rtLib) |
| 189 | 198 | ||
| 190 | var nimCmd = @["nim", "c", "--hints:off", "--warnings:off", | 199 | var nimCmd = @["nim", "c", "--hints:off", "--warnings:off", |
| 191 | "--path:" & srcDir(), "--nimcache:" & (work / "cache"), | 200 | "--path:" & srcDir(), "--nimcache:" & (work / "cache"), |
| 192 | - "--passL:-Wl,--allow-multiple-definition", "--passL:" & rtLib, | ||
| 193 | "--passL:-lm", "-o:" & outBin] | 201 | "--passL:-lm", "-o:" & outBin] |
| 202 | + when not defined(releaseCompiler): | ||
| 203 | + nimCmd.add "--passL:-Wl,--allow-multiple-definition" | ||
| 204 | + nimCmd.add "--passL:" & rtLib | ||
| 194 | if release: nimCmd.add "-d:release" | 205 | if release: nimCmd.add "-d:release" |
| 195 | nimCmd.add nimFile | 206 | nimCmd.add nimFile |
| 196 | if verbose and not cached: echo "clonim: " & nimCmd.join(" ") | 207 | if verbose and not cached: echo "clonim: " & nimCmd.join(" ") |