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

libressl-3.9.0: build fails for ios #1025

Open
chipitsine opened this issue Mar 19, 2024 · 13 comments
Open

libressl-3.9.0: build fails for ios #1025

chipitsine opened this issue Mar 19, 2024 · 13 comments

Comments

@chipitsine
Copy link
Contributor

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


@botovq
Copy link
Contributor

botovq commented Mar 20, 2024

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

#if defined(__APPLE__) && !defined(HAVE_ENDIAN_H)
#include <libkern/OSByteOrder.h>
#define be16toh(x) OSSwapBigToHostInt16((x))
#define htobe16(x) OSSwapHostToBigInt16((x))
#define le32toh(x) OSSwapLittleToHostInt32((x))
#define be32toh(x) OSSwapBigToHostInt32((x))
#define htole32(x) OSSwapHostToLittleInt32(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define htobe64(x) OSSwapHostToBigInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#endif /* __APPLE__ && !HAVE_ENDIAN_H */

Presumably this code needs to be of the form

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

@chipitsine
Copy link
Contributor Author

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
Copy link
Contributor Author

so far,

3.7.2 - builds fine
3.8.0 - fails

(I'll do more checks soon)

@botovq
Copy link
Contributor

botovq commented Mar 22, 2024

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.

@ekscrypto
Copy link

+1 any fix on this?

@chipitsine
Copy link
Contributor Author

omg, I forgot about it.
thanks ))

@ronaaron
Copy link

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

@chipitsine
Copy link
Contributor Author

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

@ronaaron
Copy link

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

@ekscrypto
Copy link

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

@botovq
Copy link
Contributor

botovq commented Apr 18, 2024 via email

@ronaaron
Copy link

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)

@botovq
Copy link
Contributor

botovq commented Apr 18, 2024 via email

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

No branches or pull requests

4 participants