Build.schema_hash(): FNV-1a 64 of the program's own schema (the bytes ludic schema prints), worked out only when a program names it, 0 under ludicc --release, which ludic bundle now passes (Mac and Windows); reseeded

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-29 19:05:28 +03:00
parent b5bffe99fa
commit dacc0f7280
14 changed files with 75837 additions and 75090 deletions

View file

@ -49,11 +49,11 @@ function compile_app(src: pointer, out: pointer, mode: int, save: bool) -> bool
var flags = "--windowed"
if mode == 2 { flags = "--headless" }
if save { flags = flags + " --save-temps" }
return shq(`{ludicc()} {flags}{title_flag()}{unsafe_flag()} {src} -o {out}`)
return shq(`{ludicc()} {flags}{title_flag()}{unsafe_flag()}{release_flag()} {src} -o {out}`)
}
if mode == 2 {
if not shq(`{ludicc()} --headless{title_flag()}{unsafe_flag()} {src} --emit-llvm -o {ll}`) { return false }
if not shq(`{ludicc()} --headless{title_flag()}{unsafe_flag()}{release_flag()} {src} --emit-llvm -o {ll}`) { return false }
let objs = split_objs(ll, out) # on every core when it can (split.ludic)
var input = ll
if objs != "" { input = objs }
@ -65,7 +65,7 @@ function compile_app(src: pointer, out: pointer, mode: int, save: bool) -> bool
return true
}
if not shq(`{ludicc()} --windowed{title_flag()}{unsafe_flag()} {src} --emit-llvm -o {ll}`) { return false }
if not shq(`{ludicc()} --windowed{title_flag()}{unsafe_flag()}{release_flag()} {src} --emit-llvm -o {ll}`) { return false }
# audio.ll (#22) is always linked here — unused snd_* are dead-stripped; the
# canonical `ludicc -o` path links it only when Audio.* is used.
let cocoa = `{home}runtime/native/cocoa.ll`
@ -85,6 +85,12 @@ function compile_app(src: pointer, out: pointer, mode: int, save: bool) -> bool
# opens under that name rather than the `program` name; "" otherwise, and for a name the
# shell line could not carry safely.
# ` --unsafe` when the build said so: the project's own files may write `unsafe` (L7)
# ludic bundle: what ships is a release, and Build.schema_hash() is 0 in it
var g_release_build: bool = false
function release_flag() -> pointer {
if g_release_build { return " --release" }
return ""
}
var g_unsafe_build: bool = false
function unsafe_flag() -> pointer {
if g_unsafe_build { return " --unsafe" }

View file

@ -355,7 +355,7 @@ function cmd_bundle_windows() -> int {
# 1. the executable - staged under a name with no spaces, as on macOS
let res = windows_icon_res(manifest_app(m, "icon"))
let staged = tmp_path("bundle_exe")
var flags = "--windowed --gui"
var flags = "--windowed --gui --release"
if res != "" { flags = flags + ` --link "{res}"` }
Os.set_env("LUDIC_OPT", "2") # a shipped game is -O2, whatever a developer's shell says
if not shq(`{ludicc()} {flags}{title_flag()} {entry} --natives-out {staged}.natives -o {staged}`) { return 1 }
@ -441,6 +441,7 @@ function cmd_bundle() -> int {
# out of the path it is given.
let exe = `{contents}/MacOS/{name}`
let staged = `{tmp_dir()}/bundle_exe`
g_release_build = true
if not compile_app(entry, staged, 1, false) { return 1 }
if not shq(`cp {staged} "{exe}"`) {
err("ludic bundle: could not place the executable\n")

View file

@ -90,6 +90,7 @@ function selfhost_frags() -> []pointer {
push(f, "selfhost/backend/emit_fnval.ludic")
push(f, "selfhost/backend/emit_vis.ludic")
push(f, "selfhost/backend/emit_schema.ludic")
push(f, "selfhost/backend/emit_schema_hash.ludic")
push(f, "selfhost/check/check_state.ludic")
push(f, "selfhost/check/check_index.ludic")
push(f, "selfhost/check/check_types.ludic")

View file

@ -1232,6 +1232,7 @@ function cmd_dev_test() -> int {
feat_case("lang/registry", "", "3 Crate true 2 fire_ring -1", "registry.ludic (L8: a registry filled by def declarations - index constants, a count, the key, a lookup)")
reject_case("rejected/registry_unknown", "there is no registry Tables", "a def names a registry that exists")
feat_case("lang/attributes", "", "2 1 Lantern 2", "attributes.ludic (editor attributes: @Ref, @OneOf, @Range, @Unit, @Asset, @Color, @AppendOnly, @ByKey - no effect on the program)")
feat_case("lang/schema_hash", "", "true", "schema_hash.ludic (Build.schema_hash(): FNV-1a 64 of the program's own schema, 0 in a release)")
reject_case("rejected/ref_unknown", "field Tool.seller: @Ref(Vendorz) names no registry", "@Ref names a registry that exists")
reject_case("rejected/node_bad", "field Tool.grip: @Node(handle) names no field", "@Node names a field of its record")
schema_case("lang/attributes", "{\"name\": \"weight\", \"type\": \"float\", \"default\": \"1.0\", \"file\": \"examples/lang/attributes.ludic\", \"line\": 24, \"col\": 33, \"attributes\": [{\"name\": \"Range\", \"args\": [0, 20.5]}, {\"name\": \"Unit\", \"args\": [\"kg\"]}]", "--emit-schema: a field's type, default, place and attributes")