From bd866dab17b1f30062a24cf4ea3b33a65695e35c Mon Sep 17 00:00:00 2001 From: wenjiu <2784307979@qq.com> Date: Fri, 29 May 2026 09:57:50 +0800 Subject: [PATCH 1/4] sys: only compile enabled arch sources in build.rs In GCC 14+, -Wimplicit-function-declaration became an error that -w flag cannot suppress. The auto-generated AArch64 sources in capstone v6 trigger this error even when the AArch64 feature is disabled, because build.rs previously compiled all arch directories unconditionally. Filter arch directories by enabled cargo features, so only selected architectures' sources are compiled. --- capstone-sys/build.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/capstone-sys/build.rs b/capstone-sys/build.rs index 3643b5f5..d42d720d 100644 --- a/capstone-sys/build.rs +++ b/capstone-sys/build.rs @@ -95,12 +95,42 @@ fn build_capstone_cc() { }) } + fn is_arch_enabled(dir_name: &str) -> bool { + match dir_name.to_lowercase().as_str() { + "aarch64" => cfg!(feature = "arch_aarch64"), + "alpha" => cfg!(feature = "arch_alpha"), + "arc" => cfg!(feature = "arch_arc"), + "arm" => cfg!(feature = "arch_arm"), + "bpf" => cfg!(feature = "arch_bpf"), + "evm" => cfg!(feature = "arch_evm"), + "hppa" => cfg!(feature = "arch_hppa"), + "loongarch" => cfg!(feature = "arch_loongarch"), + "m680x" => cfg!(feature = "arch_m680x"), + "m68k" => cfg!(feature = "arch_m68k"), + "mips" => cfg!(feature = "arch_mips"), + "mos65xx" => cfg!(feature = "arch_mos65xx"), + "powerpc" => cfg!(feature = "arch_powerpc"), + "riscv" => cfg!(feature = "arch_riscv"), + "sh" => cfg!(feature = "arch_sh"), + "sparc" => cfg!(feature = "arch_sparc"), + "systemz" => cfg!(feature = "arch_systemz"), + "tms320c64x" => cfg!(feature = "arch_tms320c64x"), + "tricore" => cfg!(feature = "arch_tricore"), + "wasm" => cfg!(feature = "arch_wasm"), + "x86" => cfg!(feature = "arch_x86"), + "xcore" => cfg!(feature = "arch_xcore"), + "xtensa" => cfg!(feature = "arch_xtensa"), + _ => false, + } + } + fn find_arch_dirs() -> Vec { read_dir_and_filter(&format!("{}/{}", CAPSTONE_DIR, "arch"), |e| { let file_type = e .file_type() .expect("Failed to read capstone source directory"); - file_type.is_dir() + let dir_name = e.file_name().into_string().expect("Invalid filename"); + file_type.is_dir() && is_arch_enabled(&dir_name) }) } From cf7ad563e82ad5436ffb0c632118f26bef610c9c Mon Sep 17 00:00:00 2001 From: wenjiu <2784307979@qq.com> Date: Tue, 16 Jun 2026 21:50:32 +0800 Subject: [PATCH 2/4] sys: panic on unhandled arch dir, allow clippy match_like_matches_macro --- capstone-sys/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/capstone-sys/build.rs b/capstone-sys/build.rs index d42d720d..c83c32fd 100644 --- a/capstone-sys/build.rs +++ b/capstone-sys/build.rs @@ -96,6 +96,7 @@ fn build_capstone_cc() { } fn is_arch_enabled(dir_name: &str) -> bool { + #[allow(clippy::match_like_matches_macro)] match dir_name.to_lowercase().as_str() { "aarch64" => cfg!(feature = "arch_aarch64"), "alpha" => cfg!(feature = "arch_alpha"), @@ -120,7 +121,7 @@ fn build_capstone_cc() { "x86" => cfg!(feature = "arch_x86"), "xcore" => cfg!(feature = "arch_xcore"), "xtensa" => cfg!(feature = "arch_xtensa"), - _ => false, + _ => panic!("Unhandled arch dir {dir_name}"), } } From 8e22c3316ffa8bf6fd7842a9a2d7c501ece0021b Mon Sep 17 00:00:00 2001 From: wenjiu <2784307979@qq.com> Date: Tue, 16 Jun 2026 21:56:01 +0800 Subject: [PATCH 3/4] sys: fix panic format for Rust 2018 edition compatibility --- capstone-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capstone-sys/build.rs b/capstone-sys/build.rs index c83c32fd..0b35039b 100644 --- a/capstone-sys/build.rs +++ b/capstone-sys/build.rs @@ -121,7 +121,7 @@ fn build_capstone_cc() { "x86" => cfg!(feature = "arch_x86"), "xcore" => cfg!(feature = "arch_xcore"), "xtensa" => cfg!(feature = "arch_xtensa"), - _ => panic!("Unhandled arch dir {dir_name}"), + _ => panic!("Unhandled arch dir {}", dir_name), } } From c75db0422c14817b652e933183a57096f4599ed1 Mon Sep 17 00:00:00 2001 From: wenjiu <2784307979@qq.com> Date: Tue, 16 Jun 2026 22:13:47 +0800 Subject: [PATCH 4/4] sys: remove redundant clippy allow attribute --- capstone-sys/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/capstone-sys/build.rs b/capstone-sys/build.rs index 0b35039b..a79e6634 100644 --- a/capstone-sys/build.rs +++ b/capstone-sys/build.rs @@ -96,7 +96,6 @@ fn build_capstone_cc() { } fn is_arch_enabled(dir_name: &str) -> bool { - #[allow(clippy::match_like_matches_macro)] match dir_name.to_lowercase().as_str() { "aarch64" => cfg!(feature = "arch_aarch64"), "alpha" => cfg!(feature = "arch_alpha"),