-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Building for macOS-x86_64 but attempting to link with file built for macOS-arm64 #50
Comments
Make sure to do It should show a file, otherwise that is the issue. Also please just copy and paste terminal output as text instead of as images (much easier to parse and work with). |
Ah seeing the issue now .. the file is there but it cannot link it since it's built for a different architecture.
In your case you may have to change it so that Rust compiles an architecture that is compat with Flutter. |
Yes, M1 chip indeed! @thlorenz
also, you asked
Indeed, the file is here: -rw-r--r-- 1 romain staff 17045752 Oct 20 09:57 plugin/macos/libagent.a more detailsIn the meantime I found out mentions of the issue with architecture related to M1 + Cocoapods / XCode on Stackoverflow and finally stumbled upon the So I tried updating it to x86_64-apple-darwin: rustup target add x86_64-apple-darwin Then updated ./sh/bindgen && ./sh/macos && flutter run -d macos Which builds fine, but keep crashing with the same error on |
Actually you're right You want to look into rust cross compilation in order to force the target via the It could be as simple as changing the
What you did so far (adding another rust target via Hope this helps. I don't have an M1, so I cannot reproduce this unfortunately, but please ask more questions if things don't work out. |
Ok so far as you suggested I've tried with I've started to wonder if it's also related to #!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR/.. && cargo run --target=x86_64-apple-darwin --bin=rid_build which yielded a different error: β― ./sh/bindgen && ./sh/macos && flutter run -d macos
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
Running `/Users/romain/Development/sandbox/dataterm/target/x86_64-apple-darwin/debug/rid_build rid_build`
2021-10-20 23:00:43,641 INFO [rid_build] Generating bindings
2021-10-20 23:00:44,091 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::RidVec.
2021-10-20 23:00:44,094 INFO [rid_build] Generating Dart glue code
2021-10-20 23:00:44,094 INFO [rid_build] Injecting Swift code into plugin
2021-10-20 23:00:44,096 DEBUG [rid_build::ffigen::run_ffigen] Running '"dart" "run" "ffigen" "--config" "/var/folders/f9/wg0kh90517b1y_stm7qc0ztc0000gn/T/.tmp5QGfkI/ffigen_config.yaml"' from: '"/Users/romain/Development/sandbox/dataterm/agent"'
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
Launching lib/main.dart on macOS in debug mode...
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:x86_64, id:DD7B1F9D-D0BA-5DB5-8574-1DC73431BFAC }
{ platform:macOS, name:Any Mac }
lib/main.dart:9:9: Error: Type 'Store' not found.
final Store _store = Store.instance;
^^^^^
lib/main.dart:24:9: Error: Type 'Store' not found.
final Store _store;
^^^^^
plugin/lib/generated/rid_api.dart:180:1: Error: Type 'ffigen_bind.NativeLibrary' not found.
ffigen_bind.NativeLibrary _initRidFFI() {
^^^^^^^^^^^^^^^^^^^^^^^^^
lib/main.dart:9:9: Error: 'Store' isn't a type.
final Store _store = Store.instance;
^^^^^
lib/main.dart:9:24: Error: Getter not found: 'Store'.
final Store _store = Store.instance;
^^^^^
lib/main.dart:24:9: Error: 'Store' isn't a type.
final Store _store;
^^^^^
plugin/lib/generated/rid_api.dart:183:10: Error: Method not found: 'NativeLibrary'.
return ffigen_bind.NativeLibrary(_dl);
^^^^^^^^^^^^^
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
** BUILD FAILED **
Building macOS application...
Exception: Build process failed Looking closely at it, it appears that 2021-10-20 23:18:28,665 INFO [rid_build] Generating bindings
2021-10-20 23:18:29,267 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::Store - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
2021-10-20 23:18:29,267 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::Msg.
2021-10-20 23:18:29,267 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::Reply.
2021-10-20 23:18:29,274 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::_to_dart_for_Store.
2021-10-20 23:18:29,276 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_debug.
2021-10-20 23:18:29,276 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_debug_pretty.
2021-10-20 23:18:29,276 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::RidStoreAccess - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
2021-10-20 23:18:29,277 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::create_store.
2021-10-20 23:18:29,280 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_lock.
2021-10-20 23:18:29,280 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_unlock.
2021-10-20 23:18:29,282 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_free.
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_store_count.
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::_include_Store_field_wrappers.
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::str - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::CString - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_cstring_free.
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_init_msg_isolate.
2021-10-20 23:18:29,283 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_init_reply_isolate.
2021-10-20 23:18:29,290 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_msg_Inc.
2021-10-20 23:18:29,290 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::rid_msg_Add.
2021-10-20 23:18:29,295 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::include_reply.
2021-10-20 23:18:29,295 INFO [cbindgen::bindgen::parser] Take rid_agent_expanded::RidVec. Could this be that |
By the way my local Dart version is: β― dart --version
Dart SDK version: 2.14.4 (stable) (Wed Oct 13 11:11:32 2021 +0200) on "macos_x64" I'll try looking at |
Wow I honestly have no idea at this point what's going on, but the errors you're seeing originate from this step Try running each step one by one and look at the error messages in isolation. Another thing I'd suggest is jumping into the root of the rid repo and running Then you could just try to get the Dart only example to build and run. Otherwise could you maybe launch your terminal with Rosetta and see if that works around M1 issues? |
Yes
I did, it yielded the same errors.
Interestingly enough, it did fail on:
|
This error seems to be the problem:
You may have some broken install there. |
I had this issue a few times, and I usually got it to go away by running |
oh thanks ! I can't test it right away but let me get back to you on Monday π |
@thlorenz @SecondFlight well actually I finally found out and it was ... actually way simpler than expected π additional installbut ffi version must be installed for M1 chip arch like this: arch -x86_64 sudo gem install ffi sh/bindgen# ...
cargo run --target=x86_64-apple-darwin --bin=rid_build sh/macos# ...
# TARGET_DIR
# -------------
# first problem is that, on typical build
# binary and files are placed under `/target` folder
# while when compiling for M1 chip arch these are placed under `/target/x86_64-apple-darwin` folder,
# so basically TARGET_DIR has to be updated in this context
# ...
cargo build --target=x86_64-apple-darwin && \
cp $LIB_SOURCE_FILE $LIB_TARGET_FILE I don't really remember when it's necessary to run I was super happy to see the Counter App run on screen ! |
Awesome @Roms1383. I'm delighted you finally got it to work! Could we add a section to rid's README? Would you be willing to provide a PR with it? Using rid with an M1 Macbook |
@thlorenz Utterly ok for the section in the README, I can do it in the following days π On a broader scale, my feeling here is that |
Awesome, gonna look out for that PR π Also WRT to CLI tool that is already on the roadmap and I totally agree that we need something like this. I kept things driven by scripts to learn a bit more about what actually we need it todo. Obviously you can also develop this inside a fork of this monorepo as well ... |
Well, I'm gonna take a stab at it in a couple of weeks ahead, and see what I can get done. |
I don't think this is specific to ARM. I just got the same error on a recent x86 Mac running Big Sur. I got stuck trying to install the Just a quick sanity check: is the |
@SecondFlight I remember I had to install the |
A few updates:
|
Thanks for the update. Please keep posting updates in this issue and feel free to provide more PRs with updates to the README that help others get rid setup correctly. |
Trying on an M1 but can't get the flutter run -d macOS to pass. Have nearly the same error message as @Roms1383 , followed instructions to the T, cleaning and redoing several times with the same error. My
|
@Roms1383 Does your build work on the iOS simulator? |
@enzotar I'm sorry, My memory about ld: symbol(s) not found for architecture x86_64 is usually due to having arch -x86_64 sudo gem install ffi |
I did run it. I thoroughly followed your thread, but somehow still get the
error message when running for macOS. Then I tried for iOS and updated
xcode to match the x86_64 architecture for builds, but still no luck.
β¦On Sun, Feb 13, 2022, 6:49 PM Roms1383 ***@***.***> wrote:
@enzotar <https://github.com/enzotar> I'm sorry,
actually I didn't have the opportunity to get back on tinkering with rid
since December now.
My memory about rid install process a bit rusty tbh,
but as far as I remember this error:
ld: symbol(s) not found for architecture x86_64
is usually due to having ffi installed for the wrong architecture on your
machine, did you run ?
arch -x86_64 sudo gem install ffi
β
Reply to this email directly, view it on GitHub
<#50 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIKTHU37OSC45QGOLPO263TU3BUSZANCNFSM5GJEI63A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sadly I don't have time to look further into it these days (quite busy with work and other concerns). Still, here's my M1 configuration on my last (successful) run as a desktop app, hope this helps: bindgen-m1.sh#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR/.. && cargo run --target=x86_64-apple-darwin --bin=rid_build macos-m1.sh#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
MACOS_TARGETS=aarch64-apple-ios
TARGET_DIR=`cargo metadata --format-version 1 --no-deps | jq ".target_directory" | xargs echo`
PROJECT_NAME=`cargo metadata --format-version 1 | jq ".resolve.root" | xargs echo | cut -d ' ' -f1`
LIB_NAME=lib$PROJECT_NAME.a
# <root>/target/universal/debug
UNIVERSAL_DEBUG_DIR="$TARGET_DIR/x86_64-apple-darwin/debug" # π don't forget to update according to your install
FLUTTER_MACOS_DIR="$DIR/../plugin/macos" # π don't forget to update according to your install
LIB_SOURCE_FILE="$UNIVERSAL_DEBUG_DIR/$LIB_NAME"
LIB_TARGET_FILE="$FLUTTER_MACOS_DIR/$LIB_NAME"
cargo build --target=x86_64-apple-darwin && \
cp $LIB_SOURCE_FILE $LIB_TARGET_FILE I would then run: ./sh/bindgen-m1 && ./sh/macos-m1 && flutter run -d macos |
Notice how each |
Thanks. Yes, same configuration but somehow not working. I'll dig some more. |
Found a workaround. @thlorenz Would love to get your feedback on how safe the workaround is and whether you can identify the issue. Everytime I run bindgen, at random, in addition to some 100 others, some new functions get inserted to the dummyCallsToPreventTreeShaking() in the Plugin.swift file. Sometimes just 1, sometimes several. Every bindgen has a different output. And all start with "__include_dart_for" and are usually associated with some Vector or HashMap I have annotated with Rid in Rust. And when I run
And to make it work, I comment it out in the Plugin.swift file.
And so I run bindgen maybe ten times, to get only one of them to show, so I can comment only one function and not multiple. |
This might be leading to the issue. I get the below error but only every 100 builds or so which makes it hard to run the backtrace. And it only happens with the 'Composite' types Vec, HashMap.
|
Hello ! and sorry to come back with another issue ^^'
description
So far I have
./sh/bindgen
,./sh/macos
and./sh/ios
running just fine βbut I keep having architecture related issue when running
flutter run
π₯I ended up reinstalling from
rid-template-flutter
again (from commit 70dbfd0), and got the same result:context
local machine
versions
I'm not familiar with the build tooling like XCode etc so apologies if this is a beginner question π
The text was updated successfully, but these errors were encountered: