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

Unable to build on macOS m2 #1

Closed
tallamjr opened this issue Jun 13, 2024 · 0 comments · Fixed by #3
Closed

Unable to build on macOS m2 #1

tallamjr opened this issue Jun 13, 2024 · 0 comments · Fixed by #3
Assignees

Comments

@tallamjr
Copy link
Owner

A fresh install of pup fails to build on Apple M2 Sonoma 14.5.

(pup) 18:33:31 ✔ cargo clean && cargo build
     Removed 3254 files, 1.6GiB total
    Updating crates.io index
    Updating git repository `https://github.com/huggingface/candle.git`
    Updating git repository `https://github.com/rcastill/mat2image.git`
error: failed to select a version for the requirement `candle-core = "^0.4.0"`
candidate versions found which didn't match: 0.6.0
location searched: Git repository https://github.com/huggingface/candle.git
required by package `pup v0.1.0 (/Users/tallam/github/tallamjr/origin/pup)`

After updating the Cargo.toml file to match v0.6.0 for candle, the following error occurs:

  === Generated: core in 18.196518083s
  thread 'main' panicked at /Users/tallam/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.8/build/generator.rs:119:36:
  Generator process panicked: Any { .. }
  stack backtrace:
     0:        0x1025c421c - std::backtrace_rs::backtrace::libunwind::trace::he4f0a5f56afe8e37
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
     1:        0x1025c421c - std::backtrace_rs::backtrace::trace_unsynchronized::habb302958e80f800
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:        0x1025c421c - std::sys_common::backtrace::_print_fmt::h9819d35e2a5cda77
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:68:5
     3:        0x1025c421c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:44:22
     4:        0x1025e3320 - core::fmt::rt::Argument::fmt::h626862aa6242248a
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/rt.rs:165:63
     5:        0x1025e3320 - core::fmt::write::heedef092c8c0962e
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/fmt/mod.rs:1157:21
     6:        0x1025c0958 - std::io::Write::write_fmt::h7178e8e2ea928914
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/io/mod.rs:1832:15
     7:        0x1025c4074 - std::sys_common::backtrace::_print::ha0f584bc7bfb9d2b
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:47:5
     8:        0x1025c4074 - std::sys_common::backtrace::print::h417292deb95532ed
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:34:9
     9:        0x1025c57a8 - std::panicking::default_hook::{{closure}}::h0cb68f1228c4613a
    10:        0x1025c549c - std::panicking::default_hook::h24535936bc1f51de
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:298:9
    11:        0x1025c6060 - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:795:13
    12:        0x1025c5a90 - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
    13:        0x1025c46a4 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
    14:        0x1025c5800 - rust_begin_unwind
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
    15:        0x1026001fc - core::panicking::panic_fmt::hc2b459a5bd3dce66
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
    16:        0x1026005e4 - core::result::unwrap_failed::h88d7eb352f20b747
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:1654:5
    17:        0x102177e14 - core::result::Result<T,E>::expect::hd8965b36141f3d56
    18:        0x102181690 - build_script_build::generator::BindingGenerator::run::{{closure}}::hc5b069ba334404e7
    19:        0x1021909c4 - std::thread::scoped::scope::{{closure}}::h71fb584dc074dd60
    20:        0x102192fa0 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h495a652218759b2d
    21:        0x102190b24 - std::panicking::try::do_call::hd3fc0800c2662636
    22:        0x102192e98 - ___rust_try
    23:        0x102190ab8 - std::panicking::try::ha4ea956364f339b4
    24:        0x1021907e0 - std::thread::scoped::scope::hbf4af47715b70986
    25:        0x1021813a4 - build_script_build::generator::BindingGenerator::run::h9e287aacc7530955
    26:        0x1021809d4 - build_script_build::generator::BindingGenerator::generate_wrapper::h2df02edeb7e7dca1
    27:        0x1021a6564 - build_script_build::main::h92c244efe232b274
    28:        0x102193d1c - core::ops::function::FnOnce::call_once::hcb92fec8d7b86c39
    29:        0x10217d27c - std::sys_common::backtrace::__rust_begin_short_backtrace::h318d1c966e78bd08
    30:        0x10219052c - std::rt::lang_start::{{closure}}::h595fe049a0b92159
    31:        0x1025ba6ec - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2f86a413382a979d
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:284:13
    32:        0x1025ba6ec - std::panicking::try::do_call::hd40c9eb4d233b111
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
    33:        0x1025ba6ec - std::panicking::try::h13ac68ffa70c387b
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
    34:        0x1025ba6ec - std::panic::catch_unwind::habea7b6fc986e966
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
    35:        0x1025ba6ec - std::rt::lang_start_internal::{{closure}}::h6b16436250c3cf62
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:48
    36:        0x1025ba6ec - std::panicking::try::do_call::h9970b928a0b20951
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
    37:        0x1025ba6ec - std::panicking::try::h4dfbe3cb4cc8f253
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
    38:        0x1025ba6ec - std::panic::catch_unwind::hf6a5e1e8ce5a10f5
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
    39:        0x1025ba6ec - std::rt::lang_start_internal::hecc68fef83c8f44d
                                 at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:20
    40:        0x102190504 - std::rt::lang_start::h7ecc524e215ec39d
    41:        0x1021a6cc4 - _main
warning: build failed, waiting for other jobs to finish...

This implies an issue with open-cv crate. Upon investigation, the following issue gave some clues: twistedfall/opencv-rust#548, specifically twistedfall/opencv-rust#548 (comment) suggests that the bug is caused by https://github.com/twistedfall/opencv-rust/blob/985af46844b74581d38325561b5baa240292c797/binding-generator/src/field.rs#L153 with a PR to be merged found at KyleMayes/clang-rs#58 that will fix things.

Later, it was announced in twistedfall/opencv-rust#548 (comment) that an update to opencv-rust should resolve this if bumped to opencv = "=0.91.3".

Though, because of this update to mat2image crate: rcastill/mat2image@7bc3cc7 it seems to cause the following error when fixing to the opencv-rust version above:

   Compiling pup v0.1.0 (/Users/tallam/github/tallamjr/origin/pup)
error[E0599]: the method `to_image` exists for struct `Mat`, but its trait bounds were not satisfied
     --> src/main.rs:452:40
      |
452   |             let original_image = frame.to_image()?;
      |                                        ^^^^^^^^ method cannot be called on `Mat` due to unsatisfied trait bounds
      |
     ::: /Users/tallam/github/tallamjr/origin/pup/target/debug/build/opencv-9aef8a2551c7da9a/out/opencv/core.rs:19719:2
      |
19719 |     pub struct Mat {
      |     -------------- doesn't satisfy `_: MatTraitConstManual` or `opencv::prelude::Mat: ToImage`
      |
      = note: the following trait bounds were not satisfied:
              `opencv::prelude::Mat: opencv::manual::core::mat::MatTraitConstManual`
              which is required by `opencv::prelude::Mat: ToImage`

warning: unused import: `mat2image::ToImage`
  --> src/main.rs:12:5
   |
12 | use mat2image::ToImage;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `pup` (bin "pup") generated 1 warning
error: could not compile `pup` (bin "pup") due to 1 previous error; 1 warning emitted

Then if we fix mat2image crate to a revision immediately prior to that change, i.e. in the Cargo.toml set:

mat2image = { git = "https://github.com/rcastill/mat2image.git", rev = "f222cb14"}

we in theory should be Ok, but the following error still occurs:

   Compiling pup v0.1.0 (/Users/tallam/github/tallamjr/origin/pup)
error[E0599]: no method named `to_image` found for struct `opencv::prelude::Mat` in the current scope
   --> src/main.rs:452:40
    |
452 |             let original_image = frame.to_image()?;
    |                                        ^^^^^^^^ method not found in `Mat`

warning: unused import: `mat2image::ToImage`
  --> src/main.rs:12:5
   |
12 | use mat2image::ToImage;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `pup` (bin "pup") generated 1 warning
error: could not compile `pup` (bin "pup") due to 1 previous error; 1 warning emitted

This can go one of two ways, either put on ice until tools are updated elsewhere, or try to use Github Actions to build for other platforms than macOS and compare outputs. TBD 🤔 ...

tallamjr added a commit that referenced this issue Jun 13, 2024
@tallamjr tallamjr self-assigned this Jun 13, 2024
tallamjr added a commit that referenced this issue Jun 24, 2024
Avoids mat2image crate due to previous build errors. See description
listed in #1

	modified:   src/main.rs
tallamjr added a commit that referenced this issue Jun 24, 2024
Avoids mat2image crate due to previous build errors. See description
listed in #1

	modified:   src/main.rs
tallamjr added a commit that referenced this issue Jun 24, 2024
* Attempting to fix build issues

See #1 for details.

* Trial CI build

* Test CI build on macos-13, only

	modified:   .github/workflows/rust.yml
	modified:   Cargo.toml

* Ensure opencv installed

* Remove dummy package

* Dirty fix to macos-13 runner errors

* fixup

* Add cache option and ensure Xcode installed

* Fn for mat -> dynamic image conversion

Avoids mat2image crate due to previous build errors. See description
listed in #1

	modified:   src/main.rs

* Clean build option for current working version

Use latest linker for Xcode

* wip: build script/options for x-compiling in CI

	new file:   .github/workflows/build.yml
	new file:   __build.rs
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

Successfully merging a pull request may close this issue.

1 participant