Skip to content

Commit f6e2a98

Browse files
authored
Merge pull request #2404 from elBoberido/iox-2301-windows-32-bit-fixes
iox-#2301 Windows 32 bit fixes
2 parents e088257 + 8973e18 commit f6e2a98

File tree

8 files changed

+71
-10
lines changed

8 files changed

+71
-10
lines changed

.github/workflows/build-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ jobs:
191191
uses: ./.github/actions/install-iceoryx-deps-and-clang
192192
- run: ./tools/ci/build-test-ubuntu.sh 32-bit-x86
193193

194+
build-test-windows-32-bit:
195+
# prevent stuck jobs consuming runners for 6 hours
196+
timeout-minutes: 60
197+
runs-on: windows-latest
198+
needs: pre-flight-check
199+
steps:
200+
- uses: actions/checkout@v4
201+
- run: ./tools/ci/build-test-windows.ps1 -toolchain MSVC -architecture 32-bit
202+
shell: powershell
203+
194204
build-test-ubuntu-32-64-bit-mix-mode:
195205
# prevent stuck jobs consuming runners for 6 hours
196206
timeout-minutes: 60

cmake/googletest/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ if(BUILD_TEST AND NOT GTest_DIR)
4242
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS})
4343
endif()
4444

45+
if(DEFINED CMAKE_CXX_FLAGS_INIT)
46+
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT})
47+
endif()
48+
49+
if(DEFINED CMAKE_CXX_COMPILER)
50+
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER})
51+
endif()
52+
53+
if(DEFINED CMAKE_CXX_COMPILER_TARGET)
54+
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET})
55+
endif()
56+
57+
if(DEFINED CMAKE_GENERATOR_PLATFORM)
58+
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM})
59+
endif()
60+
61+
if(DEFINED CMAKE_LINKER)
62+
list(APPEND EXTRA_CMAKE_ARGS -DCMAKE_LINKER=${CMAKE_LINKER})
63+
endif()
64+
4565
set(GTEST_BUILD_ARGS "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${EXTRA_CMAKE_ARGS}")
4666
set(GTEST_DOWNLOAD_ARGS "${DOWNLOAD_CONFIG_DIR}")
4767

doc/website/advanced/iceoray-on-32-bit.md renamed to doc/website/advanced/iceoryx-on-32-bit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ The `-m32` flag tells GCC to build iceoryx as 32-bit library on a 64-bit system.
3434
The `-malign-double` flag is required to have 64-bit atomics on an 8 byte boundary.
3535
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.
3636

37+
> [!NOTE]
38+
> On Windows with MSVC, the `-DCMAKE_GENERATOR_PLATFORM=Win32` cmake flag must be set instead of the `-DCMAKE_C_FLAGS` and `-DCMAKE_CXX_FLAGS`.
39+
3740
## Limitations
3841

3942
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
8184
cmake --build build-64
8285
```
8386

87+
> [!NOTE]
88+
> 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.
89+
8490
## Running the examples
8591

8692
You can now mix and match 32-bit and 64-bit applications

iceoryx_examples/waitset_in_c/ice_c_waitset_timer_driven_execution.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ void cyclicRun(iox_user_trigger_t trigger)
6060
fflush(stdout);
6161
}
6262

63+
#if defined(_WIN32)
64+
DWORD WINAPI cyclicTriggerCallback(LPVOID dontCare)
65+
#else
6366
void* cyclicTriggerCallback(void* dontCare)
67+
#endif
6468
{
6569
// Ignore unused variable warning
6670
(void)dontCare;
@@ -78,13 +82,13 @@ void* cyclicTriggerCallback(void* dontCare)
7882
return NULL;
7983
}
8084

81-
bool createThread(pthread_t* threadHandle, void* (*callback)(void*))
85+
bool createThread(pthread_t* threadHandle)
8286
{
8387
#if defined(_WIN32)
84-
threadHandle = CreateThread(NULL, 8192, callback, NULL, 0, NULL);
88+
threadHandle = CreateThread(NULL, 8192, cyclicTriggerCallback, NULL, 0, NULL);
8589
return threadHandle != NULL;
8690
#else
87-
return pthread_create(threadHandle, NULL, callback, NULL) == 0;
91+
return pthread_create(threadHandle, NULL, cyclicTriggerCallback, NULL) == 0;
8892
#endif
8993
}
9094

@@ -121,7 +125,7 @@ int main(void)
121125
// start a thread which triggers cyclicTrigger every second
122126
//! [cyclic trigger thread]
123127
pthread_t cyclicTriggerThread;
124-
if (!createThread(&cyclicTriggerThread, cyclicTriggerCallback))
128+
if (!createThread(&cyclicTriggerThread))
125129
{
126130
printf("failed to create thread\n");
127131
return -1;

iceoryx_meta/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ message(" c compiler................: " ${CMAKE_C_COMPILER})
9292
message(" c++ compiler..............: " ${CMAKE_CXX_COMPILER})
9393
message(" c flags...................: " ${CMAKE_C_FLAGS})
9494
message(" c++ flags.................: " ${CMAKE_CXX_FLAGS})
95+
message(" generator platform........: " ${CMAKE_GENERATOR_PLATFORM})
9596
message(" cmake.....................: " ${CMAKE_VERSION})
9697
message(" Additional flags from iceoryx platform")
9798
message(" c++ standard..............: " ${ICEORYX_CXX_STANDARD})

iceoryx_platform/win/source/pthread.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
#include <sstream>
2525
#include <vector>
2626

27-
HRESULT GetThreadDescription(HANDLE hThread, PWSTR* ppszThreadDescription);
28-
HRESULT SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription);
29-
3027
int iox_pthread_setname_np(iox_pthread_t thread [[maybe_unused]], const char* name [[maybe_unused]])
3128
{
3229
#if defined(__GNUC__) || defined(__GNUG__)

iceoryx_posh/cmake/cpptoml/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set(CMAKE_ADDITIONAL_OPTIONS
6666
"-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}"
6767
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
6868
"-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}"
69+
"-DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}"
6970
"-DCMAKE_LINKER=${CMAKE_LINKER}")
7071

7172
if(DEFINED CMAKE_TOOLCHAIN_FILE)

tools/ci/build-test-windows.ps1

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,44 @@
1818

1919
param(
2020
[Parameter()]
21-
[String]$toolchain = "MSVC"
21+
[String]$toolchain = "MSVC",
22+
23+
[Parameter()]
24+
[String]$architecture = "64-bit"
2225
)
2326

2427
$ErrorActionPreference = "Stop"
2528
$NumCPUs = (Get-WmiObject Win32_processor).NumberOfLogicalProcessors
2629

30+
$ARCHITECTURE_FLAG_MSVC = ""
31+
$C_FLGAS_MINGW = ""
32+
$CXX_FLAGS_MINGW = ""
33+
34+
switch ($architecture) {
35+
"64-bit" {
36+
# nothing to do
37+
}
38+
"32-bit" {
39+
$ARCHITECTURE_FLAG_MSVC = "-DCMAKE_GENERATOR_PLATFORM=Win32"
40+
$C_FLAGS_MINGW = '-DCMAKE_C_FLAGS="-m32"'
41+
$CXX_FLAGS_MINGW = '-DCMAKE_CXX_FLAGS="-m32"'
42+
}
43+
default {
44+
if ($?) { Write-Host "## The '$architecture' architecture is not supported. Currently only '64-bit' and '32-bit' is supported to build iceoryx." }
45+
exit 1
46+
}
47+
}
48+
2749
switch ($toolchain) {
2850
"MSVC" {
2951
if ($?) { Write-Host "## Building sources with MSVC toolchain" }
3052
# 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
3153
# fixed with this version, see: https://github.com/microsoft/vcpkg/issues/15035#issuecomment-742427969.
32-
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" }
54+
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 }
3355
}
3456
"MinGW" {
3557
if ($?) { Write-Host "## Building sources with MinGW toolchain" }
36-
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" }
58+
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 }
3759
}
3860
default {
3961
if ($?) { Write-Host "## The '$toolchain' toolchain is not supported. Currently only 'MSVC' and 'MingGW' is supported to build iceoryx." }

0 commit comments

Comments
 (0)