diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 8b3f64c240..7198737fba 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -16,7 +16,8 @@ target_link_libraries(benchmark PRIVATE ${tfpsacrypto_target} ${CMAKE_THREAD_LIB # which_aes tfpsacrypto_build_program_common(which_aes) -target_link_libraries(which_aes PRIVATE ${tfpsacrypto_target}) +target_sources(which_aes PRIVATE $) +target_link_libraries(which_aes PRIVATE ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT}) # dlopen if(USE_SHARED_TF_PSA_CRYPTO_LIBRARY AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") diff --git a/tests/scripts/components-build-system.sh b/tests/scripts/components-build-system.sh index daccfc637b..7c483bdbf7 100644 --- a/tests/scripts/components-build-system.sh +++ b/tests/scripts/components-build-system.sh @@ -22,6 +22,40 @@ component_test_tf_psa_crypto_shared () { $FRAMEWORK/tests/programs/dlopen_demo.sh } +support_build_tf_psa_crypto_shared_newer_ld_gcc () { + ld_version="" + ld_version_major="" + ld_version_minor="" + distrib_id="" + + # Attempt to parse ld -v to find out ld’s version. If not found this should fail safe. + if command ld -v >/dev/null 2>&1; then + ld_version=$(ld -v | awk '{print $NF}') + # split into major and minor + ld_version_major=${ld_version%%.*} + tmp=${ld_version#*.} + ld_version_minor=${tmp%%.*} + fi + + if [[ -f /etc/lsb-release ]]; then + while read -r lsb_line; do + case "$lsb_line" in + "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};; + esac + done < /etc/lsb-release + fi + + # Newer lds with gcc cause extra errors that wouldn't be caught with older versions + [ "$distrib_id" != "Ubuntu" ] || [ "$ld_version_minor" -gt 37 ] +} + +component_build_tf_psa_crypto_shared_newer_ld_gcc () { + msg "build/test: shared libraries" + # Test building with this option with newer lds and gcc for a more thorough check + CC=gcc cmake -DUSE_SHARED_TF_PSA_CRYPTO_LIBRARY=ON "$TF_PSA_CRYPTO_ROOT_DIR" + make +} + component_test_tf_psa_crypto_out_of_source () { msg "build: cmake tf-psa-crypto 'out-of-source' build" cd $OUT_OF_SOURCE_DIR