gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:52:03 27 4
gpt4 key购买 nike

我正在尝试为 iOS 开发构建 boost,我在 github 上找到了一个自动构建脚本.
大多数图书馆都建得很好,我得到了一个 boost.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-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...



而 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 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: 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" `



不仅仅是 pop v1 ,以及许多其他编译错误,并且在阅读了 clang 的交叉编译文档之后,
我决定添加 -target arm-machoauto script第 213 行。
现在,只有一个错误 pop v1和 8 个这样的警告:

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'



我知道一点 x86 asm,我阅读了 库/上下文/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 v1pop {v1}并再次构建它,它终于可以正常工作了。

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

libs/atomic/src/lockpool.cpp:15:10: fatal error: 'cstddef' file not found



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

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

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

最佳答案

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

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

  • 构建脚本将 darwin 工具集硬编码为使用“clang++”,它只能构建纯 C++ 代码,不能构建汇编代码
  • 正如您已经发现的那样,构建脚本提供的 b2 命令行不包括构建 Boost.Context 的所有要求,即:abi、地址模型、架构、二进制格式,这些要求用于匹配“context/build/Jamfile.v2”中的正确汇编源文件
  • 即使您正确指定了所有要求,您仍然会得到编译错误,这些错误实际上是由于尝试使用硬编码的 clang++ 编译程序集源代码而产生的 - 顺便说一句,您不应该修改原始程序集源代码以仅看到它编译.
  • 在 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 "$(<)"
    }

    -
    # 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 某处并重新应用它,或者用于第二次运行(下载后,拆包和修补 boost 至少一次):
    #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

    希望这可以帮助!

    关于ios - 如何为 iPhone (ARM) 构建 boost 1.56.0 boost::context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26668858/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com