Skip to content

Commit 4793649

Browse files
committed
MacPlatform: use install_name_tool to add /usr/local/lib and /opt/hombrew/lib to rpath of lime.ndll
Previously, we added these rpaths to lime.ndll when it was built in commits c70ec9f and 333d093, but it's actually necessary only for Neko, so now I made it happen specfically after calling `nekotools boot` to create the Neko executable. I've tested cpp and hl, and I've confirmed that the executables still launch successfully when these rpaths are omitted. It's better for their security to use fewer rpaths. As noted commit c70ec9f, adding these rpaths is necessary due to a change in Xcode 15 where /usr/local/lib used to be available on the rpath automatically, but now it isn't, which affects the executable's ability to find the libneko dylib.
1 parent 4485246 commit 4793649

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

project/Build.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,6 @@
442442
</section>
443443

444444
<section if="mac">
445-
<!--
446-
starting in xcode 15, rpath doesn't automatically include
447-
/usr/local/lib, but we need it for neko
448-
-->
449-
<vflag name="-rpath" value="/usr/local/lib" />
450-
<vflag name="-rpath" value="/opt/homebrew/lib" if="HXCPP_ARM64"/>
451-
452445
<vflag name="-l" value="iconv" />
453446
<vflag name="-framework" value="IOKit" />
454447
<vflag name="-framework" value="Foundation" />

tools/platforms/MacPlatform.hx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package;
22

33
import lime.tools.HashlinkHelper;
44
import hxp.Haxelib;
5+
import hxp.HostArchitecture;
56
import hxp.HXML;
67
import hxp.Log;
78
import hxp.Path;
@@ -188,6 +189,17 @@ class MacPlatform extends PlatformTarget
188189

189190
NekoHelper.createExecutable(project.templatePaths, "mac" + dirSuffix.toLowerCase(), targetDirectory + "/obj/ApplicationMain.n", executablePath);
190191
NekoHelper.copyLibraries(project.templatePaths, "mac" + dirSuffix.toLowerCase(), executableDirectory);
192+
193+
// starting in xcode 15, rpath doesn't automatically include
194+
// /usr/local/lib, but we need it for libneko dylib
195+
System.runCommand("", "install_name_tool", ["-add_rpath", "/usr/local/lib", Path.join([executableDirectory, "lime.ndll"])]);
196+
if (System.hostArchitecture == HostArchitecture.ARM64)
197+
{
198+
// on Apple Silicon, the user may have installed Neko with
199+
// Homebrew, which has a different path. however, if the
200+
// Homebrew path doesn't exist, that's okay.
201+
System.runCommand("", "install_name_tool", ["-add_rpath", "/opt/homebrew/lib", Path.join([executableDirectory, "lime.ndll"])]);
202+
}
191203
}
192204
else if (targetType == "hl")
193205
{

0 commit comments

Comments
 (0)