fix: include moreLinkArgs in precompile link

This commit is contained in:
tydeu 2023-08-22 20:10:39 -04:00 committed by Mac Malone
parent 83556a1120
commit 898cd0b647
7 changed files with 27 additions and 2 deletions

View file

@ -211,8 +211,10 @@ def Module.recBuildDynlib (mod : Module) : IndexBuildM (BuildJob Dynlib) := do
let libDirs := pkgLibDirs ++ externDynlibs.filterMap (·.dir?)
let depTrace := oTrace.mix <| libTrace.mix externTrace
let trace ← buildFileUnlessUpToDate mod.dynlibFile depTrace do
let args := links.map toString ++
libDirs.map (s!"-L{·}") ++ libNames.map (s!"-l{·}")
let args :=
links.map toString ++
libDirs.map (s!"-L{·}") ++ libNames.map (s!"-l{·}") ++
mod.linkArgs
compileSharedLib mod.name.toString mod.dynlibFile args (← getLeanc)
return (⟨mod.dynlibFile, mod.dynlibName⟩, trace)

View file

@ -0,0 +1 @@
/build

View file

@ -0,0 +1 @@
import Foo.Bar

View file

@ -0,0 +1 @@
rm -rf build

View file

@ -0,0 +1,11 @@
import Lake
open Lake DSL
package precompileArgs
@[default_target]
lean_lib Foo {
precompileModules := true
moreLinkArgs := #["-lBaz"]
}

View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -exo pipefail
LAKE=${LAKE:-../../build/bin/lake}
./clean.sh
# Test that `moreLinkArgs` are included when linking precompiled modules
($LAKE build Foo 2>&1 || true) | grep -- "-lBaz"