fix: pass pkg linking args to extern lib linking
This commit is contained in:
parent
59585d2374
commit
b022a99027
4 changed files with 12 additions and 4 deletions
|
|
@ -53,7 +53,7 @@ def compileO (name : String) (oFile srcFile : FilePath)
|
|||
|
||||
def compileStaticLib (name : String) (libFile : FilePath)
|
||||
(oFiles : Array FilePath) (ar : FilePath := "ar") : LogIO Unit := do
|
||||
logInfo s!"Linking {name}"
|
||||
logInfo s!"Creating {name}"
|
||||
createParentDirs libFile
|
||||
proc {
|
||||
cmd := ar.toString
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def recBuildWithIndex : (info : BuildInfo) → IndexBuildM (BuildData info.key)
|
|||
| .sharedExternLib lib =>
|
||||
mkTargetFacetBuild ExternLib.sharedFacet do
|
||||
let staticTarget := Target.active <| ← lib.static.recBuild
|
||||
staticToLeanSharedLibTarget lib.name.toString staticTarget |>.activate
|
||||
staticToLeanSharedLibTarget lib.name.toString staticTarget lib.linkArgs |>.activate
|
||||
| .dynlibExternLib lib =>
|
||||
mkTargetFacetBuild ExternLib.dynlibFacet do
|
||||
let sharedTarget := Target.active <| ← lib.shared.recBuild
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ def leanExeTarget (name : String) (exeFile : FilePath)
|
|||
(extraDepTrace := getLeanTrace <&> (·.mix <| pureHash linkArgs)) fun links => do
|
||||
compileExe name exeFile links linkArgs (← getLeanc)
|
||||
|
||||
def staticToLeanSharedLibTarget (name : String) (staticLibTarget : FileTarget) : FileTarget :=
|
||||
def staticToLeanSharedLibTarget (name : String)
|
||||
(staticLibTarget : FileTarget) (linkArgs : Array String := #[]) : FileTarget :=
|
||||
.mk <| staticLibTarget.bindSync fun staticLib staticTrace => do
|
||||
let dynlib := staticLib.withExtension sharedLibExt
|
||||
let trace ← buildFileUnlessUpToDate dynlib staticTrace do
|
||||
|
|
@ -93,7 +94,7 @@ def staticToLeanSharedLibTarget (name : String) (staticLibTarget : FileTarget) :
|
|||
#[s!"-Wl,-force_load,{staticLib}"]
|
||||
else
|
||||
#["-Wl,--whole-archive", staticLib.toString, "-Wl,--no-whole-archive"]
|
||||
compileSharedLib name dynlib args (← getLeanc)
|
||||
compileSharedLib name dynlib (args ++ linkArgs) (← getLeanc)
|
||||
return (dynlib, trace)
|
||||
|
||||
def sharedToLeanDynlibTarget (sharedLibTarget : FileTarget) : DynlibTarget :=
|
||||
|
|
|
|||
|
|
@ -32,3 +32,10 @@ namespace ExternLib
|
|||
/-- The external library's user-defined `target`. -/
|
||||
@[inline] def target (self : ExternLib) : FileTarget :=
|
||||
self.config.target
|
||||
|
||||
/--
|
||||
The arguments to pass to `leanc` when linking the external library.
|
||||
That is, the package's `moreLinkArgs`.
|
||||
-/
|
||||
@[inline] def linkArgs (self : ExternLib) : Array String :=
|
||||
self.pkg.moreLinkArgs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue