fix: lake: better library plugin heuristic (#8528)

This PR fixes the heuristic Lake uses to determine whether a `lean_lib`
can be loaded via `lean --plugin` rather than `lean --load-dynlib`.
Previously, a mismatch between the single root's name and the library's
name would not be caught and cause loading to fail.
This commit is contained in:
Mac Malone 2025-05-29 13:48:05 -04:00 committed by GitHub
parent 22d4c1d803
commit 3b72c7d193
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -113,7 +113,7 @@ protected def LeanLib.recBuildShared (self : LeanLib) : FetchM (Job Dynlib) := d
(·.push <$> ·.dynlib.fetch) jobs
return jobs
buildLeanSharedLib self.libName self.sharedLibFile objJobs libJobs
self.weakLinkArgs self.linkArgs (plugin := self.roots.size == 1)
self.weakLinkArgs self.linkArgs self.isPlugin
/-- The `LibraryFacetConfig` for the builtin `sharedFacet`. -/
def LeanLib.sharedFacetConfig : LibraryFacetConfig sharedFacet :=

View file

@ -73,6 +73,10 @@ The names of the library's root modules
@[inline] def sharedLibFile (self : LeanLib) : FilePath :=
self.pkg.sharedLibDir / self.sharedLibFileName
/-- Whether the shared binary of this library is a valid plugin. -/
def isPlugin (self : LeanLib) : Bool :=
self.roots == #[self.name] && self.libName == self.name.mangle ""
/-- The library's `extraDepTargets` configuration. -/
@[inline] def extraDepTargets (self : LeanLib) :=
self.config.extraDepTargets