randombit / botan

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

ld doesn't support -soname on OS X #1865

Closed William-Froelich closed 5 years ago

William-Froelich commented 5 years ago

When building for ios using macOS Mojave 10.14.3, the generated Makefile uses -soname instead of -install_name. The workaround mentioned in https://github.com/randombit/botan/issues/861 is a temporary work-around.

Build output: build.log

Configure output

09:12 $ ./configure.py --os=ios --prefix="iphone-64" --cpu=armv8-a --cc=clang  --cc-abi-flags="-arch arm64" --verbose 2>&1 | tee configure.log
  DEBUG: git reported revision a95c67a5a1fd8c9afd9cb69770cb1542f558f163
   INFO: Configuring to build Botan 2.9.0 (revision git:a95c67a5a1fd8c9afd9cb69770cb1542f558f163)
  DEBUG: Loaded 219 Modules files: adler32 aead aes aes_armv8 aes_ni aes_power8 aes_ssse3 aont aria asn1 auto_rng base base32 base58 base64 bcrypt bearssl bigint blake2 block blowfish boost bzip2 camellia cascade cast128 cast256 cbc cbc_mac ccm cecpq1 certstor_sql certstor_sqlite3 cfb chacha chacha20poly1305 chacha_avx2 chacha_rng chacha_simd32 checksum clmul clmul_ssse3 cmac codec_filt comb4p commoncrypto compression cpuid crc24 crc32 cryptobox ctr curve25519 des dev_random dh dl_algo dl_group dlies dsa dyn_load eax ec_group ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm getentropy gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea idea_sse2 iso9796 kasumi kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion locking_allocator lzma mac mce mceies md4 md5 mdx_hash mem_pool mgf1 misty1 mode_pad modes mp newhope nist_keywrap noekeon noekeon_simd numbertheory ocb ofb openssl par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pem pgp_s2k pk_pad pkcs11 pmull poly1305 poly_dbl prf_tls prf_x942 proc_walk psk_db pubkey rc4 rdrand rdrand_rng rdseed rfc3394 rfc6979 rmd160 rng rsa salsa20 scrypt seed serpent serpent_avx2 serpent_simd sessions_sql sessions_sqlite3 sha1 sha1_armv8 sha1_sse2 sha1_x86 sha2_32 sha2_32_armv8 sha2_32_bmi2 sha2_32_x86 sha2_64 sha3 shacal2 shacal2_simd shacal2_x86 shake shake_cipher simd simd_avx2 siphash siv skein sm2 sm3 sm4 sm4_armv8 socket sp800_108 sp800_56a sp800_56c sqlite3 srp6 stateful_rng stream streebog system_rng thread_utils threefish_512 threefish_512_avx2 tiger tls tls_cbc tpm tss twofish utils uuid whirlpool win32_stats x509 x919_mac xmss xtea xts zlib
  DEBUG: Loaded 21 CPU info files: alpha arm32 arm64 hppa ia64 llvm m68k mips32 mips64 powerpcspe ppc32 ppc64 riscv64 s390 s390x sparc32 sparc64 superh x32 x86_32 x86_64
  DEBUG: Loaded 22 OS info files: aix android cygwin darwin dragonfly emscripten freebsd haiku hpux hurd includeos ios linux llvm mingw nacl netbsd openbsd qnx solaris uwp windows
  DEBUG: Loaded 9 compiler info files: clang ekopath gcc hpcc icc msvc pgi sunstudio xlc
  DEBUG: Loaded 3 module policy files: bsi modern nist
   INFO: ./configure.py invoked with options "--os=ios --prefix=iphone-64 --cpu=armv8-a --cc=clang --cc-abi-flags=-arch arm64 --verbose"
   INFO: Autodetected platform information: OS="Darwin" machine="x86_64" proc="i386"
  DEBUG: Known CPU names: 680x0 68k 80x86 aarch64 alpha alphaaxp amd64 arm arm32 arm64 armeb armel armhf armv7 armv7-a armv7l armv8 armv8-a armv8l axp bepc em64t evbarm hp-pa hp-pa-risc hp-parisc hppa i386 i586 i686 i86pc ia32 ia64 itanic itanium ix86 llvm m68k mips mips32 mips64 mips64el mipsbe mipsel mipsle pa-risc parisc parisc64 powerpc powerpc64 powerpc64le powerpcspe ppc ppc32 ppc64 ppc64el ppc64le riscv64 s390 s390x sh4 sparc sparc32 sparc64 superh x32 x64 x86 x86-64 x86_32 x86_64 x86_amd64 x86pc
  DEBUG: Program sphinx-build not found
  DEBUG: Program rst2man not found
   INFO: Canonicalized CPU target armv8-a to arm64
  DEBUG: Running 'clang++ -E ./src/build-data/detect_version.cpp'
   INFO: Auto-detected compiler version 4.0
  DEBUG: Running 'clang++ -E -fstack-protector -pthread -stdlib=libc++ -arch arm64 ./src/build-data/detect_arch.cpp'
   INFO: Auto-detected compiler arch arm64
   INFO: Target is clang:4.0-ios-arm64
   INFO: Skipping (dependency failure): certstor_sqlite3 rdrand sessions_sqlite3
   INFO: Skipping (incompatible CPU): aes_ni aes_power8 aes_ssse3 chacha_avx2 clmul clmul_ssse3 idea_sse2 rdrand_rng rdseed serpent_avx2 sha1_sse2 sha1_x86 sha2_32_bmi2 sha2_32_x86 shacal2_x86 simd_avx2 threefish_512_avx2
   INFO: Skipping (incompatible OS): dev_random getentropy proc_walk win32_stats
   INFO: Skipping (incompatible compiler): sm4_armv8
   INFO: Skipping (no enabled compression schemes): compression
   INFO: Skipping (requires external dependency): bearssl boost bzip2 commoncrypto lzma openssl sqlite3 tpm zlib
   INFO: Loading modules: adler32 aead aes aes_armv8 aont aria asn1 auto_rng base base32 base58 base64 bcrypt bigint blake2 block blowfish camellia cascade cast128 cast256 cbc cbc_mac ccm cecpq1 certstor_sql cfb chacha chacha20poly1305 chacha_rng chacha_simd32 checksum cmac codec_filt comb4p cpuid crc24 crc32 cryptobox ctr curve25519 des dh dl_algo dl_group dlies dsa dyn_load eax ec_group ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea iso9796 kasumi kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion locking_allocator mac mce mceies md4 md5 mdx_hash mem_pool mgf1 misty1 mode_pad modes mp newhope nist_keywrap noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pem pgp_s2k pk_pad pkcs11 pmull poly1305 poly_dbl prf_tls prf_x942 psk_db pubkey rc4 rfc3394 rfc6979 rmd160 rng rsa salsa20 scrypt seed serpent serpent_simd sessions_sql sha1 sha1_armv8 sha2_32 sha2_32_armv8 sha2_64 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_512 tiger tls tls_cbc tss twofish utils uuid whirlpool x509 x919_mac xmss xtea xts
   INFO: Defaulting to assuming little endian
  DEBUG: Using MP bits 64
   INFO: Using symlink to link files into build dir (use --link-method to change)
  DEBUG: Linking 296 public header files in build/include/botan
  DEBUG: Linking 53 internal header files in build/include/botan/internal
  DEBUG: Linking 3 external header files in build/include/external
   INFO: Botan 2.9.0 (revision git:a95c67a5a1fd8c9afd9cb69770cb1542f558f163) (unreleased undated) build setup is complete
randombit commented 5 years ago

Does it actually even make sense to build a shared library for iOS? Not a rhetorical question, I don't know that much about iOS development. Our iOS CI build targets static library. The correct answer here may be we should disable even attempting to build a shared lib for this platform.

If shared libs do make sense, can you test the following patch?

diff --git a/src/build-data/cc/clang.txt b/src/build-data/cc/clang.txt
index 4b14d9c4b..2dc36dfe6 100644
--- a/src/build-data/cc/clang.txt
+++ b/src/build-data/cc/clang.txt
@@ -31,6 +31,7 @@ visibility_attribute '__attribute__((visibility("default")))'

 <so_link_commands>
 darwin        -> "$(CXX) -dynamiclib -fPIC -install_name $(INSTALLED_LIB_DIR)/{soname_abi} -current_version {darwin_so_current_ver} -compatibility_version {darwin_so_compat_ver}"
+ios           -> "$(CXX) -dynamiclib -fPIC -install_name $(INSTALLED_LIB_DIR)/{soname_abi} -current_version {darwin_so_current_ver} -compatibility_version {darwin_so_compat_ver}"

 # The default works for GNU ld and several other Unix linkers
 default       -> "$(CXX) -shared -fPIC -Wl,-soname,{soname_abi}"
randombit commented 5 years ago

Things like this SO post

https://stackoverflow.com/questions/7187649/can-i-use-dynamic-libraryshared-object-in-my-iphone-app

make me think that actually shared library is not correct for IOS and we should just disable it.

randombit commented 5 years ago

I have disabled building shared libs on iOS since a) it never worked b) it is not clear it is desirable. If someone comes back and explains how and why shared lib on iOS would be useful, we can revisit (and ideally add some CI tests to prevent regressions).

I'm closing this since the build should now succeed. Feel free to reopen if you think this is the wrong resolution.