androidboostb2

How do I build Boost for Android?


I am trying to cross-compile Boost for Android, from a Dockcross container (i.e. it has the environment variables AS, AR, CC, CXX, LD set to the toolchain) by running the following commands:

$ ./bootstrap.sh
$ ./b2 architecture=arm address-model=32 binary-format=elf abi=aapcs target-os=android

My hope is that I don't need a user-config.jam, given that I pass everything to ./b2.

However, I am getting the errors looking like below:

    "g++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -fvisibility=hidden  -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DBOOST_DISABLE_ASSERTS -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/gcc-10/release/abi-aapcs/address-model-32/architecture-arm/link-static/target-os-android/threading-multi/visibility-hidden/asm/jump_arm_aapcs_elf_gas.o" "libs/context/src/asm/jump_arm_aapcs_elf_gas.S"

...failed gcc.compile.asm bin.v2/libs/context/build/gcc-10/release/abi-aapcs/address-model-32/architecture-arm/link-static/target-os-android/threading-multi/visibility-hidden/asm/jump_arm_aapcs_elf_gas.o...
gcc.compile.asm bin.v2/libs/context/build/gcc-10/release/abi-aapcs/address-model-32/architecture-arm/link-static/target-os-android/threading-multi/visibility-hidden/asm/ontop_arm_aapcs_elf_gas.o
ontop_arm_aapcs_elf_gas.S: Assembler messages:
ontop_arm_aapcs_elf_gas.S:46: Error: unknown pseudo-op: `.syntax'
ontop_arm_aapcs_elf_gas.S:48: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:49: Error: invalid char '{' beginning operand 1 `{lr}'
ontop_arm_aapcs_elf_gas.S:50: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:51: Error: invalid char '{' beginning operand 1 `{a1'
ontop_arm_aapcs_elf_gas.S:53: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:54: Error: too many memory references for `sub'
ontop_arm_aapcs_elf_gas.S:60: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:61: Error: too many memory references for `mov'
ontop_arm_aapcs_elf_gas.S:63: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:64: Error: too many memory references for `mov'
ontop_arm_aapcs_elf_gas.S:66: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:67: Error: too many memory references for `mov'
ontop_arm_aapcs_elf_gas.S:73: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:74: Error: too many memory references for `add'
ontop_arm_aapcs_elf_gas.S:76: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:77: Error: invalid char '{' beginning operand 1 `{a1'
ontop_arm_aapcs_elf_gas.S:79: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:80: Error: invalid char '[' beginning operand 2 `[a1'
ontop_arm_aapcs_elf_gas.S:81: Error: invalid char '[' beginning operand 2 `[a1'
ontop_arm_aapcs_elf_gas.S:82: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:83: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:85: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:86: Error: too many memory references for `add'
ontop_arm_aapcs_elf_gas.S:88: Error: junk at end of line, first unrecognized character is `@'
ontop_arm_aapcs_elf_gas.S:89: Error: no such instruction: `bx a4'
ontop_arm_aapcs_elf_gas.S:92: Error: junk at end of line, first unrecognized character is `@'

What am I missing?


Solution

  • A jam file is required, like so (let's call it dockcross-config.jam):

    import os ;
    
    using clang : arm : [ os.environ CXX ] :
    <cxxflags>"-fPIC"
    <cflags>"-fPIC" ;
    

    And then it can be passed to b2 with --user-config=:

    $ ./b2 --user-config=dockcross-config.jam --without-python architecture=arm address-model=32 binary-format=elf abi=aapcs target-os=android
    

    Also note --without-python, which I needed for Android.