File tree Expand file tree Collapse file tree 5 files changed +26
-3
lines changed
Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,13 @@ def computeModuleDeps
186186 plugins := plugins.push impLib
187187 else
188188 dynlibs := dynlibs.push impLib
189+ /-
190+ On MacOS, Lake must be loaded as a plugin for
191+ `import Lake` to work with precompiled modules.
192+ https://github.com/leanprover/lean4/issues/7388
193+ -/
194+ if Platform.isOSX && !(plugins.isEmpty && dynlibs.isEmpty) then
195+ plugins := plugins.push (← getLakeInstall).sharedDynlib
189196 return {dynlibs, plugins}
190197
191198/--
Original file line number Diff line number Diff line change 88import Init.Control.Option
99import Init.Data.Option.Coe
1010import Lean.Compiler.FFI
11+ import Lake.Config.Dynlib
1112import Lake.Util.NativeLib
1213import Lake.Config.Defaults
1314
@@ -114,19 +115,26 @@ structure LakeInstall where
114115 srcDir := home
115116 binDir := home / defaultBuildDir / defaultBinDir
116117 libDir := home / defaultBuildDir / defaultLeanLibDir
117- sharedLib := libDir / nameToSharedLib "Lake"
118+ sharedDynlib : Dynlib := {
119+ name := "Lake"
120+ path := libDir / nameToSharedLib "Lake"
121+ }
118122 lake := binDir / lakeExe
119123 deriving Inhabited, Repr
120124
125+ @[inline] def LakeInstall.sharedLib (self : LakeInstall) : FilePath :=
126+ self.sharedDynlib.path
127+
121128/-- Construct a Lake installation co-located with the specified Lean installation. -/
122129def LakeInstall.ofLean (lean : LeanInstall) : LakeInstall where
123130 home := lean.sysroot
124131 srcDir := lean.srcDir / "lake"
125132 binDir := lean.binDir
126133 libDir := lean.leanLibDir
127- sharedLib :=
134+ sharedDynlib :=
128135 let lib := s! "libLake_shared.{ sharedLibExt} "
129- if Platform.isWindows then lean.binDir / lib else lean.leanLibDir / lib
136+ let path := if Platform.isWindows then lean.binDir / lib else lean.leanLibDir / lib
137+ {name := "Lake_shared" , path}
130138 lake := lean.binDir / lakeExe
131139
132140/-! ## Detection Functions -/
Original file line number Diff line number Diff line change 1+ import Lake
2+ import Foo
Original file line number Diff line number Diff line change @@ -14,3 +14,5 @@ lean_lib FooDepDep
1414lean_exe orderTest
1515
1616lean_lib Downstream
17+
18+ lean_lib LakeTest
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ source ../common.sh
33
44./clean.sh
55
6+ # Test that precompilation works with a Lake import
7+ # https://github.com/leanprover/lean4/issues/7388
8+ test_run -v build LakeTest
9+
610# Test that the link & load order of precompiled libraries is correct
711# https://github.com/leanprover/lean4/issues/7790
812test_run -v exe orderTest
You can’t perform that action at this time.
0 commit comments