icmodnames

Search:
Group by:
Source   Edit  

Nim's OWN module-suffix, replacing nimony's gear2/modnames.moduleSuffix.

nimony's version hashes a path made RELATIVE to getCurrentDir() (or the shortest search-path-relative form), so the produced suffix depends on the current working directory AND the searchPath set. Under nim ic the DISCOVERY pass (deps.nim, in the driver process) and the COMPILE pass (nifgen/typekeys, in a child nim m process) can run with different CWDs or --path sets, so the SAME file hashes to two different suffixes: e.g. std/staticos became sta5rk8sn1 at discovery but sta4c0qxk at compile, so every importer waited forever for a .s.bif that was actually written under the other name — a cold nim ic build (of anything pulling in std/os, whose oscommon does from std/staticos import PathComponent) never converged.

Hashing the CANONICAL ABSOLUTE path makes the suffix a pure function of the file, identical across every process and call site. The base-name prefix + base-36 uhash layout is kept byte-for-byte compatible with the old scheme so nothing but the hashed string changes.

Procs

proc moduleSuffix(path: string; searchPaths: openArray[string]): string {.
    ...raises: [], tags: [], forbids: [].}
searchPaths is accepted for signature-compatibility with the replaced modnames.moduleSuffix but is deliberately IGNORED — the suffix must not depend on the search-path set or the CWD (see the module doc). Source   Edit