Description
Sorry in advance if I messed this up but I've never bothered to report a bug before. I'm not sure if this even is a bug
Here's all the important-looking stuff:
thread 'coordinator' panicked at /private/tmp/rust-20250515-8123-mdgm7y/rustc-1.87.0-src/compiler/rustc_codegen_ssa/src/back/write.rs:1692:29:
/private/tmp/rust-20250515-8123-mdgm7y/rustc-1.87.0-src/compiler/rustc_codegen_ssa/src/back/write.rs:1692:29: worker thread panicked
note: rustc 1.87.0 (17067e9 2025-05-09) (Homebrew) running on aarch64-apple-darwin
note: compiler flags: --crate-type staticlib --crate-type cdylib --crate-type rlib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]
error: unable to copy /Users/burakunlu/rust/compressor/compressor_tauri/src-tauri/target/debug/incremental/compressor_tauri_lib-08bee5v42d0id/s-h8iowq8lvm-1btnd36-working/59tyakjllmb4oichnejy2o23a.o to /Users/burakunlu/rust/compressor/compressor_tauri/src-tauri/target/debug/deps/compressor_tauri_lib.59tyakjllmb4oichnejy2o23a.rcgu.o: No such file or directory (os error 2)
Code
#[tauri::command]
pub fn parallel_compress() -> Vec<CompressionResult> {
let input_path = get_input_path();
let output_path = get_output_path();
println!("Input path: {}", input_path.display());
println!("Output path: {}", output_path.display());
// Clear the output folder before compressing new images
crate::utility::clear_output_folder().expect("Failed to clear output folder");
fs::create_dir_all(&output_path).expect("Failed to recreate output directory");
println!("Output folder cleared and recreated.");
//wait a few milliseconds to ensure the folder is cleared
std::thread::sleep(std::time::Duration::from_millis(500));
let input_files: Vec<PathBuf> = match fs::read_dir(&*input_path) {
Ok(entries) => entries
.filter_map(|res| res.ok())
.map(|e| e.path())
.filter(|p| p.is_file())
.collect(),
Err(e) => {
eprintln!("Failed to read directory: {}", e);
Vec::new()
}
};
println!("Found {} input files.", input_files.len());
let results: Vec<CompressionResult> = input_files.par_iter().filter_map(|input| {
let file_stem = input.file_stem().unwrap().to_string_lossy();
let ext = input.extension().unwrap().to_string_lossy();
let compressed_path = output_path.join(format!("{}_compressed.{}", file_stem, ext));
let original_size: u64 = std::fs::metadata(&input)
.map(|metadata| metadata.len())
.unwrap_or(0);
println!("Compressing: {} to {}", input.display(), compressed_path.display());
println!("Input exists? {}", input.exists());
let mut comp = Compressor::new(&input, &compressed_path);
comp.set_factor(Factor::new(0.8, 1.0));
match comp.compress_to_jpg() {
Ok(_) => {
println!("Success!! Compressed: {} to {}", input.display(), compressed_path.display());
let compressed_size = std::fs::metadata(&compressed_path)
.map(|metadata| metadata.len())
.unwrap_or(0);
let reduction_percent = if original_size > 0 {
100.0 * (original_size as f32 - compressed_size as f32) / original_size as f32
} else {
0.0
};
let result = CompressionResult {
original_path: input.display().to_string(),
compressed_path: compressed_path.display().to_string(),
original_size,
compressed_size,
reduction_percent,
};
println!("Reduced size by {:.1}%", reduction_percent);
return Some(result);
},
Err(e) => {
eprintln!("Failed to compress {}: {}", input.display(), e);
None
}
}
})
.collect();
println!("Compression completed.");
results
}
Meta
rustc --version --verbose
:
rustc 1.87.0 (17067e9ac 2025-05-09) (Homebrew)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: aarch64-apple-darwin
release: 1.87.0
LLVM version: 20.1.4
Error output
thread 'coordinator' panicked at /private/tmp/rust-20250515-8123-mdgm7y/rustc-1.87.0-src/compiler/rustc_codegen_ssa/src/back/write.rs:1692:29:
/private/tmp/rust-20250515-8123-mdgm7y/rustc-1.87.0-src/compiler/rustc_codegen_ssa/src/back/write.rs:1692:29: worker thread panicked
stack backtrace:
0: 0x10d4f6ea0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h92c4e918781d801b
1: 0x10d55b230 - core::fmt::write::h8f75e776556839a0
2: 0x10d50bd48 - std::io::Write::write_fmt::hc2a765a75039a837
3: 0x10d4f6d54 - std::sys::backtrace::BacktraceLock::print::ha7a698681566e125
4: 0x10d501bc8 - std::panicking::default_hook::{{closure}}::hf90e930ff3e69c2d
5: 0x10d501ac4 - std::panicking::default_hook::had80bb8af3f6815c
6: 0x10abd0a88 - <alloc[ec5599a6ff6f777b]::boxed::Box<rustc_driver_impl[2db6a7acee9181d8]::install_ice_hook::{closure#1}> as core[cd2ca16b82fa16d0]::ops::function::Fn<(&dyn for<'a, 'b> core[cd2ca16b82fa16d0]::ops::function::Fn<(&'a std[6ff5e211387c1c03]::panic::PanicHookInfo<'b>,), Output = ()> + core[cd2ca16b82fa16d0]::marker::Send + core[cd2ca16b82fa16d0]::marker::Sync, &std[6ff5e211387c1c03]::panic::PanicHookInfo)>>::call
7: 0x10d502280 - std::panicking::rust_panic_with_hook::h77f9a822db4ac97a
8: 0x10d0629e0 - std[6ff5e211387c1c03]::panicking::begin_panic::<alloc[ec5599a6ff6f777b]::string::String>::{closure#0}
9: 0x10d0626d8 - std[6ff5e211387c1c03]::sys::backtrace::__rust_end_short_backtrace::<std[6ff5e211387c1c03]::panicking::begin_panic<alloc[ec5599a6ff6f777b]::string::String>::{closure#0}, !>
10: 0x10d6b8f8c - std[6ff5e211387c1c03]::panicking::begin_panic::<alloc[ec5599a6ff6f777b]::string::String>
11: 0x10d07fca0 - rustc_middle[1921f7fa52b9505d]::util::bug::opt_span_bug_fmt::<rustc_span[16a7c46a06ed0f8]::span_encoding::Span>::{closure#0}
12: 0x10d07f9a4 - rustc_middle[1921f7fa52b9505d]::ty::context::tls::with_opt::<rustc_middle[1921f7fa52b9505d]::util::bug::opt_span_bug_fmt<rustc_span[16a7c46a06ed0f8]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x10d07f970 - rustc_middle[1921f7fa52b9505d]::ty::context::tls::with_context_opt::<rustc_middle[1921f7fa52b9505d]::ty::context::tls::with_opt<rustc_middle[1921f7fa52b9505d]::util::bug::opt_span_bug_fmt<rustc_span[16a7c46a06ed0f8]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x10d6d76c8 - rustc_middle[1921f7fa52b9505d]::util::bug::bug_fmt
15: 0x10ae75e1c - std[6ff5e211387c1c03]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm[17a84dc1d755849b]::LlvmCodegenBackend as rustc_codegen_ssa[546b227f8b29fa6b]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::start_executing_work<rustc_codegen_llvm[17a84dc1d755849b]::LlvmCodegenBackend>::{closure#5}, core[cd2ca16b82fa16d0]::result::Result<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::CompiledModules, ()>>::{closure#0}, core[cd2ca16b82fa16d0]::result::Result<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::CompiledModules, ()>>
16: 0x10aecbfd8 - <<std[6ff5e211387c1c03]::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm[17a84dc1d755849b]::LlvmCodegenBackend as rustc_codegen_ssa[546b227f8b29fa6b]::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::start_executing_work<rustc_codegen_llvm[17a84dc1d755849b]::LlvmCodegenBackend>::{closure#5}, core[cd2ca16b82fa16d0]::result::Result<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::CompiledModules, ()>>::{closure#0}, core[cd2ca16b82fa16d0]::result::Result<rustc_codegen_ssa[546b227f8b29fa6b]::back::write::CompiledModules, ()>>::{closure#1} as core[cd2ca16b82fa16d0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
17: 0x10d4e3464 - std::sys::pal::unix::thread::Thread::new::thread_start::h30d0ef7640bc7718
18: 0x1847e2c0c - __pthread_cond_wait
error: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.87.0 (17067e9ac 2025-05-09) (Homebrew) running on aarch64-apple-darwin
note: compiler flags: --crate-type staticlib --crate-type cdylib --crate-type rlib -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: unable to copy /Users/burakunlu/rust/compressor/compressor_tauri/src-tauri/target/debug/incremental/compressor_tauri_lib-08bee5v42d0id/s-h8iowq8lvm-1btnd36-working/59tyakjllmb4oichnejy2o23a.o to /Users/burakunlu/rust/compressor/compressor_tauri/src-tauri/target/debug/deps/compressor_tauri_lib.59tyakjllmb4oichnejy2o23a.rcgu.o: No such file or directory (os error 2)```
<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>
RUST_BACKTRACE=1 cargo build
Compiling objc2-exception-helper v0.1.1
Compiling mozjpeg-sys v2.2.3
Compiling objc2 v0.6.1
Compiling block2 v0.6.1
Compiling objc2-core-foundation v0.3.1
Compiling dispatch2 v0.2.0
Compiling objc2-foundation v0.3.1
Compiling objc2-core-graphics v0.3.1
Compiling mozjpeg v0.10.13
Compiling image_compressor v1.5.2
Compiling objc2-quartz-core v0.3.1
Compiling objc2-cloud-kit v0.3.1
Compiling objc2-core-data v0.3.1
Compiling objc2-core-image v0.3.1
Compiling objc2-app-kit v0.3.1
Compiling objc2-web-kit v0.3.1
Compiling tao v0.33.0
Compiling muda v0.16.1
Compiling window-vibrancy v0.6.0
Compiling rfd v0.15.3
Compiling wry v0.51.2
Compiling tauri-runtime-wry v2.6.0
Compiling tauri v2.5.1
Compiling tauri-plugin-fs v2.3.0
Compiling tauri-plugin-opener v2.3.0
Compiling tauri-plugin-dialog v2.2.2
Compiling compressor_tauri v0.1.0 (/Users/burakunlu/rust/compressor/compressor_tauri/src-tauri)
warning: unused import: std::path::PathBuf
--> src/lib.rs:4:5
|
4 | use std::path::PathBuf;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)]
on by default
error: failed to build archive at /Users/burakunlu/rust/compressor/compressor_tauri/src-tauri/target/debug/deps/libcompressor_tauri_lib.a
: failed to map object file: memory map must have a non-zero length
warning: compressor_tauri
(lib) generated 1 warning
error: could not compile compressor_tauri
(lib) due to 1 previous error; 1 warning emitted
</p>
</details>