如何为iPhone(ARM)构建Boost 1.56.0 boost :: context

eth*_*hae 1 macos boost arm coroutine ios

我正在尝试为iOS开发构建增强功能,并且在github上找到了一个自动构建脚本。大多数库都运行良好,我得到了提升。我已经测试过asio库,它可以工作。

但是boost ::协程构建失败,实际上boost :: context构建因该错误而失败。

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“不支持平台” ^ 1错误生成。

“ /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。

boost :: context要求表明,我们应该在bjam命令行中指定某些其他属性:target-os,abi,二进制格式,体系结构和地址模型。我从以下更改构建脚本的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体系结构= arm target-os = iphonemacosx-version = iphone-$ {IPHONE_SDKVERSION} define = _LITTLE_ENDIAN link =静态阶段>“ $ {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二进制格式=马赫-o地址模型= 32体系结构= arm目标操作系统= 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:错误:指令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汇编程序与cpp -O3 -finline-functions -Wno-inline-墙-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。

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

铛:警告:未知平台,假设-mfloat-abi = soft铛:警告:编译期间未使用的参数:-arch Armv7铛:警告:编译期间未使用的参数:-stdlib = libc ++铛:警告:在编译期间未使用的参数编译:'-拱臂'

我知道一些x86 asm,并且阅读了libs / context / src / asm / jump_arm_aapcs_macho_gas.S,似乎pop v1应该是pop {v1},我不知道ARM asm,无论如何,我只想通过此检查并稍后检查错误。

因此,我将libs / context / src / asm / jump_arm_aapcs_macho_gas.S:94从pop v1更改为,pop {v1}并再次构建它,终于可以正常工作了。

但是只是上下文和协程库可以很好地构建。其他库,例如由于libs/atomic/src/lockpool.cpp错误而失败

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

作为假驴,我没有技能。

有人可以帮我吗?

我应该链接所有引用,但我的声誉低于10。我不能发布2个以上的链接。

Dej*_*avu 5

我刚刚设法构建了Boost.Context(1.59.0),并对该解决方案进行了一些修改,该解决方案由GitHub的ofxiOSBoost提供。

反对构建Boost.Context的原始解决方案的问题是:

  1. 构建脚本将darwin工具集硬编码为使用“ clang ++”,后者只能构建纯C ++代码,而不能构建汇编代码
  2. 如您所知,构建脚本提供的b2命令行并不包含构建Boost.Context的所有要求,即:abi,地址模型,体系结构,二进制格式,这些要求用于匹配“ context / build / Jamfile.v2”中正确的程序集源文件
  3. 即使正确地指定了所有要求,您仍然会遇到编译错误,这些错误实际上是尝试使用硬编码的clang ++编译程序集源代码而产生的-btw,您不应修改原始程序集源代码以使其仅能编译。
  4. 在context / build / Jamfile.v2内部,您必须内联构建汇编代码,而不是使用clang ++。幸运的是,在同一文件中有一些不错的示例,它们教您如何内联构建程序集源代码,因此最终clang ++只会看到生成的目标文件,其余的工具链管道可以愉快地使用它们。

我将在下面的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 "$(<)"
}
Run Code Online (Sandbox Code Playgroud)

--

# 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
   ;
Run Code Online (Sandbox Code Playgroud)

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

建议使用Boost 1.58.0+,因为Boost.Context添加了对arm64的支持

BOOST_V1=1.59.0
BOOST_V2=1_59_0
Run Code Online (Sandbox Code Playgroud)

--

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
}
Run Code Online (Sandbox Code Playgroud)

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

另外,由于原始构建脚本总是尝试下载并解压缩boost存档,因此您可能需要将对Boost.Context Jamfile.v2的修改保存在某个地方,然后重新应用它,或者进行第二次运行(下载后) ,解压缩和修补至少一次):

#cleanEverythingReadyToStart #may want to comment if repeatedly running during dev
#restoreBoost

#downloadBoost
#unpackBoost
#inventMissingHeaders
prepare
bootstrapBoost
#updateBoost
buildBoostForIPhoneOS
scrunchAllLibsTogetherInOneLibPerPlatform
buildIncludes

#restoreBoost

#postcleanEverything
Run Code Online (Sandbox Code Playgroud)

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

希望这可以帮助!