Skip to content

Commit

Permalink
fix: lake: set MACOSX_DEPLOYMENT_TARGET for shared libs (#6631)
Browse files Browse the repository at this point in the history
This PR sets `MACOSX_DEPLOYMENT_TARGET` for shared libraries (it was
previously only set for executables).

(cherry picked from commit 749a82a)
  • Loading branch information
tydeu authored and github-actions[bot] committed Jan 13, 2025
1 parent aee5e0b commit 955e99e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/lake/Lake/Build/Actions.lean
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ def compileStaticLib
args := #["rcs", libFile.toString] ++ oFiles.map toString
}

private def getMacOSXDeploymentEnv : BaseIO (Array (String × Option String)) := do
-- It is difficult to identify the correct minor version here, leading to linking warnings like:
-- `ld64.lld: warning: /usr/lib/system/libsystem_kernel.dylib has version 13.5.0, which is newer than target minimum of 13.0.0`
-- In order to suppress these we set the MACOSX_DEPLOYMENT_TARGET variable into the far future.
if System.Platform.isOSX then
match (← IO.getEnv "MACOSX_DEPLOYMENT_TARGET") with
| some _ => return #[]
| none => return #[("MACOSX_DEPLOYMENT_TARGET", some "99.0")]
else
return #[]

def compileSharedLib
(libFile : FilePath) (linkArgs : Array String)
(linker : FilePath := "cc")
Expand All @@ -96,6 +107,7 @@ def compileSharedLib
proc {
cmd := linker.toString
args := #["-shared", "-o", libFile.toString] ++ linkArgs
env := ← getMacOSXDeploymentEnv
}

def compileExe
Expand All @@ -106,16 +118,7 @@ def compileExe
proc {
cmd := linker.toString
args := #["-o", binFile.toString] ++ linkFiles.map toString ++ linkArgs
env := ← do
-- It is difficult to identify the correct minor version here, leading to linking warnings like:
-- `ld64.lld: warning: /usr/lib/system/libsystem_kernel.dylib has version 13.5.0, which is newer than target minimum of 13.0.0`
-- In order to suppress these we set the MACOSX_DEPLOYMENT_TARGET variable into the far future.
if System.Platform.isOSX then
match (← IO.getEnv "MACOSX_DEPLOYMENT_TARGET") with
| some _ => pure #[]
| none => pure #[("MACOSX_DEPLOYMENT_TARGET", some "99.0")]
else
pure #[]
env := ← getMacOSXDeploymentEnv
}

/-- Download a file using `curl`, clobbering any existing file. -/
Expand Down

0 comments on commit 955e99e

Please sign in to comment.