Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on arm64 with --build-tool=ninja #3750

Closed
thesamesam opened this issue Oct 11, 2023 · 3 comments · Fixed by #3751
Closed

Build failure on arm64 with --build-tool=ninja #3750

thesamesam opened this issue Oct 11, 2023 · 3 comments · Fixed by #3751

Comments

@thesamesam
Copy link

thesamesam commented Oct 11, 2023

Originally reported downstream in Gentoo at https://bugs.gentoo.org/915544 (w/ regular gcc 13 as well, I just happened to reproduce it w/ gcc 14 below):

$ ./configure.py --build-tool=ninja
   INFO: ./configure.py invoked with options "--build-tool=ninja"
   INFO: Configuring to build Botan 3.2.0 (revision git:6f466a2704a31856ebc27451ca861527d3dd00a1)
   INFO: Python version: "3.11.6 (main, Oct 10 2023, 05:56:40) [GCC 14.0.0 20231010 (experimental) fb124f2a23e92b08556984a50a4b2f367ed04d90]"
   INFO: Autodetected platform information: OS="Linux" machine="aarch64" proc=""
   INFO: Guessing target OS is linux (use --os to set)
   INFO: Guessing to use compiler gcc (use --cc or CXX to set)
   INFO: Guessing target processor is a arm64 (use --cpu to set)
   INFO: Found sphinx-build (use --without-sphinx to disable)
   INFO: Using /etc/ssl/certs/ca-certificates.crt as system certificate store
   INFO: Canonicalized CPU target aarch64 to arm64
   INFO: Auto-detected compiler version gcc 14.0
   INFO: Auto-detected compiler arch arm64
   INFO: Target is gcc:14.0-linux-arm64
   INFO: Assuming target arm64 is little endian
   INFO: Skipping (dependency failure): asio certstor_sqlite3 sessions_sqlite3
   INFO: Skipping (incompatible CPU): aes_ni aes_power8 argon2_avx2 argon2_ssse3 chacha_avx2 chacha_avx512 ghash_vperm idea_sse2 keccak_perm_bmi2 processor_rng rdseed serpent_avx2 serpent_avx512 sha1_sse2 sha1_x86 sha2_32_bmi2 sha2_32_x86 sha2_64_bmi2 shacal2_avx2 shacal2_x86 simd_avx2 simd_avx512 zfec_sse2
   INFO: Skipping (incompatible OS): certstor_system_macos certstor_system_windows commoncrypto win32_stats
   INFO: Skipping (no enabled compression schemes): compression
   INFO: Skipping (requires external dependency): boost bzip2 lzma sqlite3 tpm zlib
   INFO: Loading modules: adler32 aead aes aes_armv8 aes_crystals_xof aes_vperm argon2 argon2fmt aria asn1 auto_rng base base32 base58 base64 bcrypt bcrypt_pbkdf bigint blake2 blake2mac block blowfish camellia cascade cast128 cbc ccm certstor_flatfile certstor_sql certstor_system cfb chacha chacha20poly1305 chacha_rng chacha_simd32 checksum cmac comb4p cpuid crc24 crc32 cryptobox cshake_xof ctr curve25519 des dh dilithium dilithium_aes dilithium_common dl_algo dl_group dlies dsa dyn_load eax ec_group ec_h2c ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm getentropy ghash ghash_cpu gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea iso9796 kdf kdf1 kdf1_iso18033 kdf2 keccak keccak_perm keypair kmac kuznyechik kyber kyber_90s kyber_common lion locking_allocator mac mce md4 md5 mdx_hash mem_pool mgf1 mode_pad modes mp nist_keywrap noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf2 pem pgp_s2k pk_pad pkcs11 poly1305 poly_dbl prf_tls prf_x942 psk_db pubkey raw_hash rc4 rfc3394 rfc6979 rmd160 rng roughtime rsa salsa20 scrypt seed serpent serpent_simd sessions_sql sha1 sha1_armv8 sha2_32 sha2_32_armv8 sha2_64 sha3 shacal2 shacal2_armv8 shacal2_simd shake shake_cipher shake_xof simd siphash siv skein sm2 sm3 sm4 sm4_armv8 socket sodium sp800_108 sp800_56a sp800_56c sphincsplus_common sphincsplus_sha2 sphincsplus_shake srp6 stateful_rng stream streebog system_rng thread_utils threefish_512 tls tls12 tls13 tls13_pqc tls_cbc trunc_hash tss twofish utils uuid whirlpool x509 x919_mac xmss xof xts zfec zfec_vperm
   INFO: Using symlink to link files into build dir (use --link-method to change)
   INFO: Botan 3.2.0 (revision git:6f466a2704a31856ebc27451ca861527d3dd00a1) (release dated 20231009) build setup is complete
$ ninja
[9/582] g++ -fPIC -fvisibility=hidden -fstack-protector -pthread -std=c++20 -D_REENTRANT  -O3 -DBOTAN_...build/include/external -c src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp -o build/obj/lib/block_sm4_armv8.o
FAILED: build/obj/lib/block_sm4_armv8.o
g++ -fPIC -fvisibility=hidden -fstack-protector -pthread -std=c++20 -D_REENTRANT  -O3 -DBOTAN_IS_BEING_BUILT -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wca
st-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Wold-style-cast -Wsuggest-override -Wshadow -Wextra-semi  -I build/include -isystem build/include/external -c src/lib/block/sm4/sm4_armv8/sm4_armv8.
cpp -o build/obj/lib/block_sm4_armv8.o
In file included from src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp:8:
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/arm_neon.h: In function ‘void Botan::{anonymous}::SM4_E(uint32x4_t&, uint32x4_t&, uint32x4_t&, uint32x4_t&, uint32x4_t)’:
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/arm_neon.h:26899:1: error: inlining failed in call to ‘always_inline’ ‘uint32x4_t vsm4eq_u32(uint32x4_t, uint32x4_t)’: target specific option mismatch
26899 | vsm4eq_u32 (uint32x4_t __a, uint32x4_t __b)
      | ^~~~~~~~~~
src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp:38:19: note: called from here
   38 |    B3 = vsm4eq_u32(B3, K);
      |         ~~~~~~~~~~^~~~~~~
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/arm_neon.h:26899:1: error: inlining failed in call to ‘always_inline’ ‘uint32x4_t vsm4eq_u32(uint32x4_t, uint32x4_t)’: target specific option mismatch
26899 | vsm4eq_u32 (uint32x4_t __a, uint32x4_t __b)
      | ^~~~~~~~~~
src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp:37:19: note: called from here
   37 |    B2 = vsm4eq_u32(B2, K);
      |         ~~~~~~~~~~^~~~~~~
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/arm_neon.h:26899:1: error: inlining failed in call to ‘always_inline’ ‘uint32x4_t vsm4eq_u32(uint32x4_t, uint32x4_t)’: target specific option mismatch
26899 | vsm4eq_u32 (uint32x4_t __a, uint32x4_t __b)
      | ^~~~~~~~~~
src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp:36:19: note: called from here
   36 |    B1 = vsm4eq_u32(B1, K);
      |         ~~~~~~~~~~^~~~~~~
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/arm_neon.h:26899:1: error: inlining failed in call to ‘always_inline’ ‘uint32x4_t vsm4eq_u32(uint32x4_t, uint32x4_t)’: target specific option mismatch
26899 | vsm4eq_u32 (uint32x4_t __a, uint32x4_t __b)
      | ^~~~~~~~~~
src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp:35:19: note: called from here
   35 |    B0 = vsm4eq_u32(B0, K);
      |         ~~~~~~~~~~^~~~~~~

I can only reproduce this with --build-tool=ninja (I was keen to try it for the nice progress bars and faster builds). I'll flip us back to make for the ebuild for now.

@thesamesam thesamesam changed the title Build failure on arm64 (with --build-tool=ninja?) Build failure on arm64 with --build-tool=ninja Oct 11, 2023
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Oct 11, 2023
@randombit
Copy link
Owner

Thanks for the report - we must not be passing the right flags to enable the instructions here.

BTW in the linked Gentoo bug I noticed you added cpu_use flags for ARMv8 SHA1/SHA2 - here we are using the ARMv8 SM4 instructions and you may want to have a flag for that as well.

@thesamesam
Copy link
Author

Thanks @randombit - the PR works for me.

I'll also check out the SM4 bits, we don't currently have a USE flag for it at all (not just in Botan) so I'll file a bug for that.

@securitykernel
Copy link
Collaborator

Sorry for the bug, I must have missed that bit. But glad to see that ninja support is being used downstream. 😊

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 a pull request may close this issue.

3 participants