From 0bd3b663d12a84f3c22230260570d5fd6f642693 Mon Sep 17 00:00:00 2001 From: jclc Date: Sun, 26 Jan 2025 00:56:34 +0200 Subject: [PATCH 01/15] disable packet tagging on mingw by default, fix TLS qualifier --- netcode.c | 4 ++++ netcode.h | 8 ++++++-- sodium/sodium_randombytes_salsa20_random.c | 4 ++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/netcode.c b/netcode.c index ad38e9b..f449147 100755 --- a/netcode.c +++ b/netcode.c @@ -82,6 +82,10 @@ void netcode_enable_packet_tagging() netcode_packet_tagging_enabled = 1; } +#else + +void netcode_enable_packet_tagging() {} + #endif // #if NETCODE_PACKET_TAGGING // ------------------------------------------------------------------ diff --git a/netcode.h b/netcode.h index 0ddaab0..546310a 100755 --- a/netcode.h +++ b/netcode.h @@ -113,12 +113,16 @@ int netcode_init(); void netcode_term(); #ifndef NETCODE_PACKET_TAGGING +#ifndef __MINGW32__ #define NETCODE_PACKET_TAGGING 1 +#else +// At least as of version 14.2.0, the Qwave library is not properly implemented +// in MingW-w64, so packet tagging is disabled by default. +#define NETCODE_PACKET_TAGGING 0 +#endif // #ifndef __MINGW32__ #endif // #ifndef NETCODE_PACKET_TAGGING -#if NETCODE_PACKET_TAGGING void netcode_enable_packet_tagging(); -#endif // #if NETCODE_PACKET_TAGGING struct netcode_address_t { diff --git a/sodium/sodium_randombytes_salsa20_random.c b/sodium/sodium_randombytes_salsa20_random.c index 2cf65f5..26619aa 100644 --- a/sodium/sodium_randombytes_salsa20_random.c +++ b/sodium/sodium_randombytes_salsa20_random.c @@ -89,6 +89,10 @@ BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); # endif #endif +#if !defined(TLS) && !defined(__STDC_NO_THREADS__) && \ + defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +# define TLS _Thread_local +#endif #ifndef TLS # ifdef _WIN32 # define TLS __declspec(thread) From 4c836219908a1f280a368812656761a432bb7197 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 20:43:07 +0200 Subject: [PATCH 02/15] add mingw CI --- .github/workflows/ci.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27c5379..d557388 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,4 +51,31 @@ jobs: - name: Test (vs2019) if: runner.os == 'Windows' run: "& ./bin/test.exe" - \ No newline at end of file + + build_and_test_mingw: + name: Build & test + + strategy: + matrix: + os: [windows-latest] + configuration: [release, debug] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@master + - name: Setup premake + uses: abel0b/setup-premake@v1 + + steps: + # Set up msys2/MingW-w64 toolchain + - name: Setup (msys2) + uses: msys2/setup-msys2@v2 + + - name: Build (msys2) + run: | + premake5 gmake + make config=${{ matrix.configuration }} + + - name: Test (msys2) + run: "& ./bin/test.exe" From cb108aecc72dbf078c7dd12aacd8c52bd18684d8 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 20:45:05 +0200 Subject: [PATCH 03/15] fix CI --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d557388..7556016 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,6 @@ jobs: - name: Setup premake uses: abel0b/setup-premake@v1 - steps: # Set up msys2/MingW-w64 toolchain - name: Setup (msys2) uses: msys2/setup-msys2@v2 From 11b28935201616425498e739517eac3615cdcb46 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 20:48:15 +0200 Subject: [PATCH 04/15] fix build step --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7556016..b23cd11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: run: "& ./bin/test.exe" build_and_test_mingw: - name: Build & test + name: Build & test (MingW) strategy: matrix: @@ -74,7 +74,8 @@ jobs: - name: Build (msys2) run: | premake5 gmake - make config=${{ matrix.configuration }} + make clean + make all config=${{ matrix.configuration }} - name: Test (msys2) run: "& ./bin/test.exe" From df84cb2d08b391f5daeef730e07bb5f40feb1693 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 21:13:26 +0200 Subject: [PATCH 05/15] try msys2 shell --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b23cd11..fbc59e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,10 +72,12 @@ jobs: uses: msys2/setup-msys2@v2 - name: Build (msys2) + shell: msys2 {0} run: | premake5 gmake make clean make all config=${{ matrix.configuration }} - name: Test (msys2) + shell: msys2 {0} run: "& ./bin/test.exe" From c777140e63526204ec7181633af9ecbf5d8ad459 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 21:20:23 +0200 Subject: [PATCH 06/15] install gcc/premake with msys2 --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbc59e7..7665fbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,12 +64,15 @@ jobs: steps: - uses: actions/checkout@master - - name: Setup premake - uses: abel0b/setup-premake@v1 # Set up msys2/MingW-w64 toolchain - name: Setup (msys2) uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + mingw-w64-premake + mingw-w64-gcc - name: Build (msys2) shell: msys2 {0} From 949192436af88bafe929e0fd65d8292ec8e1798c Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 21:47:55 +0200 Subject: [PATCH 07/15] improved stuff --- .github/workflows/ci.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7665fbc..419ddfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,10 @@ jobs: runs-on: ${{ matrix.os }} + defaults: + run: + shell: msys2 {0} + steps: - uses: actions/checkout@master @@ -69,18 +73,17 @@ jobs: - name: Setup (msys2) uses: msys2/setup-msys2@v2 with: + msystem: UCRT64 update: true install: >- - mingw-w64-premake - mingw-w64-gcc + premake + mingw-w64-ucrt-x86_64-gcc - name: Build (msys2) - shell: msys2 {0} run: | premake5 gmake make clean make all config=${{ matrix.configuration }} - name: Test (msys2) - shell: msys2 {0} - run: "& ./bin/test.exe" + run: "./bin/test.exe" From 5fc803f41d7dd51319f16b96aaa067776308f347 Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 21:58:49 +0200 Subject: [PATCH 08/15] maybe this package works --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 419ddfe..f072414 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: msystem: UCRT64 update: true install: >- - premake + mingw-w64-ucrt-x86_64-premake mingw-w64-ucrt-x86_64-gcc - name: Build (msys2) From f17b791bdd58c72fa68f5faed91e73c6a390dcbf Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 22:01:00 +0200 Subject: [PATCH 09/15] add make --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f072414..94a41e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,7 @@ jobs: msystem: UCRT64 update: true install: >- + mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-x86_64-premake mingw-w64-ucrt-x86_64-gcc From cb90f8f4270de797aceee45e65a5fbaabb57061c Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 22:14:31 +0200 Subject: [PATCH 10/15] is this the correct make?? --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94a41e5..0db328c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,8 @@ jobs: - name: Build (msys2) run: | premake5 gmake - make clean - make all config=${{ matrix.configuration }} + mingw-w64-ucrt-x86_64-make clean + mingw-w64-ucrt-x86_64-make all config=${{ matrix.configuration }} - name: Test (msys2) run: "./bin/test.exe" From ba1466f2439acd2f21286480d5423734c6d799fb Mon Sep 17 00:00:00 2001 From: jclc Date: Mon, 27 Jan 2025 22:48:29 +0200 Subject: [PATCH 11/15] try another make alias --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0db328c..db701a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,8 @@ jobs: - name: Build (msys2) run: | premake5 gmake - mingw-w64-ucrt-x86_64-make clean - mingw-w64-ucrt-x86_64-make all config=${{ matrix.configuration }} + mingw32-make clean + mingw32-make all config=${{ matrix.configuration }} - name: Test (msys2) run: "./bin/test.exe" From 1e2a9446dac9efb2dd4452fb04e1db07de899e23 Mon Sep 17 00:00:00 2001 From: jclc Date: Thu, 30 Jan 2025 23:48:32 +0200 Subject: [PATCH 12/15] use #pragma comment only on msvc --- netcode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netcode.c b/netcode.c index f449147..6efd6fc 100755 --- a/netcode.c +++ b/netcode.c @@ -168,15 +168,19 @@ void netcode_default_free_function( void * context, void * pointer ) #include #include #include + #ifdef _MSC_VER #pragma comment( lib, "WS2_32.lib" ) #pragma comment( lib, "IPHLPAPI.lib" ) + #endif // #ifdef _MSC_VER #ifdef SetPort #undef SetPort #endif // #ifdef SetPort #include + #ifdef _MSC_VER #pragma comment( lib, "IPHLPAPI.lib" ) + #endif // #ifdef _MSC_VER #elif NETCODE_PLATFORM == NETCODE_PLATFORM_MAC || NETCODE_PLATFORM == NETCODE_PLATFORM_UNIX @@ -482,7 +486,9 @@ typedef UINT32 QOS_FLOWID, *PQOS_FLOWID; #endif // #ifdef __MINGW32__ #include +#ifdef _MSC_VER #pragma comment( lib, "Qwave.lib" ) +#endif // #ifdef _MSC_VER static int netcode_set_socket_codepoint( SOCKET socket, QOS_TRAFFIC_TYPE trafficType, QOS_FLOWID flowId, PSOCKADDR addr ) { From e26f91719267f34bdff424874056ae217cdfacf4 Mon Sep 17 00:00:00 2001 From: jclc Date: Thu, 30 Jan 2025 23:52:03 +0200 Subject: [PATCH 13/15] guard #define NOMINMAX --- netcode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netcode.c b/netcode.c index 6efd6fc..5ffc923 100755 --- a/netcode.c +++ b/netcode.c @@ -161,7 +161,9 @@ void netcode_default_free_function( void * context, void * pointer ) #if NETCODE_PLATFORM == NETCODE_PLATFORM_WINDOWS + #ifndef NOMINMAX #define NOMINMAX + #endif // #ifndef NOMINMAX #define _WINSOCK_DEPRECATED_NO_WARNINGS #include #include @@ -5227,7 +5229,9 @@ double netcode_time() // windows +#ifndef NOMINMAX #define NOMINMAX +#endif // #ifndef NOMINMAX #include void netcode_sleep( double time ) From 185c17cc9dc15e64bf1a7607036f26e6ddacedac Mon Sep 17 00:00:00 2001 From: jclc Date: Fri, 31 Jan 2025 00:19:07 +0200 Subject: [PATCH 14/15] windows link stuff attempt --- premake5.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/premake5.lua b/premake5.lua index 4c40677..8f92bc3 100644 --- a/premake5.lua +++ b/premake5.lua @@ -31,6 +31,9 @@ project "sodium" } filter { "action:gmake*" } buildoptions { "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-unknown-pragmas", "-Wno-unused-variable", "-Wno-type-limits" } + if os.target() == "windows" then + links { "ws2_32", "iphlpapi" } + end project "test" files { "test.cpp" } From bdedb6ad79eff9e95541a4c94970657985b3fe39 Mon Sep 17 00:00:00 2001 From: jclc Date: Fri, 31 Jan 2025 00:47:33 +0200 Subject: [PATCH 15/15] mingw win lib link attempt 2 --- premake5.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/premake5.lua b/premake5.lua index 8f92bc3..739131e 100644 --- a/premake5.lua +++ b/premake5.lua @@ -31,33 +31,42 @@ project "sodium" } filter { "action:gmake*" } buildoptions { "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-unknown-pragmas", "-Wno-unused-variable", "-Wno-type-limits" } - if os.target() == "windows" then - links { "ws2_32", "iphlpapi" } - end project "test" files { "test.cpp" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "soak" files { "soak.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "profile" files { "profile.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "client" files { "client.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "server" files { "server.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } project "client_server" files { "client_server.c", "netcode.c" } links { "sodium" } + filter { "action:gmake*", "system:windows" } + links { "ws2_32", "iphlpapi" } newaction {