desbma / rsop

Simple, fast & configurable tool to open and preview files
MIT License
22 stars 3 forks source link

When I use the --release flag, I get errors on MacOS Sonoma (14.3.1) #5

Open cskeeters opened 2 months ago

cskeeters commented 2 months ago

When I use the --release flag, I get errors.

$ cargo build --release
   Compiling proc-macro2 v1.0.83
   Compiling libc v0.2.155
   Compiling syn v1.0.109
   Compiling rustversion v1.0.17
   Compiling anstyle-query v1.0.3
error: failed to run custom build command for `proc-macro2 v1.0.83`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/proc-macro2-21fb11b2b8742029/build-script-build` (signal: 9, SIGKILL: kill)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libc v0.2.155`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/libc-9cfb5571b05c3f32/build-script-build` (signal: 9, SIGKILL: kill)
error: failed to run custom build command for `syn v1.0.109`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/syn-5fedb5aa04aaafd7/build-script-build` (signal: 9, SIGKILL: kill)
error: failed to run custom build command for `rustversion v1.0.17`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/rustversion-f8b6e1301ec0ffc4/build-script-build` (signal: 9, SIGKILL: kill)

Without the --release flag, it compiles fine.

To get more information, I tried the --verbose flag and not much more helpful info was provided.

$ cargo build --release --verbose
   Compiling proc-macro2 v1.0.83
       Fresh unicode-ident v1.0.12
       Fresh memchr v2.7.2
       Fresh tinyvec_macros v0.1.1
       Fresh utf8parse v0.2.1
       Fresh cc v1.0.98
       Fresh colorchoice v1.0.1
     Running `/Users/chad/working/rsop/target/release/build/proc-macro2-21fb11b2b8742029/build-script-build`
   Compiling libc v0.2.155
       Fresh anstyle-parse v0.2.4
   Compiling syn v1.0.109
       Fresh tinyvec v1.6.0
   Compiling rustversion v1.0.17
       Fresh cfg-if v1.0.0
       Fresh hashbrown v0.14.5
       Fresh anstyle-query v1.0.3
     Running `/Users/chad/working/rsop/target/release/build/libc-9cfb5571b05c3f32/build-script-build`
     Running `/Users/chad/working/rsop/target/release/build/syn-5fedb5aa04aaafd7/build-script-build`
     Running `/Users/chad/working/rsop/target/release/build/rustversion-f8b6e1301ec0ffc4/build-script-build`
       Fresh equivalent v1.0.1
       Fresh gimli v0.28.1
       Fresh is_terminal_polyfill v1.70.0
   Compiling anstyle v1.0.7
     Running `/Users/chad/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name anstyle --edition=2021 /Users/chad/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anstyle-1.0.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=283 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 '--warn=clippy::zero_sized_map_values' '--warn=clippy::wildcard_imports' '--warn=clippy::verbose_file_reads' --warn=unused_qualifications --warn=unused_macro_rules --warn=unused_lifetimes --warn=unsafe_op_in_unsafe_fn --warn=unreachable_pub '--warn=clippy::trait_duplication_in_bounds' '--warn=clippy::todo' '--warn=clippy::string_to_string' '--warn=clippy::string_lit_as_bytes' '--warn=clippy::string_add_assign' '--warn=clippy::string_add' '--warn=clippy::str_to_string' '--warn=clippy::single_match_else' '--warn=clippy::semicolon_if_nothing_returned' '--warn=clippy::self_named_module_files' '--warn=clippy::same_functions_in_if_condition' --warn=rust_2018_idioms '--warn=clippy::rest_pat_in_fully_bound_structs' '--warn=clippy::ref_option_ref' '--warn=clippy::redundant_feature_names' '--warn=clippy::rc_mutex' '--warn=clippy::ptr_as_ptr' '--warn=clippy::path_buf_push_overwrite' '--warn=clippy::negative_feature_names' '--warn=clippy::needless_for_each' '--warn=clippy::needless_continue' '--warn=clippy::mutex_integer' '--warn=clippy::mem_forget' '--warn=clippy::match_wildcard_for_single_variants' '--warn=clippy::macro_use_imports' '--warn=clippy::lossy_float_literal' '--warn=clippy::linkedlist' '--allow=clippy::let_and_return' '--warn=clippy::large_types_passed_by_value' '--warn=clippy::large_stack_arrays' '--warn=clippy::large_digit_groups' '--warn=clippy::items_after_statements' '--warn=clippy::invalid_upcast_comparisons' '--warn=clippy::infinite_loop' '--warn=clippy::inefficient_to_string' '--warn=clippy::inconsistent_struct_constructor' '--warn=clippy::imprecise_flops' '--warn=clippy::implicit_clone' '--allow=clippy::if_same_then_else' '--warn=clippy::from_iter_instead_of_collect' '--warn=clippy::fn_params_excessive_bools' '--warn=clippy::float_cmp_const' '--warn=clippy::flat_map_option' '--warn=clippy::filter_map_next' '--warn=clippy::fallible_impl_from' '--warn=clippy::explicit_into_iter_loop' '--warn=clippy::explicit_deref_methods' '--warn=clippy::expl_impl_clone_on_copy' '--warn=clippy::enum_glob_use' '--warn=clippy::empty_enum' '--warn=clippy::doc_markdown' '--warn=clippy::debug_assert_with_mut_call' '--warn=clippy::dbg_macro' '--warn=clippy::create_dir' '--allow=clippy::collapsible_else_if' '--warn=clippy::checked_conversions' '--allow=clippy::branches_sharing_code' '--allow=clippy::bool_assert_comparison' --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=048fb9ee88865e0e -C extra-filename=-048fb9ee88865e0e --out-dir /Users/chad/working/rsop/target/release/deps -C strip=symbols -L dependency=/Users/chad/working/rsop/target/release/deps --cap-lints allow`
error: failed to run custom build command for `proc-macro2 v1.0.83`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/proc-macro2-21fb11b2b8742029/build-script-build` (signal: 9, SIGKILL: kill)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `syn v1.0.109`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/syn-5fedb5aa04aaafd7/build-script-build` (signal: 9, SIGKILL: kill)
error: failed to run custom build command for `libc v0.2.155`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/libc-9cfb5571b05c3f32/build-script-build` (signal: 9, SIGKILL: kill)
error: failed to run custom build command for `rustversion v1.0.17`

Caused by:
  process didn't exit successfully: `/Users/chad/working/rsop/target/release/build/rustversion-f8b6e1301ec0ffc4/build-script-build` (signal: 9, SIGKILL: kill)

I'm new to rust, so this might be a simple skill issue on my part. Please advise.

desbma commented 2 months ago

Is your Rust toolchain up to date? How did you install it?

You can try commenting out the lto = true line in Cargo.toml, but that should not be needed.

I can't help you much more because I am on Linux, and I get a very different error when cross compiling.

cskeeters commented 2 months ago

I was running rust 1.75.0.

I tried using brew install rust and then rustup via:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Both installed the latest rust tools (1.78.0) and resulted in the same errors. This appears to be a problem with rust on M1 processors.

https://github.com/rust-lang/cargo/issues/8913

cskeeters commented 2 months ago

I tried Terminal.app and arch -arm64e sh too and still got the same SIGKILL error.

cskeeters commented 2 months ago

Commenting out lto = true had no effect. Commenting out strip = true had no effect.

desbma commented 2 months ago

What's weird is that the error only occurs in release mode.

You can try overriding each option that is specific to the release profile, until you find the one that causes the error.

cskeeters commented 2 months ago

My testing shows that debug must be true. Also if I change strip from "none" (default) to true (as set by this project's Cargo.toml) it also fails.

reubenmiller commented 2 months ago

@cskeeters I just stumbled upon this issue since I was having a similar problem in another Rust project (thin-edge.io)...so just posting in case it is also helpful for you.

In the end my issue was with the homebrew binutils package, see the original issue in the rust project which goes into some more details.

To fix it, check which strip is used by default on your console:

which strip

If you get anything other than /usr/bin/strip, then you will need to check your PATH environment variable (maybe remove the binutils path from it if you did something similar to me).

Afterwards you will have to run cargo clean, then you should be able to build again.

cargo clean
cargo build --release
cskeeters commented 2 months ago

@reubenmiller, Thank you for this post. I can confirm that my path was configured to use strip from binutils. Without this path element, cargo build --release works fine.

That begs the question: What's going on? Why does gnu strip from binutils break cargo? Is this a bug or incompatibility? If it's a compatibility issue, could cargo not check strip's version for compatibility before utilization? If it's a bug has a bug been filed? I didn't see one on their bug tracker.