Floating point ABI woes while building perfetto for Cortexa15t2hf

I ran into this issue while debugging the recipe for Perfetto, I’m running into a problem where part of Perfetto is built without VFP register arguments while part of it uses VFP register arguments no matter how I attempt to specify wither -mfloat-abi=soft or -mfloat-abi=hard in a sweeping way in the recipe.

A typical error message is:

/home/.../yoe/build/tmp/work/cortexa15t2hf-neon-yoe-linux-musleabi/perfetto/1.0-r0/recipe-sysroot-native/usr/bin/arm-yoe-linux-musleabi/arm-yoe-linux-musleabi-ld.gold: error: obj/src/traced/probes/ftrace/format_parser/format_parser.format_parser.o uses VFP register arguments, output does not 

One can find the fact that part of the set of input object files use VFP register arguments while some others don’t by saving the last compilation step (where all .o files are linked to become tracebox) into a shell script and flipping between using VFP register arguments and not using it and entering the BitBake devshell and executing that shell script.

qemuarm64 does not encounter this issue, and that apparently is due to the qemuarm64 useing cortexa57-yoe-linux as its architecture triplet because according to documentation from ARM, arm64 will always use hard FP, so there is no ambiguity, while qemuarm has a large configuration space and for the Yoe distribution, it uses cortexa15t2hf-neon-yoe-linux as its architecture triplet.

Found relevant emails in the mailing list, starting from this one. Will consult those emails while looking into the issues here

An answer must exist as Perfetto is known to work with Android phones and the first Android phone I had had a Qualcomm Krait whilch apprently is a cortexa15t2hf, if not very similar, so Perfetto must work. It’s just the way this recipe is configured.

Got this apparently self-conflicting error by re-running the last link step:

  • Without -fuse-ld=gold -mfloat-abi=soft:

    • Error arm-yoe-linux-musleabi-ld: error: ./tracebox uses VFP register arguments, obj/src/base/http/http.sha1.o does not
  • With -fuse-ld=gold -mfloat-abi=soft:

    • Error arm-yoe-linux-musleabi-ld.gold: error: obj/src/base/http/http.sha1.o uses VFP register arguments, output does not

How could an already-existing build file both be using VFP and not be using VFP with the last link step flipped? Something is not adding up here. Need to understand what the linker is actually doing.

A minimal example for reproducing the above error:

(in Bitbake devshell)

cat $libfoo.cpp
float foo(float a, float b) {
  return a*a + b*b;
}

arm-yoe-linux-musleabi-clang++  -shared libfoo.cpp -o libfoo.so -stdlib=libc++ -rtlib=libgcc --unwindlib=libgcc --sysroot=/home/(my username)/yoe/build/tmp/work/cortexa15t2hf-neon-yoe-linux-musleabi/perfetto/1.0-r0/recipe-sysroot

error: libfoo.so uses VFP register arguments, /tmp/libfoo-80143b.o does not

It’s good that with this minimal example we can debug the issue much more easily.


By turning on the -v flag, we can see that clang++ spawns 2 commands:

  1. cc1
  2. ld
    The error message basically says: the temporary file generated by 1 does not use VFP while the output file produced by 2 uses VFP.

Adding -mfloat-abi=hard to clang++ makes this error go away.

Updated the recipe accordingly.

thats perhaps the right option to pass but it should be passed conditionally based on callconvention settings

CXXFLAGS:append:arm = "${@bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', ' -mfloat-abi=hard', '', d)}

might be portable way of doing it.