portable icon indicating copy to clipboard operation
portable copied to clipboard

libressl-3.9.0: build fails for ios

Open chipitsine opened this issue 1 year ago • 13 comments

I ran build script from https://github.com/build-xcframeworks/libressl

./configure --host=x86_64-apple-darwin --prefix=/Users/runner/work/libressl/libressl/build/libressl-build/simulator_x86_64 CC=/usr/bin/clang CPPFLAGS=-I/Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.0.sdk/usr/include/ 'CFLAGS= -arch x86_64 -miphoneos-version-min=13.0 -pipe -no-cpp-precomp -isysroot /Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.0.sdk' 'CPP=/usr/bin/cpp ' LD=/Applications/Xcode_15.0.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ld
...
...
/Applications/Xcode_15.0.1.app/Contents/Developer/usr/bin/make  all-am
  CPPAS    aes/libcrypto_la-aes-macosx-x86_64.lo
  CPPAS    aes/libcrypto_la-bsaes-macosx-x86_64.lo
  CPPAS    aes/libcrypto_la-vpaes-macosx-x86_64.lo
  CPPAS    aes/libcrypto_la-aesni-macosx-x86_64.lo
  CPPAS    aes/libcrypto_la-aesni-sha1-macosx-x86_64.lo
  CPPAS    bn/libcrypto_la-modexp512-macosx-x86_64.lo
  CPPAS    bn/libcrypto_la-mont-macosx-x86_64.lo
  CPPAS    bn/libcrypto_la-mont5-macosx-x86_64.lo
  CPPAS    camellia/libcrypto_la-cmll-macosx-x86_64.lo
  CPPAS    md5/libcrypto_la-md5-macosx-x86_64.lo
  CPPAS    modes/libcrypto_la-ghash-macosx-x86_64.lo
  CPPAS    rc4/libcrypto_la-rc4-macosx-x86_64.lo
  CPPAS    rc4/libcrypto_la-rc4-md5-macosx-x86_64.lo
  CPPAS    sha/libcrypto_la-sha1-macosx-x86_64.lo
  CPPAS    sha/libcrypto_la-sha256-macosx-x86_64.lo
  CPPAS    sha/libcrypto_la-sha512-macosx-x86_64.lo
  CPPAS    whrlpool/libcrypto_la-wp-macosx-x86_64.lo
  CPPAS    libcrypto_la-cpuid-macosx-x86_64.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_add.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_cmadd.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_cmul.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_mul.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_sqr.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo
  CPPAS    bn/arch/amd64/libcrypto_la-bignum_sub.lo
  CPPAS    bn/arch/amd64/libcrypto_la-word_clz.lo
  CC       bn/arch/amd64/libcrypto_la-bn_arch.lo
  CC       libcrypto_la-cpt_err.lo
  CC       libcrypto_la-cryptlib.lo
  CC       libcrypto_la-crypto_init.lo
  CC       libcrypto_la-crypto_lock.lo
In file included from crypto_lock.c:22:
./crypto_internal.h:41:9: error: call to undeclared function 'be32toh'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        return be32toh(v);
               ^
./crypto_internal.h:54:6: error: call to undeclared function 'htobe32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        v = htobe32(v);
            ^
./crypto_internal.h:72:9: error: call to undeclared function 'be64toh'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        return be64toh(v);
               ^
./crypto_internal.h:85:6: error: call to undeclared function 'htobe64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        v = htobe64(v);
            ^
./crypto_internal.h:103:9: error: call to undeclared function 'le32toh'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        return le32toh(v);
               ^
./crypto_internal.h:116:6: error: call to undeclared function 'htole32'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        v = htole32(v);
            ^
6 errors generated.
make[1]: *** [libcrypto_la-crypto_lock.lo] Error 1
make: *** [all] Error 2


chipitsine avatar Mar 19 '24 23:03 chipitsine

These should be provided via the compat header. Can you figure out what the apparently existing endian.h contains?

https://github.com/libressl/portable/blob/55f21a399f56695990d5495384146b55a5e56823/include/compat/endian.h#L65-L77

Presumably this code needs to be of the form

#if defined(__APPLE__)
#if !defined(HAVE_ENDIAN_H)
...
#elif defined(/* whatever identifies ios */)
...
#endif

botovq avatar Mar 20 '24 03:03 botovq

interesting fact is that https://github.com/build-xcframeworks/libressl was not updated for a while, it states that LibreSSL-3.2.4 is supported (which was the latest as the time of creating)

I jumped from 3.2.4 to 3.9.0 ))

chipitsine avatar Mar 20 '24 15:03 chipitsine

so far,

3.7.2 - builds fine 3.8.0 - fails

(I'll do more checks soon)

chipitsine avatar Mar 21 '24 20:03 chipitsine

3.7.2 - builds fine 3.8.0 - fails

That's because crypto_internal.h didn't exist back then and there were no calls to these conversion functions. As mentioned, the bug will be in the compat endian.h.

botovq avatar Mar 22 '24 17:03 botovq

+1 any fix on this?

ekscrypto avatar Apr 17 '24 13:04 ekscrypto

omg, I forgot about it. thanks ))

chipitsine avatar Apr 17 '24 13:04 chipitsine

Yeah, I'm trying to compile 3.9.1 for iOS and failing...

ronaaron avatar Apr 17 '24 14:04 ronaaron

Yeah, I'm trying to compile 3.9.1 for iOS and failing...

can you please help us with build steps you take ?

we definetly would like to add something like that to CI

chipitsine avatar Apr 17 '24 14:04 chipitsine

I've just got a bash script to make sure I get the right options:

echo "Configuring"
if ./configure --host=$HOST --disable-tests --enable-shared=no > /tmp/configure.log 2>&1
then
	echo "Building"
	make -k -j8 > /tmp/build.log 2>&1
	$AR -r libtls.a `find crypto -name '*.o'` ssl/*.o tls/*.o >> /tmp/build.log
	$RANLIB libtls.a
	cp -v libtls.a ~/libs/ios/$BITS/libtls.a
else
	echo "Failed configure, see /tmp/configure.log"
fi

HOST is set to either aarch64-apple-darwin11 or armv7-ios-darwin11

ronaaron avatar Apr 17 '24 14:04 ronaaron

In my case I'm simply using the build-xcframework/libressl script

ekscrypto avatar Apr 18 '24 03:04 ekscrypto

In my very first post I asked a question and suggested a solution. How about you all try to answer it and then we can figure it out?

botovq avatar Apr 18 '24 07:04 botovq

OK, I changed the line to:

#if defined(__APPLE__) && !defined(be16toh)

And it works for me for iOS, and verified it doesn't screw up macOS (both Intel and ARM)

ronaaron avatar Apr 18 '24 09:04 ronaaron

On Thu, Apr 18, 2024 at 02:01:18AM -0700, ronaaron wrote:

OK, I changed the line to:

#if defined(__APPLE__) && !defined(be16toh)

And it works for me for iOS, and verified it doesn't screw up macOS (both Intel and ARM)

Ok, thanks.

That might be a viable approach although I'd prefer to get these HAVE_* defines set by autotools or cmake right. @busterb could you take a look please?

botovq avatar Apr 18 '24 09:04 botovq