Skip to content

sys: only compile enabled arch sources in build.rs#198

Merged
tmfink merged 4 commits into
capstone-rust:capstone-v6from
CodeWenjiu:capstone-v6-fix
Jun 28, 2026
Merged

sys: only compile enabled arch sources in build.rs#198
tmfink merged 4 commits into
capstone-rust:capstone-v6from
CodeWenjiu:capstone-v6-fix

Conversation

@CodeWenjiu

Copy link
Copy Markdown

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.

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.
@tmfink

tmfink commented Jun 8, 2026

Copy link
Copy Markdown
Member

@CodeWenjiu thanks for the enhancement! I thought we we already doing to this in 335ca9e, but I guess we were not. 😆

Could you fix the clippy::match_like_matches_macro warning in the code? It looks like this may be a false-positive from clippy, so you may just want to add the #[allow(clippy::match_like_matches_macro)] attribute on that match expression.

Comment thread capstone-sys/build.rs Outdated
"x86" => cfg!(feature = "arch_x86"),
"xcore" => cfg!(feature = "arch_xcore"),
"xtensa" => cfg!(feature = "arch_xtensa"),
_ => false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's actually make the _ case a panic. That way, we need to explicitly handle every case. For example, if we don't support a platform, we will can explicitly handle that with a false match case.

match {
    /* ... */
    _ => panic!("Unhandled arch dir {dir_name}"),
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed _ arm to panic!() and dropped the #[allow] since the panic makes it unnecessary.

@CodeWenjiu
CodeWenjiu requested a review from tmfink June 27, 2026 23:05
@tmfink
tmfink merged commit 8d7f9ef into capstone-rust:capstone-v6 Jun 28, 2026
13 checks passed
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 this pull request may close these issues.

3 participants