Persistent linter log embeds absolute source file paths into `.olean.server` (and `.olean`), breaking build reproducibility across directories
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- build-system
Direzione di ricerca
Start with the cited path flow in src/lake/Lake/Build/Module.lean and Actions.lean, then inspect how src/Lean/Linter/PersistentLintLog.lean records and serializes source paths. Reproduce with the supplied three-directory Lake build and compare the listed artifacts. Done when identical source builds produce byte-for-byte identical compiled artifacts across checkout paths while preserving useful lint locations.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
When a module triggers any linter diagnostic (e.g. the default linter.unusedVariables), lake build produces directory-dependent .olean.server files (and, when path lengths differ enough to shift compacted-region offsets, .olean.private as well; in non-module files, .olean directly).
The root cause is that Lake passes the absolute source path to lean, and Lean.Linter.recordLints persists the raw m.fileName into lintLogExt (PersistentLintLog) without normalizing it to a project-relative path (unlike Lake's diagnostic output formatting, which already rewrites the filename to relSrcFile).
Related context: this mechanism was also observed in leanprover-community/riemann-hypothesis#6 / #40 on v4.33.1; it still reproduces on v4.35.0, v4.36.0 (611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9), and master (0e511b3aa1e6af4f6eaf98838db22801466af7b9).
Minimal Reproduction
Tested on Linux x86-64 with stock leanprover/lean4:v4.36.0 (611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9):
set -euo pipefail
base=$(mktemp -d /tmp/lean-path-repro.XXXXXX)
cd "$base"
mkdir dir_alpha dir_beta dir_beta_with_a_longer_absolute_path
cat > dir_alpha/PathAudit.lean <<'LEAN'
module
namespace PathAudit
public def answer (unused : Nat) : Nat := 42
end PathAudit
LEAN
cat > dir_alpha/lakefile.toml <<'TOML'
name = "path_audit"
defaultTargets = ["PathAudit"]
enableArtifactCache = false
[[lean_lib]]
name = "PathAudit"
TOML
printf 'leanprover/lean4:v4.36.0\n' > dir_alpha/lean-toolchain
for d in dir_beta dir_beta_with_a_longer_absolute_path; do
cp dir_alpha/{PathAudit.lean,lakefile.toml,lean-toolchain} "$d/"
done
for d in dir_alpha dir_beta dir_beta_with_a_longer_absolute_path; do
(cd "$d" && LAKE_NO_CACHE=1 lake build +PathAudit:leanArts)
done
# Compare all 7 compiled artifacts across directories
for ext in olean olean.server olean.private ir ir.sig ilean; do
sha256sum dir_*/.lake/build/lib/lean/PathAudit."$ext"
done
sha256sum dir_*/.lake/build/ir/PathAudit.c
# Inspect embedded absolute path in .olean.server
strings -a -t d dir_alpha/.lake/build/lib/lean/PathAudit.olean.server | grep PathAudit.lean
Observed Behavior
| Artifact | dir_alpha vs dir_beta |
dir_alpha vs dir_beta_with_a_longer_absolute_path |
Notes |
|---|---|---|---|
.olean |
Identical | Identical | No path string (in module mode) |
.olean.server |
Differs | Differs | Embeds full /tmp/.../dir_*/PathAudit.lean under lintLogExt |
.olean.private |
Identical | Differs (1 byte) | Cross-part compacted-region pointer into .olean.server shifts by 24 bytes when server region grows (1640 → 1664 bytes) |
.ir, .ir.sig, .ilean, .c |
Identical | Identical | No absolute paths |
Control checks confirming the cause:
- Passing
-Dlinter.unusedVariables=false(eliminating the lint entry) makes all 7 artifacts byte-for-byte identical across all three directories. - Replaying Lake's exact
leancommand with--setuppreserved, changing only the source argument from/tmp/.../dir_*/PathAudit.leanto the relative pathPathAudit.lean, also makes all 7 artifacts byte-for-byte identical across directories (recordingPathAudit.leaninstead of an absolute path).
Root Cause in Source (v4.36.0, commit 611c117bfaf7b7ae1cfcf246ce6fba31e8f509e9)
- Lake computes
relSrcFilebut passes the absolutesrcFiletolean:Lake/Build/Module.lean#L1104-L1115computesrelSrcFileand passes bothpresetup.srcFileandrelSrcFiletocompileLeanModule.Lake/Build/Actions.lean#L42-L86passes the absoluteleanFileinlean's argv (line 50), and only substitutesrelLeanFilewhen post-processing diagnostic messages printed to Lake's log (line 85).
leanrecords the rawfileNameintolintLogExt:Lean/Shell.lean#L531-L545forwards the raw source argument toElab.runFrontend.Lean/Linter/PersistentLintLog.lean#L69-L83(still unchanged onmasterat0e511b3a) storesfile := m.fileNameandmessage := ← m.serialize(which preservesm.fileNameatLean/Message.lean#L635-L637) intolintLogExt.
- Serialization into
.olean.server/.olean.private(and.oleanin non-modulemode):Lean/Linter/PersistentLintLog.lean#L19-L33exportslintLogExtentries atserverandprivatelevels.- Because
saveModuleDataParts(Lean/Environment.lean#L2113-L2123) shares a singleobject_compactoracross parts, a longer absolute path in.olean.servershifts serialized object offsets referenced from.olean.private. In legacy non-modulebuilds,writeModuleserializes atprivatelevel into a single.olean, embedding the absolute path directly in.olean.
Expected Behavior / Possible Fixes
Compiled .olean* artifacts for identical source files should be invariant to the build checkout directory path (for reproducible builds, content-addressed caches, and artifact deduplication).
Possible approaches:
- Normalize the source path passed to
lean/ stored inPersistentLintLog: either have Lake passrelSrcFile(withcwd = mod.pkg.dir) or provide a relative/canonical display path inModuleSetup/recordLintsso persistedLintEntry.fileandSerialMessage.fileNamenever contain machine-local absolute directory prefixes; or - Omit the redundant
file/fileNamepath prefix inPersistentLintLogentries when it matches the owning module's source file (sincelintLogExtis already keyed per module and consumers can resolve the module's source file from the module name / package root).
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 16h 45m
- PR unite (30g)
- 361
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
leanprover/lean4#16876 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16842 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16841 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
leanprover/lean4#16840 ·
I maintainer di solito rispondono entro 1 giorno
-
doc: stray "public" in Bool and HEq documentationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
leanprover/lean4#16825 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Unable to installAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
[BUG] Nightly Build JDK 17: latest-frameworks job red since 2026-11-28 — quarkiverse-langchain4j 2.0.0 pins Quarkus 4.0.0, which requires Java 21Forse già presa @uhhgxg l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
langchain4j/langchain4j#7344 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
connectrpc/connect-es#1915 ·
I maintainer di solito rispondono entro 1 giorno
-
ninja_build.sh -t compile_commands fails: `cmake ..` points at build/ instead of the repo rootApertaneeds review regression MS4
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 2 giorni