-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
macOS library validation fails for FFI #39231
Comments
I've tried using Apple's
dart hello.dart
Unhandled exception:
Invalid argument(s): Failed to load dynamic library (dlopen(hello_world.dylib, 1): no suitable image found. Did find:
hello_world.dylib: code signature in (hello_world.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?))
#0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:10:55)
#1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:17:12)
#2 main (file:///Users/ryjohn/code/github/dart-lang/samples/ffi/hello_world/hello.dart:17:36)
#3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) |
Yeah, this is a duplicate of #38314, please add more details there. |
I have a slightly different error:
Update: |
I get this on Mac M1, is this related somehow or something new altogether?
|
Mac M1 is an arm64 chip, while all previous MacOS computers were x64. So, the dylib has to be compiled for arm64. Where did you get the dylib from? Did you compile it yourself? Please open a new issue if you have further problems, is this is a separate issue from validation. |
Thanks @dcharkes I actually followed the OP's ffi sample instructions to get a simple reproducible error BTW it generates arm64 as you can see below... Let me know if I should raise this as a new issue $> file libhello.1.0.0.dylib
libhello.1.0.0.dylib: Mach-O 64-bit dynamically linked shared library arm64 |
@gerardsimons you might be running in x64 emulation mode, in which case you'd actually want to have a dylib compiled for x64 instead. https://en.wikipedia.org/wiki/Rosetta_(software) |
Actually it's true that I was running in emulation mode as I thought that was the issue, but I just turned it off and that doesn't work either (see screenshot) However: running my terminal in emulation mode and recompiling makes an x64 library and then the hello.dart works (see next screenshot), so that's basically the old way of doing it on x64 Mac |
Ah actually once you have the library built in x64 you can run dart either way (x64 or arm64). I am guessing dart just forces Rosetta anyway |
We don't have an arm64 built dart yet as far as I know. Once we have it, I'll verify that FFI works on it (#44772). |
Cool beans, happy to test something out if needed ... keep up the good job! |
for future readers on apple silicon:
I was able to build leveldb as a shared lib and use it via |
Addition to @lesnitsky's comment, here is the complete steps on my workaround to build hello_world example in Apple Silicon: Install x86
Create Create corresponding aliases with this two commands. These can also be added to
From now on, use Install x86
Add the Now you can use x86 architecture |
It looks like #38288 has started happening again.
cd c && make dylib
cd .. && dart hello.dart
cc: @mit-mit @mjohnsullivan
The text was updated successfully, but these errors were encountered: