Error while building libcrypto and libssl for tvOS - ios

I'm using the following build script
https://gist.github.com/felix-schwarz/c61c0f7d9ab60f53ebb0
to build libcrypto and libssl for tvOS. I have Xcode 7.1 beta (7B75) installed. I updated the line
DEVELOPER=`xcode-select -print-path`
to refer to the Developer folder in Xcode-beta.app. When I run the script, it fails at building the tvOS libraries. When I check the /tmp/....log file it first tells me that -mtvos-min-version=9.0 is an unknown option. When I remove that option from the build script, so that
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -mtvos-version-min=${TVOS_MIN_SDK_VERSION} !" "Makefile"
becomes
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"
it does continue to create all the object files, but when it tries to make the library I get this error:
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f ../Makefile.shared -e \
APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o" \
LIBDEPS="-Wl,-search_paths_first $LIBRARIES " \
link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first -L.. -lssl -L.. -lcrypto }"; LDCMD="${LDCMD:-/Applications/Xcode-beta.app/Contents/Developer/usr/bin/gcc -fembed-bitcode -arch arm64}"; LDFLAGS="${LDFLAGS:--isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk -fomit-frame-pointer -fno-common}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
clang: error: -fembed-bitcode is not supported on versions of iOS prior to 6.0
make[2]: *** [link_app.] Error 1
make[1]: *** [openssl] Error 2
make: *** [build_apps] Error 1
Any idea what I'm doing wrong?

The make executable was still being called from Xcode 7.0, and not Xcode 7.1 beta. I resolved it by renaming Xcode-beta.app to Xcode.app. Then, when I ran the script, it worked!

Related

brew: unable to install mumps on mac

I am trying to install ipopt by:
brew install ipopt.rb --with-openblas
and I got the following error:
==> Installing dependencies for ipopt: mumps
==> Installing ipopt dependency: mumps
==> Downloading http://mumps.enseeiht.fr/MUMPS_5.1.1.tar.gz
Already downloaded: /Users/yufeiliu/Library/Caches/Homebrew/mumps-5.1.1.tar.gz
==> make alllib LIBEXT=.dylib AR= -dynamiclib -Wl,-install_name -Wl,/usr/local/Cellar/mumps/5.1.
Last 15 lines from /Users/yufeiliu/Library/Logs/Homebrew/mumps/01.make:
clang -fPIC -I../include -O -c symbfac.c -o symbfac.o
clang -fPIC -I../include -O -c interface.c -o interface.o
clang -fPIC -I../include -O -c sort.c -o sort.o
clang -fPIC -I../include -O -c minpriority.c -o minpriority.o
dynamiclib -Wl,-install_name -Wl,/usr/local/Cellar/mumps/5.1.1_1/lib/libpord.dylib -undefined dynamic_lookup -o libpord.dylib graph.o gbipart.o gbisect.o ddcreate.o ddbisect.o nestdiss.o multisector.o gelim.o bucket.o tree.o symbfac.o interface.o sort.o minpriority.o
make[2]: dynamiclib: No such file or directory
make[2]: [libpord.dylib] Error 1 (ignored)
echo libpord.dylib
libpord.dylib
if [ "./PORD/lib/" != "" ] ; then \
cp ./PORD/lib//libpord.dylib lib/libpord.dylib; \
fi;
cp: ./PORD/lib//libpord.dylib: No such file or directory
make[1]: *** [lib/libpord.dylib] Error 1
make: *** [c] Error 2
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/brewsci/homebrew-science/issues
Does anyone know how to solve this?
Unfortunately installation of mumps package with brew is very problematic at this moment. You have two different ways to install mumps
Method 1:
brew tap brewsci/science
brew install mumps
if that didn't work, download mumps.rb from here
brew install ./mumps.rb
Method 2
brew tap dpo/openblas
brew install mumps
The second method might lead to some issues with scalapack later.
Update: Unfortunately the above method might not work properly anymore. I have updated the installation method here.

How to build boost 1.56.0 boost::context for iphone (ARM)

I'm trying to build boost for iOS development and I found a auto build script on github.
Most libraries build fine and I got a boost.a. I have the asio library tested, it works.
But the boost::coroutine build fails, in fact the boost::context build fails with this error.
darwin.compile.c++ iphone-build/boost/bin.v2/libs/context/build/darwin-8.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-8.1/target-os-iphone/threading-multi/unsupported.o
libs/context/src/unsupported.cpp:7:2: error: "platform not supported"
#error "platform not supported"
^
1 error generated.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" "-arch" "armv7" "-arch" "armv7s" "-arch" "arm64" "-fvisibility=hidden" "-fvisibility-inlines-hidden" "-DBOOST_AC_USE_PTHREADS" "-DBOOST_SP_USE_PTHREADS" "-std=c++11" "-stdlib=libc++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -pthread -arch arm -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -D_LITTLE_ENDIAN -I"." -c -o "iphone-build/boost/bin.v2/libs/context/build/darwin-8.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-8.1/target-os-iphone/threading-multi/unsupported.o" "libs/context/src/unsupported.cpp"
...failed darwin.compile.c++ iphone-build/boost/bin.v2/libs/context/build/darwin-8.1~iphone/release/architecture-arm/link-static/macosx-version-iphone-8.1/target-os-iphone/threading-multi/unsupported.o...
And the boost::context requirements says we should
specify certain additional properties at bjam command line: target-os, abi, binary-format, architecture and address-model.
I change build script's bjam command line from
./bjam -j16 --build-dir=iphone-build -sBOOST_BUILD_USER_CONFIG=$BOOST_SRC/tools/build/example/user-config.jam --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphonemacosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage > "${LOG}" 2>&1
to
./bjam -j16 --build-dir=iphone-build -sBOOST_BUILD_USER_CONFIG=$BOOST_SRC/tools/build/example/user-config.jam --stagedir=iphone-build/stage --prefix=$PREFIXDIR toolset=darwin abi=aapcs binary-format=mach-o address-model=32 architecture=arm target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage > "${LOG}" 2>&1
now the compiler doing the right thing but I got another error
darwin.compile.asm iphone-build/boost/bin.v2/libs/context/build/darwin-8.1~iphone/release/abi-aapcs/address-model-32/architecture-arm/link-static/macosx-version-iphone-8.1/target-os-iphone/threading-multi/asm/jump_arm_aapcs_macho_gas.o
libs/context/src/asm/jump_arm_aapcs_macho_gas.S:94:11: error: invalid operand for instruction
pop v1
^
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" "-arch" "armv7" "-arch" "armv7s" "-arch" "arm64" "-fvisibility=hidden" "-fvisibility-inlines-hidden" "-DBOOST_AC_USE_PTHREADS" "-DBOOST_SP_USE_PTHREADS" "-std=c++11" "-stdlib=libc++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -arch arm -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -D_LITTLE_ENDIAN -I"." -c -o "iphone-build/boost/bin.v2/libs/context/build/darwin-8.1~iphone/release/abi-aapcs/address-model-32/architecture-arm/link-static/macosx-version-iphone-8.1/target-os-iphone/threading-multi/asm/jump_arm_aapcs_macho_gas.o" "libs/context/src/asm/jump_arm_aapcs_macho_gas.S"
`
Not just pop v1, and lots of other compile errors and after read the clang's Cross-compilation doc,
I decide to add -target arm-macho to auto script line 213.
Now, only one error pop v1 and 8 warnings like these:
clang: warning: unknown platform, assuming -mfloat-abi=soft
clang: warning: argument unused during compilation: '-arch armv7'
clang: warning: argument unused during compilation: '-stdlib=libc++'
clang: warning: argument unused during compilation: '-arch arm'
I know a little x86 asm and I read the libs/context/src/asm/jump_arm_aapcs_macho_gas.S, it seems that pop v1 should be pop {v1}, I don't know ARM asm, whatever, I just wanna make this pass and check error later.
So I change libs/context/src/asm/jump_arm_aapcs_macho_gas.S:94
from pop v1 to pop {v1} and build this again it finally works fine.
But just the context and coroutine library build fine. Other library such as libs/atomic/src/lockpool.cpp fails with error
libs/atomic/src/lockpool.cpp:15:10: fatal error: 'cstddef' file not found
As a dummy donkey, I'm out of skills.
Can somebody help me about this?
I should link all references, but my reputation is less than 10. I cannot post more than 2 links.
I just managed to build Boost.Context (1.59.0) with some modifications to the solution as provided by ofxiOSBoost from GitHub.
The problems with the original solution against building Boost.Context are:
the build script hard-codes the darwin toolset to use "clang++", which can only build pure C++ code, not the assembly code
as you have already figured out, the b2 command line as supplied by the build script doesn't include all the requirements to build Boost.Context, namely: abi, address-model, architecture, binary-format, these requirements are used to match the correct assembly source files inside "context/build/Jamfile.v2"
Even after you correctly specify all of the requirements, you still get compilation errors, which are actually generated from attempting to use the hardcoded clang++ to compile the assembly source code - btw, you should not modify the original assembly source code to just see it compiles.
Inside context/build/Jamfile.v2, you have to build the assembly code inline, instead of using clang++. Fortunately, there are some nice examples inside the same file teaching you how to build the assembly source code inline, so eventually clang++ will just see the generated object files, and the rest of the toolchain pipeline can happily consume them.
I am pasting the modifications I made in the Boost.Context Jamfile below (you should be smart enough to figure out where to put those sections):
actions gasarmv7
{
cpp -x assembler-with-cpp "$(>)" | as -arch armv7 -o "$(<)"
}
actions gasarm64
{
cpp -x assembler-with-cpp "$(>)" | as -arch arm64 -o "$(<)"
}
-
# ARM DARWIN 32_64
alias asm_context_sources
: [ make asm/make_arm_aapcs_macho_gas.o : asm/make_arm_aapcs_macho_gas.S : #gasarmv7 ]
[ make asm/jump_arm_aapcs_macho_gas.o : asm/jump_arm_aapcs_macho_gas.S : #gasarmv7 ]
[ make asm/make_arm64_aapcs_macho_gas.o : asm/make_arm64_aapcs_macho_gas.S : #gasarm64 ]
[ make asm/jump_arm64_aapcs_macho_gas.o : asm/jump_arm64_aapcs_macho_gas.S : #gasarm64 ]
: <abi>aapcs
<address-model>32_64
<architecture>arm
<binary-format>mach-o
<toolset>darwin
;
And below are the modifications to the build-libc++.sh:
Boost 1.58.0+ is recommended, since it Boost.Context added support for arm64
BOOST_V1=1.59.0
BOOST_V2=1_59_0
-
buildBoostForIPhoneOS()
{
cd $BOOST_SRC
# Install this one so we can copy the includes for the frameworks...
set +e
echo "------------------"
LOG="$LOGDIR/build-iphone-stage.log"
echo "Running bjam for iphone-build stage"
echo "To see status in realtime check:"
echo " ${LOG}"
echo "Please stand by..."
./bjam -j${PARALLEL_MAKE} --build-dir=iphone-build -sBOOST_BUILD_USER_CONFIG=$BOOST_SRC/tools/build/example/user-config.jam --stagedir=iphone-build/stage --prefix=$PREFIXDIR --toolset=darwin-${IPHONE_SDKVERSION}~iphone cxxflags="-stdlib=$STDLIB" variant=release linkflags="-stdlib=$STDLIB" architecture=arm address-model=32_64 abi=aapcs binary-format=mach-o target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static stage > "${LOG}" 2>&1
if [ $? != 0 ]; then
tail -n 100 "${LOG}"
echo "Problem while Building iphone-build stage - Please check ${LOG}"
exit 1
else
echo "iphone-build stage successful"
fi
echo "------------------"
LOG="$LOGDIR/build-iphone-install.log"
echo "Running bjam for iphone-build install"
echo "To see status in realtime check:"
echo " ${LOG}"
echo "Please stand by..."
./bjam -j${PARALLEL_MAKE} --build-dir=iphone-build -sBOOST_BUILD_USER_CONFIG=$BOOST_SRC/tools/build/example/user-config.jam --stagedir=iphone-build/stage --prefix=$PREFIXDIR --toolset=darwin-${IPHONE_SDKVERSION}~iphone cxxflags="-stdlib=$STDLIB" variant=release linkflags="-stdlib=$STDLIB" architecture=arm address-model=32_64 abi=aapcs binary-format=mach-o target-os=iphone macosx-version=iphone-${IPHONE_SDKVERSION} define=_LITTLE_ENDIAN link=static install > "${LOG}" 2>&1
if [ $? != 0 ]; then
tail -n 100 "${LOG}"
echo "Problem while Building iphone-build install - Please check ${LOG}"
exit 1
else
echo "iphone-build install successful"
fi
doneSection
echo "------------------"
LOG="$LOGDIR/build-iphone-simulator-build.log"
echo "Running bjam for iphone-sim-build "
echo "To see status in realtime check:"
echo " ${LOG}"
echo "Please stand by..."
./bjam -j${PARALLEL_MAKE} --build-dir=iphonesim-build -sBOOST_BUILD_USER_CONFIG=$BOOST_SRC/tools/build/example/user-config.jam --stagedir=iphonesim-build/stage --toolset=darwin-${IPHONE_SDKVERSION}~iphonesim architecture=x86 address-model=32_64 binary-format=mach-o abi=sysv target-os=iphone variant=release macosx-version=iphonesim-${IPHONE_SDKVERSION} link=static stage > "${LOG}" 2>&1
if [ $? != 0 ]; then
tail -n 100 "${LOG}"
echo "Problem while Building iphone-simulator build - Please check ${LOG}"
exit 1
else
echo "iphone-simulator build successful"
fi
doneSection
}
Pay special attention to the b2 command lines above (the requirements are specified there to match the Boost.Context Jamfile.v2 changes.
Also, as the original build script always tries to download and unpack the boost archive, so you need to might want to save the modifications to the Boost.Context Jamfile.v2 somewhere and re-apply it, or for the second run (after downloading, unpacking, and patching boost for at least once):
#cleanEverythingReadyToStart #may want to comment if repeatedly running during dev
#restoreBoost
#downloadBoost
#unpackBoost
#inventMissingHeaders
prepare
bootstrapBoost
#updateBoost
buildBoostForIPhoneOS
scrunchAllLibsTogetherInOneLibPerPlatform
buildIncludes
#restoreBoost
#postcleanEverything
Again, please get latest version from https://github.com/danoli3/ofxiOSBoost and use Boost 1.59.0
Hope this helps!

IOS Simulator getting FIPS signature mismatch when compiling FIPS/Openssl Solution on OS-x

I'm trying to get a OpenSSL/FIPS build forking on the IOS simulator. Every combination I've tried gives wither compile/link errors, or when it does build I get a FIPS signature mismatch (and I've tried many, many permutations of scripts and combinations of settings).
Here's the latest configuration I'm using:
Tool Set:
XCODE V 5 .1
SDK Version 7.1
For the FIPS module I'm using a script based on Appendix E of the Users Manual
For the OpenSSL build I'm using a script based on https://github.com/x2on/OpenSSL-for-iPhone
FIPS module build script:
gunzip openssl-fips-2.0.1.tar.gz
tar xf openssl-fips-2.0.1.tar
. setenv-reset.sh
. setenv-darwin-i386.sh
gunzip ios-incore-2.0.1.tar.gz
tar xf ios-incore-2.0.1.tar
cd openssl-fips-2.0.1
./config fipscanisterbuild
make
cd ios
make
cp ./incore_macho /usr/local/bin
cd ..
make clean
rm -f *.dylib
. ../setenv-reset.sh
. ../setenv-ios-11.sh
./config fipscanisterbuild
make
make install
Here are the Enviornment Variables
=========================
MACHINE = i386
RELEASE =
SYSTEM = iphoneos
BUILD = build
CROSS_TOP = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
CROSS_SDK = iPhoneSimulator7.1.sdk
BUILD_TOOLS =
CC =
CROSS_TYPE = Simulator
CROSS_CHAIN =
C_INCLUDE_PATH =
CPLUS_INCLUDE_PATH =
HOSTCC = /usr/bin/cc
HOSTCFLAGS = -arch i386
CROSS_COMPILE = /Users/scoleman/dev/IOSFipsBuilds/iosFIPSUsersManual/dev925/openssl-fips-2.0.1/iOS/
FIPS_SIG = /Users/scoleman/dev/IOSFipsBuilds/iosFIPSUsersManual/dev925/openssl-fips-2.0.1/iOS/incore_macho
IOS_TARGET = darwin-iphoneos-cross
IOS_INSTALLDIR = /usr/local/ssl/Release-iphoneos
CONFIG_OPTIONS = no-asm no-shared --openssldir=/usr/local/ssl/Release-iphoneos
CROSS_ARCH =
CROSS_DEVELOPER = /Applications//Xcode.app/Contents/Developer
CROSS_SYSROOT =
IOS_TARGET =
Openssl module build script
VERSION="1.0.1i" #
SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` #
# Don't change anything under this line! #
CURRENTPATH=`pwd`
//ARCHS="i386 x86_64 armv7 armv7s arm64"
ARCHS="i386"
DEVELOPER=`xcode-select -print-path`
mkdir -p "${CURRENTPATH}/src"
mkdir -p "${CURRENTPATH}/bin"
mkdir -p "${CURRENTPATH}/lib"
tar zxf openssl-${VERSION}.tar.gz -C "${CURRENTPATH}/src"
cd "${CURRENTPATH}/src/openssl-${VERSION}"
for ARCH in ${ARCHS}
do
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
PLATFORM="iPhoneOS"
fi
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log"
set +e
if [[ "$VERSION" =~ 1.0.0. ]]; then
./Configure BSD-generic32 --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
elif [ "${ARCH}" == "x86_64" ]; then
./Configure darwin64-x86_64-cc --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
else
# - original line: ./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
## this line was changed to add fips --with-fipsdir=/usr/local/ssl/Release-iphoneos
./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" fips --with-fipsdir=/usr/local/ssl/Release-iphoneos > "${LOG}" 2>&1
fi
if [ $? != 0 ];
then
echo "Problem while configure - Please check ${LOG}"
exit 1
fi
# add -isysroot to CC=
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 !" "Makefile"
echo "PLATFORM = $PLATFORM"
echo "CROSS_TOP = $CROSS_TOP"
echo "CROSS_SDK = $CROSS_SDK"
echo "BUILD_TOOLS = $BUILD_TOOLS"
echo "-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK}"
echo "CC = $CC"
make >> "${LOG}" 2>&1
set -e
make install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1
done
echo "Build library..."
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssl.a -output ${CURRENTPATH}/lib/libssl.a
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libcrypto.a -output ${CURRENTPATH}/lib/libcrypto.a
mkdir -p ${CURRENTPATH}/include
cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/openssl ${CURRENTPATH}/include/
echo "Building done."
echo "Cleaning up..."
rm -rf ${CURRENTPATH}/src/openssl-${VERSION}
echo "Done."
Here are the Environment Variables:
--------------------------
PLATFORM = iPhoneSimulator
CROSS_TOP = /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
CROSS_SDK = iPhoneSimulator7.1.sdk
BUILD_TOOLS = /Applications/Xcode.app/Contents/Developer
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk
CC = /Applications/Xcode.app/Contents/Developer/usr/bin/gcc -arch i386
I'm trying to get a OpenSSL/FIPS build forking on the IOS simulator. Every combination I've tried gives wither compile/link errors, or when it does build I get a FIPS signature mismatch (and I've tried many, many permutations of scripts and combinations of settings).
It looks like your're missing a step. Where is the invocation of incore_macho on the resulting binary? Here, "resulting binary" is the executable from your app.
In the OpenSSL sample, there is a custom build step called Embed Fingerprint under the Taget's Build Phases (its not available at the Project level). You can find the sample in the OpenSSL User Guide 2.0 for the FIPS Object Module, Appendix E.2. The screenshot is reproduced below:
You might also find this useful. Its an updated incore_macho that include support for dylibs (for jail broken devices) and ARM64. I'm pretty sure it includes ARMv7s support.

Unknown cpu type when compiling OpenSSL FIPS Capable libraries for arm64 or arm7s

I can successfully (at least without warnings and with resulting .a files) compile for arm7, x86_64, and i386.
When I compile for arm64, I get Unknown cpu type 100000c, no adjustments made. When I compile for arm7s, I get Unknown cpu type 100000c, no adjustments made. The script for those two architectures, which is modified from and uses environment scripts from https://github.com/noloader/openssl-1.0.1i-ios is below including arm7, which works and arm7s and arm64, followed by a log tail for arm64. The scripts build non-fips libraries successfully before modification. incore_macho and fips canisters are pre-generated and referenced from this script. I created the fips canisters similarly by modifying instructions from the OpenSSL FIPS 2.0 User Guide iOS appendix, which is incredibly dated and does not work on its own. How can one compile a FIPS capable library for these two platforms?
Edit:
I see that libssl.a and libcrypto.a have actually been created and have the correct architectures, but incore_macho returns an identical Unknown cpu type error.
Update:
Using a copy of incore_macho that is updated for armv7 from #jww at https://github.com/noloader/incore_macho, it now compiles without error for arm7s, so I'm now under the assumption that core_macho may need to be updated for arm64. Can this be done?
sed -i "" 's|\"iphoneos-cross\"\,\"llvm-gcc\:-O3|\"iphoneos-cross\"\,\"clang\:-Os|g' Configure
sed -i "" 's/CC= cc/CC= clang/g' Makefile.org
sed -i "" 's/CFLAG= -O/CFLAG= -Os/g' Makefile.org
sed -i "" 's/MAKEDEPPROG=makedepend/MAKEDEPPROG=$(CC) -M/g' Makefile.org
export LANG=$OLD_LANG
export CC=clang
export IOS_INSTALLDIR="/usr/local/ssl/ios"
unset OPENSSLDIR
################################################################
# Third, build ARMv7
echo "****************************************"
THIS_ARCH=armv7
unset CROSS_ARCH
. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"
./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a
################################################################
# Fourth, build ARMv7s
echo "****************************************"
THIS_ARCH=armv7s
unset CROSS_ARCH
. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"
./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl-fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a
################################################################
# Fifth, build ARM64
#echo "****************************************"
THIS_ARCH=arm64
unset CROSS_ARCH
. ./setenv-ios-$THIS_ARCH.sh
export HOSTCC=/usr/bin/cc
export HOSTCFLAGS="-arch i386"
export FIPS_SIG="/tmp/incore_macho"
./config fips -no-ssl2 -no-ssl3 -no-asm -no-shared -no-hw -no-engine --with-fipsdir="/tmp/openssl-fips-2.0.1-iOS-${THIS_ARCH}" --openssldir=$IOS_INSTALLDIR
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.1 !" "Makefile"
make clean 2>&1>/dev/null && make all
mkdir $THIS_ARCH
\cp ./libcrypto.a $THIS_ARCH/libcrypto.a
\cp ./libssl.a $THIS_ARCH/libssl.a
tail of output for arm64:
shlib_target=; if [ -n "" ]; then \
shlib_target="darwin-shared"; \
elif [ -n "libcrypto" ]; then \
FIPSLD_CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"; CC=/tmp/openssl-fips-2.0.1-iOS-arm64/bin/fipsld; export CC FIPSLD_CC; \
fi; \
LIBRARIES="-L.. -lssl -L.. -lcrypto" ; \
make -f ../Makefile.shared -e \
APPNAME=openssl OBJECTS="openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o" \
LIBDEPS="-Wl,-search_paths_first $LIBRARIES " \
link_app.${shlib_target}
( :; LIBDEPS="${LIBDEPS:--Wl,-search_paths_first -L.. -lssl -L.. -lcrypto }"; LDCMD="${LDCMD:-/tmp/openssl-fips-2.0.1-iOS-arm64/bin/fipsld}"; LDFLAGS="${LDFLAGS:--isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -miphoneos-version-min=7.1 -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch arm64 -Os -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -fomit-frame-pointer -fno-common -I/tmp/openssl-fips-2.0.1-iOS-arm64/include}"; LIBPATH=`for x in $LIBDEPS; do echo $x; done | sed -e 's/^ *-L//;t' -e d | uniq`; LIBPATH=`echo $LIBPATH | sed -e 's/ /:/g'`; LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH ${LDCMD} ${LDFLAGS} -o ${APPNAME:=openssl} openssl.o verify.o asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o ec.o ecparam.o x509.o genrsa.o gendsa.o genpkey.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o pkey.o pkeyparam.o pkeyutl.o spkac.o smime.o cms.o rand.o engine.o ocsp.o prime.o ts.o srp.o ${LIBDEPS} )
Unknown cpu type 100000c, no adjustments made
It will work if you add this to cpu_adjustment[]
CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_ALL, 12, 12 ,
For reference:
#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */
#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64)
/*
* ARM64 subtypes
*/
#define CPU_SUBTYPE_ARM64_ALL ((cpu_subtype_t) 0)
Finding the adjustment was fun. ;-)
I've modified the CPU type before, so it's doable. You may also need to modify the CPU adjustment as well. You need to add an entry to cpu_adjustment[] in incore_macho.c and cputype
I think for arm64 it is CPU_SUBTYPE_ARM64_V8 I do not know the adjustment. Please let us know if you get this to work

"pecl install imagick" fails on mountain lion. can't find "wand/MagickWand.h"

Pretty much what it sounds like. I did:
brew install imagemagick
That seemed to go well--so the problem is not with imagemagick itself.
I then tried to install the PHP extension (updating pear and pecl before trying):
pecl install imagick
It fails. Here's what happens near the end:
running: make
/bin/sh /private/tmp/pear/install/pear-build-brad.garrettZppuRq/imagick-3.0.1/libtool --mode=compile cc -I. -I/private/tmp/pear/install/imagick -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-brad.garrettZppuRq/imagick-3.0.1/include -I/private/tmp/pear/install/pear-build-brad.garrettZppuRq/imagick-3.0.1/main -I/private/tmp/pear/install/imagick -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/imagick/imagick_class.c -o imagick_class.lo
mkdir .libs
cc -I. -I/private/tmp/pear/install/imagick -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-brad.garrettZppuRq/imagick-3.0.1/include -I/private/tmp/pear/install/pear-build-brad.garrettZppuRq/imagick-3.0.1/main -I/private/tmp/pear/install/imagick -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/imagick/imagick_class.c -fno-common -DPIC -o .libs/imagick_class.o
In file included from /private/tmp/pear/install/imagick/imagick_class.c:21:
/private/tmp/pear/install/imagick/php_imagick.h:49:12: fatal error: 'wand/MagickWand.h' file not found
# include <wand/MagickWand.h>
^
1 error generated.
make: *** [imagick_class.lo] Error 1
ERROR: `make' failed
Any ideas?? This is only the umpteenth time I've had issues installing imagemagick on a computer. Seems they change little things here and there all the time (for instance, I've never heard of "magickwand" before now).
I complied ImageMagick according to http://www.imagemagick.org/script/install-source.php#unix
Then I followed http://verysimple.com/2011/12/21/install-image-magick-for-php-on-osx/
Had the following error fatal error: 'wand/MagickWand.h' file not found
Then I found http://www.imagemagick.org/discourse-server/viewtopic.php?f=10&t=22644
Had to find the solution in config.m4, it was exporting pkgconfig:
export PKG_CONFIG_PATH="`MagickWand-config --prefix`/lib/pkgconfig/"
Then I configured with the following:
LDFLAGS="-L/usr/local/lib" CPPFLAGS="-I/usr/local/include" ./configure --with-imagick=/usr/local

Resources