Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot cross-compile example to x86_64 on Apple Silicon #69

Open
pthexton opened this issue Jan 21, 2025 · 1 comment
Open

Cannot cross-compile example to x86_64 on Apple Silicon #69

pthexton opened this issue Jan 21, 2025 · 1 comment

Comments

@pthexton
Copy link

pthexton commented Jan 21, 2025

Hey all,

Can somebody please point me in the right direction here.. we're intending to make use of SwiftRs in one of our projects to avoid duplicating implementation for a specific shared functionality between apps where we have a pre-existing implementation in Swift. We currently need to distribute our apps as a universal binary.

Unfortunately, when attempting to build a universal binary I've discovered that something has gone wrong at the linker stage and I get an error related to not being able to load @rpath/libswiftCore.dylib

To make sure I hadn't done anything wrong, I've grabbed the example from this repo and I am seeing the same behaviour. Compiling and running the example natively on my Apple Silicon Mac works as expected, but when I compile for x86_64 architecture things don't work. Compile command in this case is cargo build --target x86_64-apple-darwin

  $ target/x86_64-apple-darwin/debug/example
dyld[31266]: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: <7923220E-4AA3-3374-AAC3-53D979383A00> /<snipped>/swift-rs-main/example/target/x86_64-apple-darwin/debug/example
  Reason: no LC_RPATH's found
zsh: abort      target/x86_64-apple-darwin/debug/example

I can modify the resulting binary by adding an rpath for /usr/lib/swift by doing install_name_tool -add_rpath /usr/lib/swift target/x86_64-apple-darwin/debug/example, then then results in the binary running as expected

$ target/x86_64-apple-darwin/debug/example
length of base64 encoded thumbnail: 1054264
First Volume Name: Macintosh HD
function returned nil: true
function returned data: true

But this doesn't feel like the "correct" solution to me.

Any help/advise greatly appreciated.

@pthexton
Copy link
Author

I should note that I have seen the mention of Tauri .... but we're not using that, and I'm unaware of how the tauri build system sets the build environment to correct this when the documented option is set appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant