如何构build提升1.56.0 boost :: context for iphone(ARM)

我正在尝试为iOS开发构buildboost,并在github上find了自动构build脚本。 大多数的图书馆build设很好,我得到了一个boost.a。 我有testing的asio库,它的工作原理。

但boost :: coroutine构build失败,事实上boost :: context构build失败,出现此错误。

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 /thread/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 – 一世”。” -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 /thread/multi/unsupported.o“”libs / context / src / unsupported.cpp“…失败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 …

而且boost :: context要求我们应该在bjam命令行中指定一些额外的属性:target-os,abi,binary-format,architecture和address-model。 我更改构build脚本的BJAM命令行

./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

./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

现在编译器做正确的事情,但我得到了另一个错误

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:指令pop v1的无效操作数^

“/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++”“-arch”“armv7”“-arch”“armv7s”“-arch”“arm64”“-fvisibility = hidden “-DBOOST_AC_USE_PTHREADS”“-DBOOST_SP_USE_PTHREADS”“-std = c ++ 11”“-stdlib = libc ++”-x汇编程序与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“

不只是pop v1 ,还有很多其他编译错误,在阅读了clang的交叉编译文档之后,我决定将-target arm-macho添加到自动脚本行213.现在,只有一个错误pop v1和8这样的警告:

铛:警告:未知的平台,假设-mfloat-abi = soft clang:warning:参数在编译过程中未被使用:'-arch armv7'clang:warning:参数在编译过程中未被使用:'-stdlib = libc ++'clang:warning:编译:'-arch arm'

我知道一些x86的asm,我读了libs / context / src / asm / jump_arm_aapcs_macho_gas.S ,似乎pop v1应该是pop {v1} ,我不知道ARM asm,不pipe怎样,我只是想通过并稍后检查错误。

所以我改变了libs / context / src / asm / jump_arm_aapcs_macho_gas.S:94从pop v1pop {v1} ,再次构build它,它终于可以正常工作。

但只是上下文和协程库build立好。 其他库,如libs/atomic/src/lockpool.cpp失败,错误

libs / atomic / src / lockpool.cpp:15:10:致命错误:找不到'cstddef'文件

作为一个假驴,我没有技能。

有人可以帮我吗?

我应该链接所有引用,但是我的声望不到10。我不能发布超过2个链接。

我只是设法构buildBoost.Context(1.59.0),并对GitHub的xxiOSBoost提供的解决scheme进行了一些修改。

针对构buildBoost.Context的原始解决scheme的问题是:

  1. 构build脚本将达尔文工具集硬编码为使用“铿锵++”,它只能build立纯粹的C ++代码, 而不是汇编代码
  2. 正如你已经想到的那样,构build脚本提供的b2命令行并不包含构buildBoost.Context的所有需求,即:abi,address-model,architecture,binary-format,这些需求用于匹配“context / build / Jamfile.v2”里面正确的汇编源文件
  3. 即使你正确地指定了所有的需求,你仍然会得到编译错误,这些错误实际上是通过尝试使用硬编码的clang ++来编译程序集源代码而产生的 – btw,你不应该修改原始程序集源代码来看它编译。
  4. 在上下文/构build/ Jamfile.v2中,您必须内联构build汇编代码,而不是使用clang ++。 幸运的是,在同一个文件里面有一些很好的例子,教你如何在内部构build汇编源代码,所以最终clang ++只会看到生成的目标文件,其余的工具链pipe道可以愉快地使用它们。

我正在粘贴我在Boost.Context Jamfile下面所做的修改(你应该足够聪明,弄清楚在哪里放置这些部分):

 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 ; 

下面是对build-libc ++的修改:sh:

推荐使用Boost 1.58.0+,因为Boost.Context增加了对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 } 

要特别注意上面的b2命令行(在那里指定要求以匹配Boost.Context Jamfile.v2更改。

此外,由于原始构build脚本总是尝试下载和解压缩压缩归档文件,所以您需要将修改保存到Boost.Context Jamfile.v2的某处并重新应用,或者第二次运行(在下载之后,解包和修补至less一次):

 #cleanEverythingReadyToStart #may want to comment if repeatedly running during dev #restoreBoost #downloadBoost #unpackBoost #inventMissingHeaders prepare bootstrapBoost #updateBoost buildBoostForIPhoneOS scrunchAllLibsTogetherInOneLibPerPlatform buildIncludes #restoreBoost #postcleanEverything 

再次请从https://github.com/danoli3/ofxiOSBoost获取最新版本,并使用Boost 1.59.0

希望这可以帮助!

Interesting Posts