Skip to content

Conversation

@kawarimidoll
Copy link

Apple Silicon(aarch64)のMacbookでビルドを試みたところ、アーキテクチャ起因のビルドエラーが発生したため、非x86環境でもビルドできるよう調整を行いました。

select_in_word_optimizedメソッドを導入し、x86かつ可能ならselect_in_word_pdepを、それ以外(非x86含む)ならselect_in_wordを呼び出すようにしています。

発生したエラー

❯ cargo build --release --features cli
   Compiling pico-args v0.5.0
   Compiling byteorder v1.5.0
   Compiling rustmigemo v0.1.4 (/Users/kawarimidoll/ghq/github.com/kawarimidoll/rustmigemo)
error: This macro cannot be used on the current target.
                                   You can prevent it from being used in other architectures by
                                   guarding it behind a cfg(any(target_arch = "x86", target_arch = "x86_64")).
  --> src/migemo/bit_vector.rs:83:16
   |
83 |             if is_x86_feature_detected!("bmi2") {
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `is_x86_feature_detected` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0432]: unresolved import `std::arch::x86_64`
 --> src/migemo/bit_vector.rs:1:16
  |
1 | use std::arch::x86_64::_pdep_u64;
  |                ^^^^^^ could not find `x86_64` in `arch`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `rustmigemo` (lib) due to 2 previous errors

x86_64専用の部分をcfgで分離。
select_in_word_optimizedメソッドを導入し、アーキテクチャごとに適切な処理を選択するよう改善。
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.

1 participant