This PR enables the module system, in cooperation with the linker, to separate meta and non-meta code in native binaries. In particular, this ensures tactics merely used in proofs do not make it into the final binary. A simple example using `meta import Lean` has its binary size reduced from 130MB to 1.7MB. # Breaking change `importModules (loadExts := true)` must now be preceded by `enableInitializersExecution`. This was always the case for correct importing but is now enforced and checked eagerly.
18 lines
463 B
Text
18 lines
463 B
Text
import Lean
|
|
|
|
open Lean
|
|
open Lean.Meta
|
|
|
|
instance : ToFormat InstanceEntry where
|
|
format e := format e.val
|
|
|
|
unsafe def tst1 : IO Unit := do
|
|
enableInitializersExecution
|
|
let env ← importModules (loadExts := true) #[{module := `Lean}] {}
|
|
let aux : MetaM Unit := do
|
|
let insts ← getGlobalInstancesIndex
|
|
assert! insts.size > 0
|
|
IO.println (format insts)
|
|
discard <| aux.run |>.toIO { fileName := "", fileMap := default } { env := env }
|
|
|
|
#eval tst1
|