Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MacPlatform: use install_name_tool to add /usr/local/lib and /opt/hom…
…brew/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.
- Loading branch information
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this not break lime tools?
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobil4sk I didn't have any issues running Lime tools after this change (and I definitely had to rebuild Lime tools to try it). As I understand it, Lime tools runs on the system neko executable, which wouldn't work for non-Lime projects either, if it couldn't find libneko. But Lime projects built for Neko use
nekotools boot
, which is where the rpath issue comes in.4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I originally ran into this error in #1750, lime tools didn't work at all without the rpath set for lime.ndll. I'm not sure if this has changed, I'm not able to test this currently.
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's strange. It kind of sounds like Homebrew isn't building Neko properly.
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshtynjala Does the executable itself not load libneko as well? The binary built with nekotools boot should have the same rpath as the neko binary. In that case maybe we shouldn't need the rpath on lime.ndll for neko builds either?
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobil4sk If I run
otool -L /usr/local/lib/neko/neko
, @rpath/libneko.2.dylib is listed. It's the same for anekotools boot
executable.If I run
otool -lV /usr/local/lib/neko/neko | grep -B 1 -A 2 LC_RPATH
, theLC_RPATH
value is @executable_path/. Again, same for anekotools boot
executable.Having used the official Haxe installer for macOS, neko and libneko are in the same directory (in this case, /usr/local/lib/neko), so it seems to be using @executable_path/ there.
I don't have a Homebrew version of Neko installed at this time to test the results of
otool -L
andotool -l
, and I don't particularly feel like going through that effort today.For a Lime-built Neko executable, we aren't copying libneko to go with
nekotools boot
, so we have been relying on rpath to find libneko. Before Xcode 15, apparently /usr/local/lib was implicitly on the rpath, and there's a linked libneko in that directory too. Starting with Xcode 15, /usr/local/lib is no longer implicitly on the rpath, for whatever reason Apple decided on. This made our Lime neko builds break. Oddly, the rpath of lime.ndll seems to be affecting the Neko executable. Or maybenekotools boot
is using Xcode somehow. Regardless, we're now adding /usr/local/lib explicitly to the rpath to restore the old behavior before Xcode 15 stopped adding that directory implicitly to the rpath.I am still considering the possibility of copying libneko into our .app bundle, and it will kill two birds with one stone. 1) We won't need to mess with the rpath. 2) the .app bundle will work without the user having to install Neko.
4793649
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshtynjala The difference could be that the installer build might have been built with a version of xcode older than 15, but the homebrew builds are probably built using the newer version of xcode.