diff --git a/src/lake/Lake/Build/Actions.lean b/src/lake/Lake/Build/Actions.lean index 9c6c05536057..c2729f4004a4 100644 --- a/src/lake/Lake/Build/Actions.lean +++ b/src/lake/Lake/Build/Actions.lean @@ -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") @@ -96,6 +107,7 @@ def compileSharedLib proc { cmd := linker.toString args := #["-shared", "-o", libFile.toString] ++ linkArgs + env := ← getMacOSXDeploymentEnv } def compileExe @@ -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. -/