Re: Segfault on iOS Simulator (x86_64)

Jeffrey Walton <[email protected]> Sat, 24 Sep 2022 14:08:27 -0400
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <CAH8yC8nzYC2gFiJJRhWj6vY15aGQ3iqAOYKvHYE84B9ashZCPQ@mail.gmail.com>
On Wed, Sep 21, 2022 at 3:41 AM Cameron G <[email protected]> wrote:

> Hi, I'm receiving a segfault on iOS Simulator (x86_64) in some trivial
> code that works on other platforms. I think I may have built the library
> incorrectly, but I followed the wiki instructions and tried various
> combinations. The segfault happens when declaring
>
> CryptoPP::AutoSeededRandomPool rng;
>
> The stack frame is
> [image: Screen Shot 2022-09-21 at 3.29.55 PM.png]
>
> Here's how I built the library:
>
> IOS_SDK=iPhoneSimulator IOS_CPU=x86_64 source ./setenv-ios.sh
> Configuring for iPhoneSimulator (x86_64)
> XCODE_TOOLCHAIN:
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
> IOS_SDK: iPhoneSimulator
> IOS_CPU: x86_64
> IOS_CPPFLAGS:  -DCRYPTOPP_DISABLE_ASM
> IOS_CFLAGS: -arch x86_64 -miphonesimulator-version-min=6 -fno-common
> IOS_CXXFLAGS: -arch x86_64 -miphonesimulator-version-min=6 -stdlib=libc++
> -fno-common
> IOS_SYSROOT:
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk
>
>
> *******************************************************************************
> It looks the the environment is set correctly. Your next step is build
> the library with 'make -f GNUmakefile-cross'.
>
> *******************************************************************************
>
> Then, I ran 'make -f GNUmakefile-cross' :
> Here's what we found... IS_X86: 0, IS_X64: 1, IS_ARM32: 0, IS_ARMV8: 0
> Using testing flags: -g2 -O3 -fPIC -arch x86_64
> -miphonesimulator-version-min=6 -stdlib=libc++ -fno-common --sysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk
>
> clang++ -DCRYPTOPP_DISABLE_ASM -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk
> -Wall -g2 -O3 -fPIC -arch x86_64 -miphonesimulator-version-min=6
> -stdlib=libc++ -fno-common --sysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk
> -Wall -c cryptlib.cpp
>
> Most of the simulators use x86_64 now - especially iPhone ones, so that's
> why I'm compiling for that architecture.
>
> Thanks for any help!
>

The library was built with IOS_CPPFLAGS: -DCRYPTOPP_DISABLE_ASM. You have
to add the flag to your project's settings, too.

The other settings, like IOS_CXXFLAGS and IOS_LDFLAGS, should already be
present in your project since they are [mostly?] Xcode default. But
-DCRYPTOPP_DISABLE_ASM is not a default - you have to add it manually.

Jeff

-- 
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8nzYC2gFiJJRhWj6vY15aGQ3iqAOYKvHYE84B9ashZCPQ%40mail.gmail.com.
Screen Shot 2022-09-21 at 3.29.55 PM.png (image/png, 168.2 KB) - not displayed