launchk icon indicating copy to clipboard operation
launchk copied to clipboard

Compiling on M1 arch Mac...

Open dillera opened this issue 3 years ago • 1 comments

Hello, nice project - there is an issue w/ building on my M1 mac.

$ RUST_BACKTRACE=full cargo build
   Compiling xpc-sys v0.1.0 (/Users/dillera/code/launchk/xpc-sys)
error: failed to run custom build command for `xpc-sys v0.1.0 (/Users/dillera/code/launchk/xpc-sys)`

Caused by:
  process didn't exit successfully: `/Users/dillera/code/launchk/target/debug/build/xpc-sys-01feba28ada025d9/build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'libclang error; possible causes include:
  - Invalid flag syntax
  - Unrecognized flags
  - Invalid flag arguments
  - File I/O errors
  - Host vs. target architecture mismatch
  If you encounter an error missing from this list, please file an issue or a PR!', /Users/dillera/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/ir/context.rs:573:15
  stack backtrace:
     0:        0x100c0c614 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b35424d98a84d2e
     1:        0x100c36ad0 - core::fmt::write::h66f440bd230d5049
     2:        0x100c0676c - std::io::Write::write_fmt::h5f96133b528343e9
     3:        0x100c1a898 - std::panicking::default_hook::{{closure}}::h30a27193d23180ec
     4:        0x100c1a5ec - std::panicking::default_hook::h200a4c4ea2ec4037
     5:        0x100c1ad4c - std::panicking::rust_panic_with_hook::hf19f16435a47814d
     6:        0x100c0cad0 - std::panicking::begin_panic_handler::{{closure}}::h7d30afed417a766c
     7:        0x100c0c754 - std::sys_common::backtrace::__rust_end_short_backtrace::hafb39ae92d7ecfa2
     8:        0x100c1a988 - _rust_begin_unwind
     9:        0x100c3cef8 - core::panicking::panic_fmt::h266736c2dfe1041a
    10:        0x100c3cad4 - core::option::expect_failed::h08b745f41456567e
    11:        0x10090cf14 - core::option::Option<T>::expect::h57c56808794faea3
                                 at /private/tmp/rust-20210109-48369-1kpc7mp/rustc-1.49.0-src/library/core/src/option.rs:349:21
    12:        0x1007f63a0 - bindgen::ir::context::BindgenContext::new::h1754a239b8c2388e
                                 at /Users/dillera/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/ir/context.rs:567:13
    13:        0x100918ea4 - bindgen::Bindings::generate::h7873b7760afa6090
                                 at /Users/dillera/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/lib.rs:2106:27
    14:        0x100916fe4 - bindgen::Builder::generate::h9e1dfbc29e69744c
                                 at /Users/dillera/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.53.3/src/lib.rs:1419:9
    15:        0x10079cb7c - build_script_build::main::h46e3bd2278cbf846
                                 at /Users/dillera/code/launchk/xpc-sys/build.rs:23:20
    16:        0x10079c340 - core::ops::function::FnOnce::call_once::h2436943b26989654
                                 at /private/tmp/rust-20210109-48369-1kpc7mp/rustc-1.49.0-src/library/core/src/ops/function.rs:227:5
    17:        0x10079bc44 - std::sys_common::backtrace::__rust_begin_short_backtrace::haf465ac0d2257dae
                                 at /private/tmp/rust-20210109-48369-1kpc7mp/rustc-1.49.0-src/library/std/src/sys_common/backtrace.rs:125:18
    18:        0x10079b470 - std::rt::lang_start::{{closure}}::h6fd6a33a0130abc8
                                 at /private/tmp/rust-20210109-48369-1kpc7mp/rustc-1.49.0-src/library/std/src/rt.rs:66:18
    19:        0x100c1f17c - std::rt::lang_start_internal::h5a4531374b5aaa0d
    20:        0x10079b448 - std::rt::lang_start::h6ae75154879f8b6a
                                 at /private/tmp/rust-20210109-48369-1kpc7mp/rustc-1.49.0-src/library/std/src/rt.rs:65:5
    21:        0x10079cdf4 - _main

$ llvm-config --version 11.1.0

MacBookAir10,1 with the Apple M1 chip

MacOS 11.2.1.

$ clang --version clang version 11.1.0 Target: arm64-apple-darwin20.3.0 Thread model: posix InstalledDir: /opt/homebrew/opt/llvm/bin

dillera avatar Mar 01 '21 15:03 dillera

https://github.com/mach-kernel/launchk/blob/ef9b8708696c1affd9510fe333e1a4fa597947e8/xpc-sys/Cargo.toml#L14

It seems like the Cargo.toml of xpc-sys hard-coded x86_64-apple-darwin as the only target. I have built successfully by changing this line to

targets = ["x86_64-apple-darwin", "aarch64-apple-darwin"]

gnattu avatar Aug 18 '22 05:08 gnattu