[Boost.build] Building for ARM64
Hi, In my quest cross-compiling Boost.Context for ARM64, I encounter the following problem (using develop since ARM64 support is not in 1.57): $ ./bootstrap.sh --with-libraries=context [...] $ ./b2 -d2 -q toolset=clang architecture=arm abi=aapcs address-model=64 binary-format=mach-o [...] "clang++" -o "bin.v2/libs/system/build/clang-darwin-4.2.1/release/abi- aapcs/address-model-64/architecture-arm/threading-multi/libboost_system.dylib" -single_module -dynamiclib -install_name "libboost _system.dylib" "bin.v2/libs/system/build/clang-darwin-4.2.1/release/abi- aapcs/address-model-64/architecture-arm/threading-multi/error_code.o" Despite asking for arm, the "-arch arm64" I would expect is not passed to clang which thus compile to x86_64. However Boost.Context DOES understand I'm targeting arm since it picks the right ASM file: "clang++" -x assembler-with-cpp -O3 -O3 -finline-functions -Wno-inline - Wall -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_DYN_LINK=1 - DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_CONTEXT_SOURCE -DBOOST_SYSTEM_DYN_LINK=1 - DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_POSIX - DBOOST_THREAD_USE_DLL=1 -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/clang- darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading- multi/asm/make_arm64_aapcs_macho_gas.o" "libs/context/src/asm/make_arm64_aapcs_macho_gas.S" Which yields assembly errors of course since "-arch arm64" is not passed. Other sources seem to manage to build Boost for ARM64 using darwin toolset forcing clang as the compiler and passing many additional options, but their setup fails to build Boost.Context since it either picks the wrong ASM file, either complains the platform is not supported. Thanks in advance ! -- Quentin "mefyl" Hocquet CTO @ infinit.io
On 01/13/2015 03:15 PM, mefyl wrote:
Hi,
In my quest cross-compiling Boost.Context for ARM64, I encounter the following problem (using develop since ARM64 support is not in 1.57):
$ ./bootstrap.sh --with-libraries=context [...] $ ./b2 -d2 -q toolset=clang architecture=arm abi=aapcs address-model=64 binary-format=mach-o [...] "clang++" -o "bin.v2/libs/system/build/clang-darwin-4.2.1/release/abi- aapcs/address-model-64/architecture-arm/threading-multi/libboost_system.dylib" -single_module -dynamiclib -install_name "libboost _system.dylib" "bin.v2/libs/system/build/clang-darwin-4.2.1/release/abi- aapcs/address-model-64/architecture-arm/threading-multi/error_code.o"
Despite asking for arm, the "-arch arm64" I would expect is not passed to clang which thus compile to x86_64. However Boost.Context DOES understand I'm targeting arm since it picks the right ASM file:
"clang++" -x assembler-with-cpp -O3 -O3 -finline-functions -Wno-inline - Wall -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_CHRONO_DYN_LINK=1 - DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_CONTEXT_SOURCE -DBOOST_SYSTEM_DYN_LINK=1 - DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_POSIX - DBOOST_THREAD_USE_DLL=1 -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/clang- darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading- multi/asm/make_arm64_aapcs_macho_gas.o" "libs/context/src/asm/make_arm64_aapcs_macho_gas.S"
Which yields assembly errors of course since "-arch arm64" is not passed.
Other sources seem to manage to build Boost for ARM64 using darwin toolset forcing clang as the compiler and passing many additional options, but their setup fails to build Boost.Context since it either picks the wrong ASM file, either complains the platform is not supported.
Hi Quentin, it does not appear that anybody made clang-darwing.jam do anything about architecture or address-model features. Would the following patch work for you? diff --git a/src/tools/clang-darwin.jam b/src/tools/clang-darwin.jam index 51e5fad..2976030 100644 --- a/src/tools/clang-darwin.jam +++ b/src/tools/clang-darwin.jam @@ -72,6 +72,8 @@ rule init ( version ? : command * : options * ) SPACE = " " ; +flags clang-darwing OPTIONS <architecture>arm <address-model>64 : -arch arm64 ; + flags clang-darwin.compile OPTIONS <cflags> ; flags clang-darwin.compile.c++ OPTIONS <cxxflags> ; # flags clang-darwin.compile INCLUDES <include> ; -- Vladimir Prus CodeSourcery / Mentor Embedded http://vladimirprus.com
On Tuesday 13 January 2015 13:49:29 Akim Demaille wrote:
Le 13 janv. 2015 à 13:42, Vladimir Prus
a écrit : +flags clang-darwing OPTIONS <architecture>arm <address-model>64 : -arch arm64
Isn't darwing a typo?
I took the liberty of fixing that to "darwin" =) Thanks a lot, works like a charm ! For the record, all you need to add is the SDKROOT so clang finds the iPhone headers: $ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk ./b2 -q toolset=clang architecture=arm abi=aapcs address-model=64 binary-format=mach-o [...] $ lipo -info bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading-multi/libboost_context.dylib Non-fat file: bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading-multi/libboost_context.dylib is architecture: arm64 $ Thanks a lot ! -- Quentin "mefyl" Hocquet CTO @ infinit.io
On 01/13/2015 04:45 PM, mefyl wrote:
On Tuesday 13 January 2015 13:49:29 Akim Demaille wrote:
Le 13 janv. 2015 à 13:42, Vladimir Prus
a écrit : +flags clang-darwing OPTIONS <architecture>arm <address-model>64 : -arch arm64
Isn't darwing a typo?
I took the liberty of fixing that to "darwin" =)
Thanks a lot, works like a charm ! For the record, all you need to add is the SDKROOT so clang finds the iPhone headers:
$ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk ./b2 -q toolset=clang architecture=arm abi=aapcs address-model=64 binary-format=mach-o [...] $ lipo -info bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading-multi/libboost_context.dylib Non-fat file: bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-model-64/architecture-arm/threading-multi/libboost_context.dylib is architecture: arm64
Cool. Could you suggest entire set of -arch options that should be added to clang-darwin.jam? -- Vladimir Prus CodeSourcery / Mentor Embedded http://vladimirprus.com
On Tuesday 13 January 2015 17:06:55 Vladimir Prus wrote:
On 01/13/2015 04:45 PM, mefyl wrote:
On Tuesday 13 January 2015 13:49:29 Akim Demaille wrote:
Le 13 janv. 2015 à 13:42, Vladimir Prus
a écrit : +flags clang-darwing OPTIONS <architecture>arm <address-model>64 : -arch arm64
Isn't darwing a typo?
I took the liberty of fixing that to "darwin" =)
Thanks a lot, works like a charm ! For the record, all you need to add is the SDKROOT so clang finds the iPhone headers:
$ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.pla tform/Developer/SDKs/iPhoneOS8.1.sdk ./b2 -q toolset=clang architecture=arm abi=aapcs address-model=64 binary-format=mach-o [...] $ lipo -info bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-mo del-64/architecture-arm/threading-multi/libboost_context.dylib Non-fat file: bin.v2/libs/context/build/clang-darwin-4.2.1/release/abi-aapcs/address-mo del-64/architecture-arm/threading-multi/libboost_context.dylib is architecture: arm64 Cool. Could you suggest entire set of -arch options that should be added to clang-darwin.jam?
Sure, here are the ones I actively use: flags clang-darwin OPTIONS <architecture>arm <address-model>32 : -arch armv7 ; flags clang-darwingOPTIONS <architecture>arm <address-model>64 : -arch arm64 ; flags clang-darwin OPTIONS <architecture>x86 <address-model>32 : -arch x86 ; flags clang-darwin OPTIONS <architecture>x86 <address-model>64 : -arch x86_64 ;
From the clang documentation, I would infer these, altough I can't test them:
flags clang-darwin OPTIONS <architecture>sparc : -arch sparc ; // sparcv9 also exists flags clang-darwin OPTIONS <architecture>power <address-model>32 : -arch ppc ; flags clang-darwin OPTIONS <architecture>power <address-model>64 : -arch ppc64 ; I'm not really fluent about mips. Boost has: "mips1" "mips2" "mips3" "mips4" "mips32" "mips32r2" "mips64" clang has: mips, // MIPS: mips, mipsallegrex mipsel, // MIPSEL: mipsel, mipsallegrexel mips64, // MIPS64: mips64 mips64el,// MIPS64EL: mips64el msp430, // MSP430: msp430 Additionnaly, clang can create Apple fat objects and libraries combining several architecture by passing multiple -arch option. By building with "-arm x86_64 -arch arm -arch arm64" you get libraries working on 32 or 64 bits phones as well as the emulator, for instance. However, I suppose it wouldn't be practical to do this with boost.build since different set of files/option should be picked in the same build? One can build three times and merge libraries afterwards anyway. Cheers, -- Quentin "mefyl" Hocquet CTO @ infinit.io
On Tuesday 13 January 2015 16:20:45 Akim Demaille wrote:
flags clang-darwin OPTIONS <architecture>arm <address-model>32 : -arch armv7 ; flags clang-darwingOPTIONS <architecture>arm <address-model>64 : -arch arm64 ; I suppose we can take the liberty to read "darwin" here ;)
Permission to read "darwin" granted. -- Quentin "mefyl" Hocquet CTO @ infinit.io
Hi mefyl, Am Dienstag, 13. Januar 2015, 16:16:29 schrieb mefyl:
On Tuesday 13 January 2015 17:06:55 Vladimir Prus wrote:
On 01/13/2015 04:45 PM, mefyl wrote:
On Tuesday 13 January 2015 13:49:29 Akim Demaille wrote: Cool. Could you suggest entire set of -arch options that should be added to clang-darwin.jam?
Sure, here are the ones I actively use:
flags clang-darwin OPTIONS <architecture>arm <address-model>32 : -arch armv7 ; flags clang-darwingOPTIONS <architecture>arm <address-model>64 : -arch arm64 ;
flags clang-darwin OPTIONS <architecture>x86 <address-model>32 : -arch x86 ; flags clang-darwin OPTIONS <architecture>x86 <address-model>64 : -arch x86_64 ;
Could you please create a Pull Request with those? And check if they can be added for both gcc and clang at the end of gcc.jam
From the clang documentation, I would infer these, altough I can't test them:
flags clang-darwin OPTIONS <architecture>sparc : -arch sparc ; // sparcv9 also exists
flags clang-darwin OPTIONS <architecture>power <address-model>32 : -arch ppc ; flags clang-darwin OPTIONS <architecture>power <address-model>64 : -arch ppc64 ;
Untested is not good :-)
I'm not really fluent about mips.
Boost has: "mips1" "mips2" "mips3" "mips4" "mips32" "mips32r2" "mips64" clang has: mips, // MIPS: mips, mipsallegrex mipsel, // MIPSEL: mipsel, mipsallegrexel mips64, // MIPS64: mips64 mips64el,// MIPS64EL: mips64el msp430, // MSP430: msp430
Additionnaly, clang can create Apple fat objects and libraries combining several architecture by passing multiple -arch option. By building with "-arm x86_64 -arch arm -arch arm64" you get libraries working on 32 or 64 bits phones as well as the emulator, for instance. However, I suppose it wouldn't be practical to do this with boost.build since different set of files/option should be picked in the same build? One can build three times and merge libraries afterwards anyway.
Yes, single invokation is usually better. Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! juergen.hunold@gmx.de * voice: 0049 4257 300 ! Fährstraße 1 * fax : 0049 4257 300 ! 31609 Balge/Sebbenhausen * mobil: 0049 178 186 1566 ! Germany
participants (4)
-
Akim Demaille
-
Jürgen Hunold
-
mefyl
-
Vladimir Prus