Skip to content

Commit 5fd17df

Browse files
authored
feat: lake: Dynlib.runtimeOnlyDeps (#14220)
This PR adds `Dynlib.runtimeOnlyDeps`. It specifies transitive dependencies that should not be linked, but need to be preloaded for `lean` elaboration when precompiling (e.g., libraries dynamically loaded at runtime via `dlopen`).
1 parent f73fc3a commit 5fd17df

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/lake/Lake/Build/Module.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ where
180180
throw (lib.name :: ps)
181181
let ps := lib.name :: ps
182182
let v := v.insert lib.name
183-
let (v, o) ← lib.deps.foldlM (init := (v, o)) fun (v, o) lib =>
183+
let step := fun (v, o) lib =>
184184
go lib ps v o
185+
let (v, o) ← lib.deps.foldlM step (v, o)
186+
let (v, o) ← lib.runtimeOnlyDeps.foldlM step (v, o)
185187
let o := o.push lib
186188
return (v, o)
187189

src/lake/Lake/Config/Dynlib.lean

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Lake
1616
public structure Dynlib where
1717
/-- Library file path. -/
1818
path : FilePath
19-
/-- Library name without platform-specific prefix/suffix (for `-l`). -/
19+
/-- Library name without any platform-specific prefix/suffix (for `-l`). -/
2020
name : String
2121
/-- Whether this library can be loaded as a plugin. -/
2222
plugin := false
@@ -25,6 +25,12 @@ public structure Dynlib where
2525
(e.g., linking on Windows, loading via `lean`).
2626
-/
2727
deps : Array Dynlib := #[]
28+
/--
29+
Non-link transitive dependencies of this library that are only required
30+
at runtime (e.g., libraries loaded dynamically via `dlopen`). Used by Lake
31+
to preload such dependencies for `lean` elaboration when precompiling.
32+
-/
33+
runtimeOnlyDeps : Array Dynlib := #[]
2834
deriving Inhabited, Repr
2935

3036
namespace Dynlib

0 commit comments

Comments
 (0)