From ed4a10661c6eff4acfa66419e26abb2c86dada8b Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 14 May 2025 10:22:31 +0200 Subject: [PATCH 1/3] cmake: library: Remove unnecessary link_to_source If we do not generate error.c, version_features.c, ... then they are supposed to be in the source tree. The CMake build get them from here and there is no need for a symbolic link or a copy in the build tree. Signed-off-by: Ronald Cron --- library/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 451dbfdb7c..b6693d1a19 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -84,10 +84,6 @@ if(GEN_FILES) ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/generate_ssl_debug_helpers.py ${tls_error_headers} ) -else() - link_to_source(error.c) - link_to_source(version_features.c) - link_to_source(ssl_debug_helpers_generated.c) endif() if(CMAKE_COMPILER_IS_GNUCC) From a2c37b3b2d7c2c9a255637c7f5b6c03830f11c52 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 14 May 2025 09:41:04 +0200 Subject: [PATCH 2/3] cmake: library: Add custom targets for generated files Add a custom target that depends on TLS generated files, and make both the static and shared crypto libraries depend on it. This ensures that when both libraries are built, the files are not generated concurrently by the static and shared library targets. Do the same for the x509 libraries. Signed-off-by: Ronald Cron --- library/CMakeLists.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index b6693d1a19..ee0381c036 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -84,6 +84,17 @@ if(GEN_FILES) ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/generate_ssl_debug_helpers.py ${tls_error_headers} ) + + add_custom_target(${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/error.c + ) + + add_custom_target(${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/ssl_debug_helpers_generated.c + ${CMAKE_CURRENT_BINARY_DIR}/version_features.c + ) endif() if(CMAKE_COMPILER_IS_GNUCC) @@ -161,6 +172,13 @@ if(USE_STATIC_MBEDTLS_LIBRARY) target_compile_options(${mbedtls_static_target} PRIVATE ${LIBS_C_FLAGS}) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) + + if(GEN_FILES) + add_dependencies(${mbedx509_static_target} + ${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target) + add_dependencies(${mbedtls_static_target} + ${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target) + endif() endif(USE_STATIC_MBEDTLS_LIBRARY) if(USE_SHARED_MBEDTLS_LIBRARY) @@ -175,6 +193,13 @@ if(USE_SHARED_MBEDTLS_LIBRARY) target_compile_options(${mbedtls_target} PRIVATE ${LIBS_C_FLAGS}) set_target_properties(${mbedtls_target} PROPERTIES VERSION 4.0.0 SOVERSION 21) target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) + + if(GEN_FILES) + add_dependencies(${mbedx509_target} + ${MBEDTLS_TARGET_PREFIX}mbedx509_generated_files_target) + add_dependencies(${mbedtls_target} + ${MBEDTLS_TARGET_PREFIX}mbedtls_generated_files_target) + endif() endif(USE_SHARED_MBEDTLS_LIBRARY) foreach(target IN LISTS target_libraries) From 37ddcf0ab4d8683eb50fa7f55691068c352bc704 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 14 May 2025 13:15:36 +0200 Subject: [PATCH 3/3] Add change log Signed-off-by: Ronald Cron --- ChangeLog.d/fix-dependency-on-generated-files.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/fix-dependency-on-generated-files.txt diff --git a/ChangeLog.d/fix-dependency-on-generated-files.txt b/ChangeLog.d/fix-dependency-on-generated-files.txt new file mode 100644 index 0000000000..b3e7e4e16b --- /dev/null +++ b/ChangeLog.d/fix-dependency-on-generated-files.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix potential CMake parallel build failure when building both the static + and shared libraries.