Skip to content

Commit 22c1204

Browse files
authored
Small fix for incremental compilation (#1930)
* Small fix for incremental compilation In incremental mode we need to add the arity of a compiled definition to the hash, because if that changes, we need to rebuild the dependencies too to make sure the arity is correct at the call site * Fix indentation in CHANGELOG
1 parent 971afa9 commit 22c1204

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ filter p (x :: xs) with (p x)
5555
and reverts to whole program compilation. Incremental compilation is currently
5656
supported only by the Chez Scheme back end.
5757
This is currently supported only on Unix-like platforms (not yet Windows)
58+
- Note that you must set `IDRIS2_INC_CGS` when building and installing
59+
all libraries you plan to link with an incremental build.
60+
- Note also that this is experimental and not yet well tested!
5861
* The type checker now tries a lot harder to avoid reducing expressions where
5962
it is not needed. This gives a huge performance improvement in programs
6063
that potentially do a lot of compile time evaluation. However, sometimes

src/Compiler/Inline.idr

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Core.CompileExpr
88
import Core.Context
99
import Core.Context.Log
1010
import Core.FC
11+
import Core.Hash
1112
import Core.Options
1213
import Core.TT
1314

@@ -514,6 +515,16 @@ mergeLamDef n
514515
| Nothing => pure ()
515516
setCompiled n !(mergeLam cexpr)
516517

518+
export
519+
addArityHash : {auto c : Ref Ctxt Defs} ->
520+
Name -> Core ()
521+
addArityHash n
522+
= do defs <- get Ctxt
523+
Just def <- lookupCtxtExact n (gamma defs) | Nothing => pure ()
524+
let Just cexpr = compexpr def | Nothing => pure ()
525+
let MkFun args _ = cexpr | _ => pure ()
526+
addHash (n, length args)
527+
517528
export
518529
compileAndInlineAll : {auto c : Ref Ctxt Defs} ->
519530
Core ()
@@ -528,6 +539,11 @@ compileAndInlineAll
528539
-- This seems to be the point where not much useful
529540
-- happens any more.
530541
traverse_ updateCallGraph cns
542+
-- in incremental mode, add the arity of the definitions to the hash,
543+
-- because if these change we need to recompile dependencies
544+
-- accordingly
545+
when (not (isNil (incrementalCGs !getSession))) $
546+
traverse_ addArityHash cns
531547
where
532548
transform : Nat -> List Name -> Core ()
533549
transform Z cns = pure ()

0 commit comments

Comments
 (0)