When cross-targeting for arm eng/common/cross/toolchain.cmake adds the -mthumb flag. If the -mthumb flag is added but the -fPIC -march=armv7-a flags are not added then it compiles for armv6 or v5 and uses thumb instead of thumb2, which is quite different. One of the differences with thumb is that its 16 bits, which causes interop with floating point numbers to not work correctly. Since -mthumb is added automatically, but -fPIC and -march=armv7-a are not, this makes the default compilation work incorrectly.
I synced with @janvorli and he suggested that:
The toolchain file is used only in the crosscompilation case, so it actually seemed to me that it should not contain any compiler options and they should all come from the eng/native/configurecompiler.cmake in the runtime build case or from some other file specific to your component build.
We could remove the all compilation flags as suggested by Jan, just remove the -mthumb flag from the cross/toolchain.cmake` file, or add in the missing flags, but whatever approach we take we should make sure that the default case works correctly.
When cross-targeting for arm
eng/common/cross/toolchain.cmakeadds the-mthumbflag. If the-mthumbflag is added but the-fPIC -march=armv7-aflags are not added then it compiles for armv6 or v5 and uses thumb instead of thumb2, which is quite different. One of the differences with thumb is that its 16 bits, which causes interop with floating point numbers to not work correctly. Since-mthumbis added automatically, but-fPICand-march=armv7-aare not, this makes the default compilation work incorrectly.I synced with @janvorli and he suggested that:
We could remove the all compilation flags as suggested by Jan, just remove the
-mthumbflag from the cross/toolchain.cmake` file, or add in the missing flags, but whatever approach we take we should make sure that the default case works correctly.