Skip to content

Commit c2d5fc8

Browse files
committed
fix: lake: MACOSX_DEPLOYMENT_TARGET for shared libs
1 parent d2c4471 commit c2d5fc8

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/lake/Lake/Build/Actions.lean

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ def compileStaticLib
8888
args := #["rcs", libFile.toString] ++ oFiles.map toString
8989
}
9090

91+
private def getMacOSXDeploymentEnv : BaseIO (String × Option String) := do
92+
-- It is difficult to identify the correct minor version here, leading to linking warnings like:
93+
-- `ld64.lld: warning: /usr/lib/system/libsystem_kernel.dylib has version 13.5.0, which is newer than target minimum of 13.0.0`
94+
-- In order to suppress these we set the MACOSX_DEPLOYMENT_TARGET variable into the far future.
95+
if System.Platform.isOSX then
96+
match (← IO.getEnv "MACOSX_DEPLOYMENT_TARGET") with
97+
| some _ => return #[]
98+
| none => return #[("MACOSX_DEPLOYMENT_TARGET", some "99.0")]
99+
else
100+
return #[]
101+
91102
def compileSharedLib
92103
(libFile : FilePath) (linkArgs : Array String)
93104
(linker : FilePath := "cc")
@@ -96,6 +107,7 @@ def compileSharedLib
96107
proc {
97108
cmd := linker.toString
98109
args := #["-shared", "-o", libFile.toString] ++ linkArgs
110+
env := ← getMacOSXDeploymentEnv
99111
}
100112

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

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

0 commit comments

Comments
 (0)