From 362c6d7bddd2af2f2579fa60555a71e35dbc63d7 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 15:25:36 +0100 Subject: [PATCH 1/7] iox-#2301 Forward the generator platform to cpptoml --- iceoryx_meta/CMakeLists.txt | 1 + iceoryx_posh/cmake/cpptoml/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/iceoryx_meta/CMakeLists.txt b/iceoryx_meta/CMakeLists.txt index 68cd4181ba..836efb443b 100644 --- a/iceoryx_meta/CMakeLists.txt +++ b/iceoryx_meta/CMakeLists.txt @@ -92,6 +92,7 @@ message(" c compiler................: " ${CMAKE_C_COMPILER}) message(" c++ compiler..............: " ${CMAKE_CXX_COMPILER}) message(" c flags...................: " ${CMAKE_C_FLAGS}) message(" c++ flags.................: " ${CMAKE_CXX_FLAGS}) +message(" generator platform........: " ${CMAKE_GENERATOR_PLATFORM}) message(" cmake.....................: " ${CMAKE_VERSION}) message(" Additional flags from iceoryx platform") message(" c++ standard..............: " ${ICEORYX_CXX_STANDARD}) diff --git a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt index e770e4fdba..c6429ce114 100644 --- a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt +++ b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt @@ -66,6 +66,7 @@ set(CMAKE_ADDITIONAL_OPTIONS "-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}" "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}" + "-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}" "-DCMAKE_LINKER=${CMAKE_LINKER}") if(DEFINED CMAKE_TOOLCHAIN_FILE) From 012a505aba6a111b45784185b00354baf3d508df Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 16:28:35 +0100 Subject: [PATCH 2/7] iox-#2301 Forward cmake flags to gTest --- cmake/googletest/CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cmake/googletest/CMakeLists.txt b/cmake/googletest/CMakeLists.txt index 0786e3af50..11805528f8 100644 --- a/cmake/googletest/CMakeLists.txt +++ b/cmake/googletest/CMakeLists.txt @@ -42,6 +42,26 @@ if(BUILD_TEST AND NOT GTest_DIR) list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}) endif() + if(DEFINED CMAKE_CXX_FLAGS_INIT) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT}) + endif() + + if(DEFINED CMAKE_CXX_COMPILER) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}) + endif() + + if(DEFINED CMAKE_CXX_COMPILER_TARGET) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}) + endif() + + if(DEFINED CMAKE_GENERATOR_PLATFORM) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}) + endif() + + if(DEFINED CMAKE_LINKER) + list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_LINKER=${CMAKE_LINKER}) + endif() + set(GTEST_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${EXTRA_CMAKE_ARGS}") set(GTEST_DOWNLOAD_ARGS "${DOWNLOAD_CONFIG_DIR}") From 5e91f9dc97eebdcce4692fd10b83917c09f3d42f Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 15:26:49 +0100 Subject: [PATCH 3/7] iox-#2301 Update build scripts --- tools/ci/build-test-windows.ps1 | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/ci/build-test-windows.ps1 b/tools/ci/build-test-windows.ps1 index cbf1861f05..6442a3a97c 100755 --- a/tools/ci/build-test-windows.ps1 +++ b/tools/ci/build-test-windows.ps1 @@ -18,22 +18,44 @@ param( [Parameter()] - [String]$toolchain = "MSVC" + [String]$toolchain = "MSVC", + + [Parameter()] + [String]$architecture = "64-bit" ) $ErrorActionPreference = "Stop" $NumCPUs = (Get-WmiObject Win32_processor).NumberOfLogicalProcessors +$ARCHITECTURE_FLAG_MSVC = "" +$C_FLGAS_MINGW = "" +$CXX_FLAGS_MINGW = "" + +switch ($architecture) { + "64-bit" { + # nothing to do + } + "32-bit" { + $ARCHITECTURE_FLAG_MSVC = "-DCMAKE_GENERATOR_PLATFORM=Win32" + $C_FLAGS_MINGW = '-DCMAKE_C_FLAGS="-m32"' + $CXX_FLAGS_MINGW = '-DCMAKE_CXX_FLAGS="-m32"' + } + default { + if ($?) { Write-Host "## The '$architecture' architecture is not supported. Currently only '64-bit' and '32-bit' is supported to build iceoryx." } + exit 1 + } +} + switch ($toolchain) { "MSVC" { if ($?) { Write-Host "## Building sources with MSVC toolchain" } # We require the Windows SDK Version 10.0.18362.0 since a previous version had a bug which caused a fatal compilation error within iceoryx and was # fixed with this version, see: https://github.com/microsoft/vcpkg/issues/15035#issuecomment-742427969. - if ($?) { cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON -DINTROSPECTION=OFF -DBINDING_C=ON -DEXAMPLES=ON -DCMAKE_CXX_FLAGS="/MP" -DCMAKE_SYSTEM_VERSION="10.0.18362.0" } + if ($?) { cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON -DINTROSPECTION=OFF -DBINDING_C=ON -DEXAMPLES=ON -DCMAKE_CXX_FLAGS="/MP" -DCMAKE_SYSTEM_VERSION="10.0.18362.0" $ARCHITECTURE_FLAG_MSVC } } "MinGW" { if ($?) { Write-Host "## Building sources with MinGW toolchain" } - if ($?) { cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON -DINTROSPECTION=OFF -DBINDING_C=ON -DEXAMPLES=ON -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "MinGW Makefiles" } + if ($?) { cmake -Bbuild -Hiceoryx_meta -DBUILD_TEST=ON -DINTROSPECTION=OFF -DBINDING_C=ON -DEXAMPLES=ON -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "MinGW Makefiles" $C_FLAGS_MINGW $CXX_FLAGS_MINGW } } default { if ($?) { Write-Host "## The '$toolchain' toolchain is not supported. Currently only 'MSVC' and 'MingGW' is supported to build iceoryx." } From 79ea76f9302e530b69b7cb0fe5fe5bfdf3e9f94d Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 18:07:26 +0100 Subject: [PATCH 4/7] iox-#2301 Remove superfluous type definition --- iceoryx_platform/win/source/pthread.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/iceoryx_platform/win/source/pthread.cpp b/iceoryx_platform/win/source/pthread.cpp index c324f9d379..09a8f332ff 100644 --- a/iceoryx_platform/win/source/pthread.cpp +++ b/iceoryx_platform/win/source/pthread.cpp @@ -24,9 +24,6 @@ #include #include -HRESULT GetThreadDescription(HANDLE hThread, PWSTR* ppszThreadDescription); -HRESULT SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription); - int iox_pthread_setname_np(iox_pthread_t thread [[maybe_unused]], const char* name [[maybe_unused]]) { #if defined(__GNUC__) || defined(__GNUG__) From ba2bea18984451755cacbb58cafb21f2cd8c2fe6 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 15:27:05 +0100 Subject: [PATCH 5/7] iox-#2301 Update documentation --- .../advanced/{iceoray-on-32-bit.md => iceoryx-on-32-bit.md} | 6 ++++++ 1 file changed, 6 insertions(+) rename doc/website/advanced/{iceoray-on-32-bit.md => iceoryx-on-32-bit.md} (93%) diff --git a/doc/website/advanced/iceoray-on-32-bit.md b/doc/website/advanced/iceoryx-on-32-bit.md similarity index 93% rename from doc/website/advanced/iceoray-on-32-bit.md rename to doc/website/advanced/iceoryx-on-32-bit.md index e86f89a8ff..ce6f64d1a5 100644 --- a/doc/website/advanced/iceoray-on-32-bit.md +++ b/doc/website/advanced/iceoryx-on-32-bit.md @@ -34,6 +34,9 @@ The `-m32` flag tells GCC to build iceoryx as 32-bit library on a 64-bit system. The `-malign-double` flag is required to have 64-bit atomics on an 8 byte boundary. Furthermore, it is required for the 32-64 bit mix-mode to enforce the same data layout when 32-bit application communicate with 64-bit applications. +> [!NOTE] +> On Windows with MSVC, the `-DCMAKE_GENERATOR_PLATFORM=Win32` cmake flag must be set instead of the `-DCMAKE_C_FLAGS` and `-DCMAKE_CXX_FLAGS`. + ## Limitations An internal data structure, the `UsedChunkList`, might be left in a corrupt state when an application terminates abnormally when writing to this data structure. @@ -81,6 +84,9 @@ cmake -S iceoryx_meta -B build-64 -DCMAKE_BUILD_TYPE=Release -DEXAMPLES=ON -DIOX cmake --build build-64 ``` +> [!NOTE] +> On Windows with MSVC, there is now counterpart for `-malign-double` and therefore the 32-64 bit mix-mode does not yet work on Windows. + ## Running the examples You can now mix and match 32-bit and 64-bit applications From 96a50e49a82e7fb983648b92831699a0848a17ef Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 15:27:58 +0100 Subject: [PATCH 6/7] iox-#2301 Add Windows 32-bit build to CI --- .github/workflows/build-test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d28f85a854..42d8925504 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -191,6 +191,16 @@ jobs: uses: ./.github/actions/install-iceoryx-deps-and-clang - run: ./tools/ci/build-test-ubuntu.sh 32-bit-x86 + build-test-windows-32-bit: + # prevent stuck jobs consuming runners for 6 hours + timeout-minutes: 60 + runs-on: windows-latest + needs: pre-flight-check + steps: + - uses: actions/checkout@v4 + - run: ./tools/ci/build-test-windows.ps1 -toolchain MSVC -architecture 32-bit + shell: powershell + build-test-ubuntu-32-64-bit-mix-mode: # prevent stuck jobs consuming runners for 6 hours timeout-minutes: 60 From 8973e1851dee41c0a43ad1ea00b0eafd2fe966c8 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Tue, 7 Jan 2025 19:34:35 +0100 Subject: [PATCH 7/7] iox-#2301 Fix Windows 32-bit C example --- .../ice_c_waitset_timer_driven_execution.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/iceoryx_examples/waitset_in_c/ice_c_waitset_timer_driven_execution.c b/iceoryx_examples/waitset_in_c/ice_c_waitset_timer_driven_execution.c index e127990242..be87f071ff 100644 --- a/iceoryx_examples/waitset_in_c/ice_c_waitset_timer_driven_execution.c +++ b/iceoryx_examples/waitset_in_c/ice_c_waitset_timer_driven_execution.c @@ -60,7 +60,11 @@ void cyclicRun(iox_user_trigger_t trigger) fflush(stdout); } +#if defined(_WIN32) +DWORD WINAPI cyclicTriggerCallback(LPVOID dontCare) +#else void* cyclicTriggerCallback(void* dontCare) +#endif { // Ignore unused variable warning (void)dontCare; @@ -78,13 +82,13 @@ void* cyclicTriggerCallback(void* dontCare) return NULL; } -bool createThread(pthread_t* threadHandle, void* (*callback)(void*)) +bool createThread(pthread_t* threadHandle) { #if defined(_WIN32) - threadHandle = CreateThread(NULL, 8192, callback, NULL, 0, NULL); + threadHandle = CreateThread(NULL, 8192, cyclicTriggerCallback, NULL, 0, NULL); return threadHandle != NULL; #else - return pthread_create(threadHandle, NULL, callback, NULL) == 0; + return pthread_create(threadHandle, NULL, cyclicTriggerCallback, NULL) == 0; #endif } @@ -121,7 +125,7 @@ int main(void) // start a thread which triggers cyclicTrigger every second //! [cyclic trigger thread] pthread_t cyclicTriggerThread; - if (!createThread(&cyclicTriggerThread, cyclicTriggerCallback)) + if (!createThread(&cyclicTriggerThread)) { printf("failed to create thread\n"); return -1;