0

With cobalt release 11, the AlignAsStackVariable test with NPLB would fail, but when we copy the test code from nplb test file(starboard/nplb/align_test.cc) , cross compile it and run it on the same arm platform, then it's aligned as expected, so it seemd to be the issue with NPLB(no the issue of the toolchain or platform), could someone help a look?

//NPLB Failed case:

[ RUN      ] SbAlignTest.AlignAsStackVariable
../../starboard/nplb/align_test.cc:117: Failure
Expected: (32) <= (GetAlignment(&by_32)), actual: 32 vs 16
../../starboard/nplb/align_test.cc:118: Failure
Expected: (64) <= (GetAlignment(&by_64)), actual: 64 vs 16
../../starboard/nplb/align_test.cc:119: Failure
Expected: (128) <= (GetAlignment(&by_128)), actual: 128 vs 16
../../starboard/nplb/align_test.cc:120: Failure
Expected: (256) <= (GetAlignment(&by_256)), actual: 256 vs 16
[  FAILED  ] SbAlignTest.AlignAsStackVariable (1 ms)

//Test Code align OK:

GetAlignment sizeof(size_t)=4
GetAlignment align=2
GetAlignment align=4
GetAlignment align=8
GetAlignment align=16
GetAlignment align=32
GetAlignment align=64
GetAlignment align=128
GetAlignment align=256

enter image description here

enter image description here

bitchainer
  • 535
  • 2
  • 19

1 Answers1

0

I'm not sure what you mean by "but when we copy the test code from nplb test file(starboard/nplb/align_test.cc) , cross compile it and run it on the same arm platform"... Are you compiling with the same compiler flags? Could it be that it is just a coincidence that it exceeds in the environment to which you copied the code to? The code for align_test.cc is fairly straightforward and is essentially just ensuring that your implementation of SB_ALIGNAS() is working correctly.

Furthermore, as you can see in the test it is understood by nplb that not all platforms/toolchains are capable of stack variable alignment greater than 16 bytes, so in that case you should define SB_HAS_QUIRK_DOES_NOT_STACK_ALIGN_OVER_16_BYTES in your platform's configuration_public.h file to inform the test and Cobalt that your platform/toolchain cannot perform stack alignment greater than 16 bytes.

Andrew Top
  • 2,517
  • 1
  • 17
  • 10
  • Hi, andrew, I copy the test code from the align_test.cc, and use the same compiler flags from the out/linux-armdirectfb-qa/obj/starboard/nplb/nplb.ninja, and you can see it can align with what is set from 2-256 bits, so it was not the issue of the platform, I guess it maybe related with the NPLB build configuration or compiler flags, so could you help to give some tips which we can check with? – bitchainer Oct 26 '17 at 07:34
  • Hi bitchainer... Yes, it may be a compiler flags issue. Are you able to check the compiler flags from the environment in which you are able to successfully run these tests into your gyp_configuration.gypi so that they will also be applied when building nplb (and cobalt)? I'm not sure how much I can help with this, besides pointing out that you are free to customize your gyp_configuration.gypi files to include whatever compiler flags are necessary for your toolchain to make the nplb tests pass. And once again if you have no luck, there isSB_HAS_QUIRK_DOES_NOT_STACK_ALIGN_OVER_16_BYTES. – Andrew Top Oct 26 '17 at 17:59