Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfm: cmake: Toolchain not being passed into psa-arch-tests #34962

Closed
microbuilder opened this issue May 7, 2021 · 9 comments · Fixed by #35510
Closed

tfm: cmake: Toolchain not being passed into psa-arch-tests #34962

microbuilder opened this issue May 7, 2021 · 9 comments · Fixed by #35510
Assignees
Labels
area: TF-M ARM Trusted Firmware-M (TF-M) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Milestone

Comments

@microbuilder
Copy link
Member

microbuilder commented May 7, 2021

Describe the bug

When running unit tests for psa_arch_tests with TF-M, cmake falls back to the default C compiler, rather than forwarding the correct ARM cross-compiler, resulting in build failure.

The use of the host compiler is caused by this: https:/zephyrproject-rtos/trusted-firmware-m/blob/master/psa-arch-tests/api-tests/CMakeLists.txt#L415-L436

Where the compiler is not passed on, but a C compiler is being looked up here:
https:/zephyrproject-rtos/trusted-firmware-m/blob/51cdecd6f9e6b0aa66da45db22f4b478183d472f/psa-arch-tests/api-tests/tools/scripts/target_cfg/CMakeLists.txt#L29

project(TargetConfigGen LANGUAGES C)

To Reproduce

$ ./scripts/twister -p mps2_an521_nonsecure -N --inline-logs \
  -s samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test

This will result in trying to run the system C compiler (/Library/Developer/CommandLineTools/usr/bin/cc here, on OS X):

[2/5] Building C object CMakeFiles/TargetConfigGen.dir/Users/kevin/Linaro/zephyr/zephyr/twister-out/mps2_an521_nonsecure/samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test/tfm/app/psa_api_tests/targetConfigGen.c.o
FAILED: CMakeFiles/TargetConfigGen.dir/Users/kevin/Linaro/zephyr/zephyr/twister-out/mps2_an521_nonsecure/samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test/tfm/app/psa_api_tests/targetConfigGen.c.o 
/Library/Developer/CommandLineTools/usr/bin/cc  -I/Users/kevin/Linaro/zephyr/modules/tee/tfm/psa-arch-tests/api-tests/val/nspe -I/Users/kevin/Linaro/zephyr/modules/tee/tfm/psa-arch-tests/api-tests/val/common -I/Users/kevin/Linaro/zephyr/modules/tee/tfm/psa-arch-tests/api-tests/platform/targets/common/nspe -I/Users/kevin/Linaro/zephyr/modules/tee/tfm/psa-arch-tests/api-tests/platform/targets/common/nspe/crypto -I/Users/kevin/Linaro/zephyr/modules/tee/tfm/psa-arch-tests/api-tests/platform/targets/tgt_dev_apis_tfm_an521/nspe -arch arm64 -o CMakeFiles/TargetConfigGen.dir/Users/kevin/Linaro/zephyr/zephyr/twister-out/mps2_an521_nonsecure/samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test/tfm/app/psa_api_tests/targetConfigGen.c.o -c /Users/kevin/Linaro/zephyr/zephyr/twister-out/mps2_an521_nonsecure/samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test/tfm/app/psa_api_tests/targetConfigGen.c
/Users/kevin/Linaro/zephyr/zephyr/twister-out/mps2_an521_nonsecure/samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test/tfm/app/psa_api_tests/targetConfigGen.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~

Expected behavior

The toolchain should be passed on in the cmake function when running the PSA tests.

Additional context

This fix should happen upstream in TF-M, but the issue is being filed here for tracking purposes until it is resolved either upstream and/or downstram in Zephyr's TF-M module.

@microbuilder microbuilder added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug area: TF-M ARM Trusted Firmware-M (TF-M) labels May 7, 2021
@microbuilder microbuilder added this to the v2.7.0 milestone May 7, 2021
@tejlmand
Copy link
Collaborator

tejlmand commented May 7, 2021

is there a corresponding issue upstream at TF-M ?

@oyvindronningstad
Copy link
Collaborator

This is psa-arch-tests. An issue can be opened here: https:/ARM-software/psa-arch-tests/issues

@microbuilder
Copy link
Member Author

@carlescufi
Copy link
Member

@tejlmand is not the right assignee here, added relevant ones.

@carlescufi
Copy link
Member

@galak this is an upstream TF-M issue, so you could exclude it from the release bug tally.

@ioannisg
Copy link
Member

Well, it is an issue, since we integrate the PSA arch tests in Zephyr. So I am also fine with the LOW bug here :)
@microbuilder do you think you could send a patch to fix this? Downstream is fine (then if it is fixed upstream we can do an upmerge and remove the downstream fix)

@microbuilder
Copy link
Member Author

@ioannisg will do 👍

@microbuilder
Copy link
Member Author

microbuilder commented May 20, 2021

@ioannisg @oyvindronningstad ARM-software/psa-arch-tests#268 allows the API tests to be run with:

$ ./scripts/twister -p mps2_an521_nonsecure -N --inline-logs \
  -s samples/tfm_integration/tfm_psa_test/sample.tfm.psa_internal_trusted_storage_test

If CROSS_COMPILE is not defined, it should continue to fall back to the default C compiler as before.

Tested on Darwin with arm-none-eabi-gcc.

@microbuilder
Copy link
Member Author

Fixed by #35510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: TF-M ARM Trusted Firmware-M (TF-M) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants