randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.6k stars 570 forks source link

Build fails on AArch64 when configured with "configure.py --cpu=arm32". Error: unrecognized command line option ‘-mfpu=neon’ #1442

Closed DevSidious closed 6 years ago

DevSidious commented 6 years ago
INFO: ./configure.py invoked with options "--cpu=arm32 --minimized-build --enable-modules=x509,ecdsa,rsa,emsa_pkcs1,sha2_64,aes --disable-shared-library --amalgamation --single-amalgamation-file"
INFO: Guessing target OS is linux (use --os to set)
INFO: Guessing to use compiler gcc (use --cc or CXX to set)
INFO: Auto-detected compiler version 5.4
INFO: Target is gcc:5.4-linux-arm32
INFO: Skipping (incompatible CPU): aes_ni aes_ssse3 chacha_sse2 clmul clmul_ssse3 idea_sse2 rdrand_rng rdseed sha1_sse2 sha1_x86 sha2_32_x86 shacal2_x86 threefish_avx2
INFO: Skipping (incompatible OS): darwin_secrandom getentropy win32_stats
INFO: Skipping (incompatible compiler): aes_armv8 pmull sha1_armv8 sha2_32_armv8
INFO: Skipping (not requested): adler32 aead aont aria auto_rng bcrypt blake2 blowfish camellia cascade cast cbc cbc_mac ccm cecpq1 certstor_sql certstor_sqlite3 cfb chacha chacha20poly1305 chacha_rng checksum cmac codec_filt comb4p compression crc24 crc32 cryptobox ctr curve25519 des dev_random dh dl_algo dl_group dlies dsa dyn_load eax ecdh ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa_raw emsa_x931 fd_unix ffi filters fpe_fe1 gcm gmac gost_28147 gost_3410 gost_3411 hkdf hmac hmac_drbg hotp http_util idea iso9796 kasumi kdf1 kdf1_iso18033 kdf2 keccak lion locking_allocator mce mceies md4 md5 misty1 mode_pad modes newhope nist_keywrap noekeon noekeon_simd ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pgp_s2k pkcs11 poly1305 poly_dbl prf_tls prf_x942 proc_walk psk_db rc4 rdrand rfc3394 rfc6979 rmd160 salsa20 seed serpent serpent_simd sessions_sql sessions_sqlite3 sha3 shacal2 shacal2_simd shake shake_cipher simd siphash siv skein sm2 sm3 sm4 socket sp800_108 sp800_56a sp800_56c srp6 stateful_rng stream streebog system_rng thread_utils threefish tiger tls tls_cbc tss twofish whirlpool x919_mac xmss xtea xts
INFO: Skipping (requires external dependency): bearssl boost bzip2 lzma openssl sqlite3 tpm zlib
INFO: Loading modules: aes asn1 base base64 bigint block cpuid ec_gfp ec_group ecc_key ecdsa emsa1 emsa_pkcs1 emsa_pssr entropy hash hash_id hex kdf keypair mac mdx_hash mgf1 mp numbertheory pem pk_pad pubkey rng rsa sha1 sha2_32 sha2_64 utils x509
INFO: Using symlink to link files into build dir (use --link-method to change)
INFO: Writing amalgamation header to botan_all.h
INFO: Writing amalgamation header to botan_all_internal.h
INFO: Writing amalgamation source to botan_all.cpp
INFO: Botan 2.5.0 (revision git:0d63e98483e304a385013a4568312ab94dff3822) (unreleased undated) build setup is complete

make
...
...
...
g++ -fstack-protector -pthread -mfpu=neon -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_simd.cpp -o build/obj/test/test_simd.o
g++: error: unrecognized command line option ‘-mfpu=neon’
Makefile:326: recipe for target 'build/obj/test/test_simd.o' failed
make: *** [build/obj/test/test_simd.o] Error 1

The solution should be this.

randombit commented 6 years ago

I am confused. You indicate your GCC is configured for Aarch64. So, it is not possible to build for a standard 32-bit ARM target (which is what arm32 is). Is your intention here to build for Aarch32?

DevSidious commented 6 years ago

My intention is to build for arm32 on an arm64 machine. The same way one would build Botan 32 bit on X64 machine.

It appears arm64 CPUs are able to run arm32 code, however Linuxes don't support mixed mode. I should be able to build though.

Arm32 support is optional on arm64. In practice, there is only one arm64 CPU that omits legacy arm32 instruction set support - Cavium ThunderX.

Source for the above

randombit commented 6 years ago

I should be able to build though.

Execution works fine, but you need an arm32 compiler. In GCC at least, Aarch64 is a completely different backend from ARMv7 and company.

DevSidious commented 6 years ago

Well, the build goes on just fine until it reaches the line where ‘-mfpu=neon’ is passed to the compiler. According to the first link, one shouldn't pass ‘-mfpu=neon’ to the compiler but rather -O3 or -O2 -ftree-vectorize when building for arm32.

Full compilation output:

root@dev-scw-xeni-a64:/tmp/botan# make
g++ -fstack-protector -pthread   -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c botan_all.cpp -o build/obj/lib/botan_all.o
ar crs libbotan-2.a build/obj/lib/botan_all.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/asn1.cpp -o build/obj/cli/asn1.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/cc_enc.cpp -o build/obj/cli/cc_enc.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/cli.cpp -o build/obj/cli/cli.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/cli_rng.cpp -o build/obj/cli/cli_rng.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/compress.cpp -o build/obj/cli/compress.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/encryption.cpp -o build/obj/cli/encryption.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/main.cpp -o build/obj/cli/main.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/math.cpp -o build/obj/cli/math.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/psk.cpp -o build/obj/cli/psk.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/pubkey.cpp -o build/obj/cli/pubkey.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/speed.cpp -o build/obj/cli/speed.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/timing_tests.cpp -o build/obj/cli/timing_tests.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/tls_client.cpp -o build/obj/cli/tls_client.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/tls_http_server.cpp -o build/obj/cli/tls_http_server.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/tls_proxy.cpp -o build/obj/cli/tls_proxy.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/tls_server.cpp -o build/obj/cli/tls_server.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/tls_utils.cpp -o build/obj/cli/tls_utils.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/utils.cpp -o build/obj/cli/utils.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/cli/x509.cpp -o build/obj/cli/x509.o
g++ -fstack-protector -pthread -Wl,-rpath=\$ORIGIN  build/obj/cli/asn1.o build/obj/cli/cc_enc.o build/obj/cli/cli.o build/obj/cli/cli_rng.o build/obj/cli/compress.o build/obj/cli/encryption.o build/obj/cli/main.o build/obj/cli/math.o build/obj/cli/psk.o build/obj/cli/pubkey.o build/obj/cli/speed.o build/obj/cli/timing_tests.o build/obj/cli/tls_client.o build/obj/cli/tls_http_server.o build/obj/cli/tls_proxy.o build/obj/cli/tls_server.o build/obj/cli/tls_utils.o build/obj/cli/utils.o build/obj/cli/x509.o -L. -lbotan-2  -o botan
/usr/bin/python ./src/scripts/build_docs.py --build-dir="build"
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/main.cpp -o build/obj/test/main.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_aead.cpp -o build/obj/test/test_aead.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_asn1.cpp -o build/obj/test/test_asn1.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_bigint.cpp -o build/obj/test/test_bigint.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_block.cpp -o build/obj/test/test_block.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_c25519.cpp -o build/obj/test/test_c25519.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_certstor.cpp -o build/obj/test/test_certstor.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_compression.cpp -o build/obj/test/test_compression.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_cryptobox.cpp -o build/obj/test/test_cryptobox.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_datastore.cpp -o build/obj/test/test_datastore.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_dh.cpp -o build/obj/test/test_dh.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_dl_group.cpp -o build/obj/test/test_dl_group.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_dlies.cpp -o build/obj/test/test_dlies.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_dsa.cpp -o build/obj/test/test_dsa.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ecc_pointmul.cpp -o build/obj/test/test_ecc_pointmul.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ecdh.cpp -o build/obj/test/test_ecdh.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ecdsa.cpp -o build/obj/test/test_ecdsa.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ecgdsa.cpp -o build/obj/test/test_ecgdsa.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ecies.cpp -o build/obj/test/test_ecies.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_eckcdsa.cpp -o build/obj/test/test_eckcdsa.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ed25519.cpp -o build/obj/test/test_ed25519.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_elg.cpp -o build/obj/test/test_elg.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_entropy.cpp -o build/obj/test/test_entropy.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ffi.cpp -o build/obj/test/test_ffi.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_filters.cpp -o build/obj/test/test_filters.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_fpe.cpp -o build/obj/test/test_fpe.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_gf2m.cpp -o build/obj/test/test_gf2m.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_gost_3410.cpp -o build/obj/test/test_gost_3410.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_hash.cpp -o build/obj/test/test_hash.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_hash_id.cpp -o build/obj/test/test_hash_id.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_kdf.cpp -o build/obj/test/test_kdf.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_keywrap.cpp -o build/obj/test/test_keywrap.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_mac.cpp -o build/obj/test/test_mac.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_mceliece.cpp -o build/obj/test/test_mceliece.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_modes.cpp -o build/obj/test/test_modes.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_mp.cpp -o build/obj/test/test_mp.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_name_constraint.cpp -o build/obj/test/test_name_constraint.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_newhope.cpp -o build/obj/test/test_newhope.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ocb.cpp -o build/obj/test/test_ocb.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_ocsp.cpp -o build/obj/test/test_ocsp.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_octetstring.cpp -o build/obj/test/test_octetstring.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_os_utils.cpp -o build/obj/test/test_os_utils.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_otp.cpp -o build/obj/test/test_otp.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_package_transform.cpp -o build/obj/test/test_package_transform.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pad.cpp -o build/obj/test/test_pad.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_passhash.cpp -o build/obj/test/test_passhash.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pbkdf.cpp -o build/obj/test/test_pbkdf.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pem.cpp -o build/obj/test/test_pem.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pk_pad.cpp -o build/obj/test/test_pk_pad.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pkcs11.cpp -o build/obj/test/test_pkcs11.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pkcs11_high_level.cpp -o build/obj/test/test_pkcs11_high_level.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pkcs11_low_level.cpp -o build/obj/test/test_pkcs11_low_level.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_psk_db.cpp -o build/obj/test/test_psk_db.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_pubkey.cpp -o build/obj/test/test_pubkey.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_rfc6979.cpp -o build/obj/test/test_rfc6979.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_rng.cpp -o build/obj/test/test_rng.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_rng_kat.cpp -o build/obj/test/test_rng_kat.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_rsa.cpp -o build/obj/test/test_rsa.o
g++ -fstack-protector -pthread  -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_runner.cpp -o build/obj/test/test_runner.o
g++ -fstack-protector -pthread -mfpu=neon -std=c++11 -D_REENTRANT -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Ibuild/include -c src/tests/test_simd.cpp -o build/obj/test/test_simd.o
g++: error: unrecognized command line option ‘-mfpu=neon’
Makefile:326: recipe for target 'build/obj/test/test_simd.o' failed
make: *** [build/obj/test/test_simd.o] Error 1
randombit commented 6 years ago

Well, the build goes on just fine until it reaches the line where ‘-mfpu=neon’ is passed to the compiler.

It is building, but is it building ARMv7 object files? I'm guessing not.

DevSidious commented 6 years ago

It is building, but is it building ARMv7 object files? I'm guessing not.

I went and replaced -mfpu=neon with -O2 -ftree-vectorize on line 326 in the generated Makefile. Build completes successfully and tests complete too on AArch64: Tests complete ran 47596 tests in 119.11 sec all tests ok.

This shows that the offending flag preventing a 32 bit build on AArch64 is indeed -mfpu=neon.

Currently waiting to see if the resulting binary (botan-test) actually runs on armv7l. My bet right now is that it won't. :D

randombit commented 6 years ago

You can test with file:

$ cat > hi.c              
int foo() { return 5; }
$ aarch64-linux-gnu-gcc -c hi.c -o hi.o
$ file hi.o 
hi.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped
$ arm-none-eabi-gcc -c hi.c -o hi.o
$ file hi.o
hi.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
DevSidious commented 6 years ago
root@dev-scw-xeni-a64:/tmp/botan# file botan-test
botan-test: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=73715262ee45a34952b4701d40438aa50d8445c3, not stripped

It seems I'm not getting a 32 bit executable. Of course it won't work on armv7l.

root@dev-scw-xeni-a64:/tmp/botan# file botan
botan: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=a3c10bbc3a1ea1cca2db23b2cdff8f4be1b2af79, not stripped
DevSidious commented 6 years ago

./configure.py --cpu=arm32 --minimized-build --enable-modules=x509,ecdsa,rsa,emsa_pkcs1,sha2_64,aes --disable-shared-library --amalgamation --single-amalgamation-file

... gives me a 64 bit build. Now I'm confused :| .

randombit commented 6 years ago

You'll need a compiler for 32-bit ARM, which will come in a completely different package from Aarch64. Eg on Ubuntu 16.04, gcc-5-aarch64-linux-gnu for 64-bit vs gcc-5-arm-linux-gnueabihf for 32-bit. It doesn't work like x86-32 vs x86-64, which share a backend in GCC and a simple -m32/-m64 flag to switch targets.

randombit commented 6 years ago

We have a compile-time check for x86-32 vs x86-64 cross-configuration because that's a common misconfiguration but for everwhere else, we just assume $CXX is going to produce binaries matching the CPU specified by --cpu without any verification. You compiled with an Aarch64 compiler, so that's the binaries you got, and it happened that ARMv7 is sufficiently like Aarch64 that - given the current source - it happened to work. But you could have said say --cpu=mips64 and that would also work, unless you happened to hit a stray bit of inline asm or whatever and one or two files would fail to build.

We could/should have a better compile time check here, but fundamentally you need a different build of GCC for 32-bit ARM binaries.

DevSidious commented 6 years ago

Oozing with clarity, I could sum it up thus:

  1. Aarch64 does not need -mfpu=neon flag. It does not understand that, the same being achieved with -O3 or -O2 -ftree-vectorize;
  2. ARM7 does need the -mfpu=neon flag;
  3. When invoking configure.py with --cpu=arm32 on AArch64, it presumes one would be using the ARM7 tool-chain;
  4. If one employs the AArch64 tool-chain on AArch64 instead of the ARM7 tool-chain on the aforementioned, configure.py won't have an issue with that. However, it adds -mfpu=neon which results in a build failure;
  5. One tries to compensate by replacing -mfpu=neon with -O2 -ftree-vectorize. Build succeeds, however there is one caveat:
  6. The resulting binaries are 64 bit AArch64, not 32 bit ARM7;

This scenario is a rich source of massive fuck-ups, inviting the question: can configure.py be updated to slap one over the wrist really hard in a scenario such as the one described in this thread?

randombit commented 6 years ago

That pretty well sums it up. It's fairly easy to check the compiler's predefined macros to detect what actual arch it intends to build for which I've done in #1443. It errors out if it detects an inconsistency between what the user expressed and what the compiler seems to be doing.

DevSidious commented 6 years ago

It seems these changes don't pass CI. I'll test as soon as they do.

noloader commented 6 years ago

@DevSidious,

My intention is to build for arm32 on an arm64 machine....

This is kind of unusual. What does gcc -dumpmachine have to say (for the compiler you are using)? That tells you what machine GCC can build for. It is called the host in Autotools speak.

As @randombit said, you can't build for arbitrary hosts. You can only build for the host the compiler is setup for.

It appears arm64 CPUs are able to run arm32 code, however Linuxes don't support mixed mode. I should be able to build though.

This does not make much sense; neither does --cpu=arm32 on Aarch64 unless you are cross-compiling. I don't recall seeing GCC options to generate 32-bit A-32 code for Aarch64, but I may have missed something. -mabi=ilp32 looks close, but I don't see where you are using it. Also see GCC's 3.18.1 AArch64 Options.

Note that if you try to use -mabi=ilp32 then you could see a lot of problems with the GNU standard C++ runtime. GCC 4.9 is kind of old but they are kind of standard on dev-board images. I don't know how newer compiler respond.

g++ -DNDEBUG -g2 -O3 -std=c++11 -mabi=ilp32 -c test.cpp
In file included from /usr/include/c++/4.9/chrono:38:0,
                 from /usr/include/c++/4.9/mutex:39,             
                 from test.cpp:18:
/usr/include/c++/4.9/ratio:214:7: error: static assertion failed: This
library calls __builtin_clzll on uintmax_t, which is unsafe on your
platform. Please complain to http://gcc.gnu.org/bugzilla/
       static_assert(sizeof (uintmax_t) == sizeof (unsigned long long),
       ^

You should probably ask some questions on the GCC Help mailing list to see what you need to accomplish what you want to do. I believe you are interested in responses from a fellow named James Greenhalgh.

You might also want to talk with the Linaro folks. They may be able to help guide you with code generation needs. They have a GCC compiler mailing list. You are looking for responses from a fellow named Jim Wilson.


Here is what I am seeing on a HiKey with GCC compiler, which is Aarch64.

$ gcc -dumpmachine
aarch64-linux-gnu

The first in the triplet, aarch64 is the host. The compiler cannot target ARM32/A-32 cpu's.

DevSidious commented 6 years ago

@noloader

I apologize if I have not made my goals clear enough. The purpose of this exercise was to ascertain how would configure.py behave in the given context. Would it fail early or accept whatever and proceed ?

In this particular scenario, I did have the gcc-5-arm-linux-gnueabihf package installed, what I did not have was the aforementioned compiler incarnation set up as system default.

The expectation was that configure.py would either successfully complete the configuration if all the prerequisites were in order or otherwise abort with a meaningful message.

The above expectation was not satisfied. configure.py accepted the --cpu=arm32 parameter and proceeded to spit out a Makefile. The build failed, but it did so for questionable reasons: the -mfpu=neon flag.

The fruits of this (albeit uncanny) scenario materialized in @randombit 's stance on the subject:

We could/should have a better compile time check here

and

1443. It errors out if it detects an inconsistency between what the user expressed and what the compiler seems to be doing.

I wish to take the opportunity to thank both @randombit and @noloader for the information made available in this thread. In retrospect, I do not believe this was a waste of time. :)