Skip to content

Commit eefc4ab

Browse files
zahclaude
andcommitted
fix(recipe-compile): make interface extraction self-contained
Compiling a project recipe (the `--define:reproInterfaceMode` interface extraction the engine runs from a staged source copy) imports the project DSL, which transitively pulls in third-party Nim packages. Three of those were only resolvable from a consumer's sibling checkout or a dev-shell environment variable, so the extraction failed from a clean staged tree with `cannot open file: ...`: - `nimcrypto/sha2` (imported by `repro_project_dsl`). Vendor a source-only slice of cheatfate/nimcrypto v0.7.3 under `libs/nimcrypto` and list it first in both the `config.nims` and interface-extract path resolvers, matching the existing in-tree vendoring of nim-faststreams / stint / the serialization packages. - `bearssl/rand` (reached via `repro_binary_cache_server/types -> repro_peer_cache/auth`). The cache type layer — and everything that depends on it, including the DSL — needs only the plain ECDSA-P256 key / signature *byte-array shapes*, not BearSSL's sign / verify procedures. Split those shapes into a new BearSSL-free `repro_peer_cache/key_types` module (re-exported from `auth`, so its public API is unchanged) and have the cache-server type module import that instead of the full `auth`. This removes BearSSL from the recipe-compile type-check closure entirely. Also terminate a runaway macro expansion in the cross-project build-binding lowering: a non-annotated `build:` binding whose RHS references an earlier sibling binding (e.g. `let runTarget = buildAction(..., deps = @[binary.id])`) caused `package` expansion to abort with "template instantiation too nested". At module scope the sibling name resolves to the generated accessor template, and forcing its `auto` return type inside the storage var's `compiles(typeof(...))` probe re-enters expansion with no base case (`when compiles` does not catch it — the cycle happens during the `typeof` elaboration). Exclude such bindings from the cross-project set; they stay ordinary build-local lets. Covered by the existing `t_dsl_cross_project_binding_guard` "RHS references a sibling binding is NOT exposed" case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e77e99f commit eefc4ab

33 files changed

Lines changed: 11102 additions & 12 deletions

File tree

config.nims

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ addPackagePath("SSZ_SERIALIZATION_SRC", [
179179
".." / "nim-ssz-serialization",
180180
], "ssz_serialization.nim")
181181
addPackagePath("NIMCRYPTO_SRC", [
182+
# Vendored source-only slice (cheatfate/nimcrypto @ 423ea4f / v0.7.3).
183+
# Listed first so reprobuild is self-contained: the recipe-compile no
184+
# longer depends on a consumer's sibling `nimcrypto` checkout. The
185+
# package entry module is `nimcrypto.nim` at the repo root with
186+
# submodules under `nimcrypto/`, so the dir itself is the --path root.
187+
# Marker is `nimcrypto/hash.nim`.
188+
"libs" / "nimcrypto",
182189
".." / "codetracer" / "libs" / "nimcrypto",
183190
".." / "nimcrypto",
184191
], "nimcrypto" / "hash.nim")

libs/nimcrypto/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Eugene Kabanov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libs/nimcrypto/nimcrypto.nim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
#
3+
# NimCrypto
4+
# (c) Copyright 2018 Eugene Kabanov
5+
#
6+
# See the file "LICENSE", included in this
7+
# distribution, for details about the copyright.
8+
#
9+
10+
import nimcrypto/[hash, sha2, ripemd, keccak, blake2, sha, hmac]
11+
import nimcrypto/[rijndael, blowfish, twofish, bcmode]
12+
import nimcrypto/[utils, sysrand]
13+
14+
## Nimcrypto is the Nim language's cryptographic library.
15+
## It implements several popular cryptographic algorithms and their tests,
16+
## with some examples in the official repo:
17+
## https://github.com/cheatfate/nimcrypto/tree/master/examples
18+
19+
export hash, sha, sha2, ripemd, keccak, blake2, hmac, rijndael, twofish,
20+
blowfish, bcmode, utils, sysrand

libs/nimcrypto/nimcrypto.nimble

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Package
2+
3+
version = "0.7.3"
4+
author = "Eugene Kabanov"
5+
description = "Nim cryptographic library"
6+
license = "MIT"
7+
skipDirs = @["tests", "examples", "Nim", "docs"]
8+
9+
# Dependencies
10+
11+
requires "nim >= 1.6"
12+
13+
# Tests
14+
15+
let
16+
nimc = getEnv("NIMC", "nim") # Which nim compiler to use
17+
18+
task test, "Runs the test suite":
19+
var testCommands = @[
20+
nimc & " c -f -r tests/",
21+
nimc & " c -f -d:danger -r tests/",
22+
nimc & " c -f -d:danger --threads:on -r tests/",
23+
nimc & " c -f --passC=\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" --passL:\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" -r tests/",
24+
]
25+
26+
# Nim version 1.6 compiler crashes with `out of memory` on i386.
27+
when defined(cpu64):
28+
testCommands.add nimc & " c -f --mm:orc --threads:on -r tests/"
29+
else:
30+
when (NimMajor, NimMinor) >= (2, 0):
31+
testCommands.add nimc & " c -f --mm:orc --threads:on -r tests/"
32+
33+
when (NimMajor, NimMinor) >= (2, 0):
34+
testCommands.add nimc & " c -f --mm:refc --threads:off --passC=\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" --passL:\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" -r tests/"
35+
testCommands.add nimc & " c -f --mm:refc --threads:on --passC=\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" --passL:\"-fsanitize=undefined -fsanitize-undefined-trap-on-error\" -r tests/"
36+
testCommands.add nimc & " c -f --mm:refc --threads:off -r tests/"
37+
testCommands.add nimc & " c -f --mm:refc --threads:on -r tests/"
38+
39+
let exampleFiles = @[
40+
"ecb", "cbc", "ofb", "cfb", "ctr", "gcm"
41+
]
42+
var exampleCommands = @[
43+
nimc & " c -f -r --threads:on examples/",
44+
nimc & " c -f --mm:orc --threads:on -r examples/"
45+
]
46+
47+
for cmd in testCommands:
48+
echo "\n" & cmd & "testall"
49+
exec cmd & "testall"
50+
rmFile("tests/testall".toExe())
51+
52+
for efile in exampleFiles:
53+
for cmd in exampleCommands:
54+
echo "\n" & cmd & efile
55+
exec cmd & efile
56+
rmFile("examples/" & efile.toExe())
57+
58+
exec(nimc & " c -f -r -d:nimcryptoLowercase tests/testapi")
59+
exec(nimc & " c -f -r -d:nimcrypto0xPrefix tests/testapi")
60+
exec(nimc & " c -f -r -d:nimcrypto0xPrefix -d:nimcryptoLowercase tests/testapi")

0 commit comments

Comments
 (0)