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

时间:2014-10-31 06:42:22

标签: ios macos boost arm coroutine

我正在尝试为iOS开发构建强大功能,我在github上找到了一个自动构建脚本。 大多数图书馆建立得很好,我得到了一个提升.a。我测试了asio库,它可以工作。

但boost :: coroutine构建失败,实际上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- iPhone OS的/线程的多/ 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 =隐藏" " -fvisibility-内联隐藏" " -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- iPhone OS的/线程的多/ unsupported.o" "库/上下文/ 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 /线程的多/ unsupported.o ...

boost :: context要求说我们应该  在bjam命令行中指定某些附加属性:target-os,abi,binary-format,architecture和address-model。 我从

更改了构建脚本的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的版本-iphone-8.1 /目标-OS-iphone /线程的多/ 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 =隐藏" " -fvisibility-内联隐藏" " -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的版本-iphone-8.1 /目标-OS-iphone /线程的多/ ASM / jump_arm_aapcs_macho_gas.o" "库/上下文/ SRC / ASM / jump_arm_aapcs_macho_gas.S"   `

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

  

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

我知道一点x86 asm并且我读了 libs / context / src / asm / jump_arm_aapcs_macho_gas.S ,似乎pop v1应该是pop {v1},我不知道#39;不知道ARM asm,无论如何,我只想做这个传递并稍后检查错误。

所以我更改了libs / context / src / asm / jump_arm_aapcs_macho_gas.S:94 从pop v1pop {v1}并再次构建它最终会正常工作。

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

  

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

作为假驴,我没有技能。

有人可以帮我解决这个问题吗?

我应该链接所有引用,但我的声誉小于10.我不能发布超过2个链接。

1 个答案:

答案 0 :(得分:4)

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

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

  1. 构建脚本对darwin工具集进行硬编码以使用" clang ++",它只能构建纯C ++代码,汇编代码
  2. 正如您已经想到的那样,构建脚本提供的b2命令行并不包含构建Boost.Context的所有要求,即:abi,地址模型,体系结构,二进制格式,这些需求用于匹配" context / build / Jamfile.v2"
  3. 中的正确汇编源文件
  4. 即使您正确指定了所有要求之后,仍然会遇到编译错误,这些错误实际上是通过尝试使用硬编码的clang ++编译汇编源代码生成的 - 顺便说一句,您不应该将原始汇编源代码修改为仅看它汇编。
  5. 在context / build / Jamfile.v2中,你必须构建汇编代码 inline ,而不是使用clang ++。幸运的是,在同一个文件中有一些很好的例子,教你如何内联构建汇编源代码,所以最终clang ++只会看到生成的目标文件,而工具链管道的其余部分可以很乐意使用它们。
  6. 我正在粘贴我在下面的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更改。

    此外,由于原始构建脚本总是尝试下载并解压缩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
    

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

    希望这有帮助!