From 4403c46788bd857c214d327a87b2a3580c9b70f3 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 15 Feb 2026 12:26:32 +0300 Subject: [PATCH] Fix Windows build: skip gettimeofday on MSYS2, force recompile ecc_platform_specific --- build_win.log | 71 ++++++++++++++++++++------- lib/platform_compat.h | 3 +- tests/test_crypto | Bin 194712 -> 194712 bytes tests/test_ecc_encrypt | Bin 251856 -> 251856 bytes tests/test_pkt_normalizer_standalone | Bin 391464 -> 391464 bytes 5 files changed, 55 insertions(+), 19 deletions(-) diff --git a/build_win.log b/build_win.log index 3788b10b..23c29535 100644 --- a/build_win.log +++ b/build_win.log @@ -9,36 +9,71 @@ make[2]: Entering directory '/c/ARM/_uTun/utun2/src' make[2]: Leaving directory '/c/ARM/_uTun/utun2/src' Making all in tests make[2]: Entering directory '/c/ARM/_uTun/utun2/tests' - cd .. && /bin/sh /c/ARM/_uTun/utun2/build-aux/missing automake-1.16 --foreign tests/Makefile - cd .. && /bin/sh ./config.status tests/Makefile depfiles -config.status: creating tests/Makefile -config.status: executing depfiles commands make all-am make[3]: Entering directory '/c/ARM/_uTun/utun2/tests' -x86_64-w64-mingw32-gcc -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -o test_etcp_crypto.exe test_etcp_crypto-test_etcp_crypto.o ../src/utun-secure_channel.o ../src/utun-crc32.o -lcrypto ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -lcrypto -x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -MT test_etcp_two_instances-test_etcp_two_instances.o -MD -MP -MF .deps/test_etcp_two_instances-test_etcp_two_instances.Tpo -c -o test_etcp_two_instances-test_etcp_two_instances.o `test -f 'test_etcp_two_instances.c' || echo './'`test_etcp_two_instances.c -x86_64-w64-mingw32-gcc -I../tinycrypt/lib/include -I../tinycrypt/lib/source -I../lib -g -O2 -o test_crypto.exe test_crypto-test_crypto.o ../src/utun-aes_encrypt.o ../src/utun-aes_decrypt.o ../src/utun-ccm_mode.o ../src/utun-cmac_mode.o ../src/utun-ctr_mode.o ../src/utun-ecc.o ../src/utun-ecc_dh.o ../src/utun-ecc_dsa.o ../src/utun-sha256.o ../src/utun-ecc_platform_specific.o ../src/utun-utils.o ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -lcrypto -x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -MT test_etcp_simple_traffic-test_etcp_simple_traffic.o -MD -MP -MF .deps/test_etcp_simple_traffic-test_etcp_simple_traffic.Tpo -c -o test_etcp_simple_traffic-test_etcp_simple_traffic.o `test -f 'test_etcp_simple_traffic.c' || echo './'`test_etcp_simple_traffic.c +x86_64-w64-mingw32-gcc -I../tinycrypt/lib/include -I../tinycrypt/lib/source -I../lib -g -O2 -o test_crypto.exe test_crypto-test_crypto.o ../src/utun-aes_encrypt.o ../src/utun-aes_decrypt.o ../src/utun-ccm_mode.o ../src/utun-cmac_mode.o ../src/utun-ctr_mode.o ../src/utun-ecc.o ../src/utun-ecc_dh.o ../src/utun-ecc_dsa.o ../src/utun-sha256.o ../src/utun-ecc_platform_specific.o ../src/utun-utils.o ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -o test_pkt_normalizer_standalone.exe test_pkt_normalizer_standalone-test_pkt_normalizer_standalone.o ../src/utun-pkt_normalizer.o ../src/utun-route_lib.o ../src/utun-routing.o ../src/utun-etcp_api.o ../src/utun-aes_encrypt.o ../src/utun-aes_decrypt.o ../src/utun-ccm_mode.o ../src/utun-cmac_mode.o ../src/utun-ctr_mode.o ../src/utun-ecc.o ../src/utun-ecc_dh.o ../src/utun-ecc_dsa.o ../src/utun-sha256.o ../src/utun-ecc_platform_specific.o ../src/utun-utils.o ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -o test_etcp_api.exe test_etcp_api-test_etcp_api.o ../src/utun-config_parser.o ../src/utun-config_updater.o ../src/utun-route_lib.o ../src/utun-route_bgp.o ../src/utun-routing.o ../src/utun-tun_if.o ../src/utun-tun_windows.o ../src/utun-utun_instance.o ../src/utun-etcp.o ../src/utun-etcp_connections.o ../src/utun-etcp_loadbalancer.o ../src/utun-pkt_normalizer.o ../src/utun-etcp_api.o ../src/utun-secure_channel.o ../src/utun-crc32.o -lcrypto ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../lib -g -O2 -MT test_ll_queue-test_ll_queue.o -MD -MP -MF .deps/test_ll_queue-test_ll_queue.Tpo -c -o test_ll_queue-test_ll_queue.o `test -f 'test_ll_queue.c' || echo './'`test_ll_queue.c C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../src/utun-ecc.o:ecc.c:(.data+0x0): undefined reference to `default_CSPRNG' collect2.exe: error: ld returned 1 exit status make[3]: *** [Makefile:899: test_crypto.exe] Error 1 make[3]: *** Waiting for unfinished jobs.... -test_etcp_simple_traffic.c: In function 'create_temp_configs': -test_etcp_simple_traffic.c:71:32: warning: comparison between pointer and integer - 71 | if (test_mkdtemp(temp_dir) == NULL) { - | ^~ -mv -f .deps/test_etcp_two_instances-test_etcp_two_instances.Tpo .deps/test_etcp_two_instances-test_etcp_two_instances.Po -mv -f .deps/test_etcp_simple_traffic-test_etcp_simple_traffic.Tpo .deps/test_etcp_simple_traffic-test_etcp_simple_traffic.Po +C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../src/utun-ecc.o:ecc.c:(.data+0x0): undefined reference to `default_CSPRNG' +collect2.exe: error: ld returned 1 exit status +make[3]: *** [Makefile:955: test_pkt_normalizer_standalone.exe] Error 1 +In file included from ../lib/u_async.h:8, + from test_ll_queue.c:14: +../lib/platform_compat.h:44:23: error: static declaration of 'gettimeofday' follows non-static declaration + 44 | static inline int gettimeofday(struct timeval *tv, void *tz) { + | ^~~~~~~~~~~~ +In file included from test_ll_queue.c:11: +C:/msys64/ucrt64/include/sys/time.h:42:13: note: previous declaration of 'gettimeofday' with type 'int(struct timeval * restrict, void * restrict)' + 42 | int __cdecl gettimeofday(struct timeval *__restrict__, + | ^~~~~~~~~~~~ +make[3]: *** [Makefile:1217: test_ll_queue-test_ll_queue.o] Error 1 make[3]: Leaving directory '/c/ARM/_uTun/utun2/tests' make[2]: *** [Makefile:844: all] Error 2 make[2]: Leaving directory '/c/ARM/_uTun/utun2/tests' make[1]: *** [Makefile:379: all-recursive] Error 1 make[1]: Leaving directory '/c/ARM/_uTun/utun2' make: *** [Makefile:320: all] Error 2 - +'. +make[2]: Leaving directory '/c/ARM/_uTun/utun2/lib' +Making all in src +make[2]: Entering directory '/c/ARM/_uTun/utun2/src' +make[2]: Leaving directory '/c/ARM/_uTun/utun2/src' +Making all in tests +make[2]: Entering directory '/c/ARM/_uTun/utun2/tests' +make all-am +make[3]: Entering directory '/c/ARM/_uTun/utun2/tests' +x86_64-w64-mingw32-gcc -I../tinycrypt/lib/include -I../tinycrypt/lib/source -I../lib -g -O2 -o test_crypto.exe test_crypto-test_crypto.o ../src/utun-aes_encrypt.o ../src/utun-aes_decrypt.o ../src/utun-ccm_mode.o ../src/utun-cmac_mode.o ../src/utun-ctr_mode.o ../src/utun-ecc.o ../src/utun-ecc_dh.o ../src/utun-ecc_dsa.o ../src/utun-sha256.o ../src/utun-ecc_platform_specific.o ../src/utun-utils.o ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -o test_pkt_normalizer_standalone.exe test_pkt_normalizer_standalone-test_pkt_normalizer_standalone.o ../src/utun-pkt_normalizer.o ../src/utun-route_lib.o ../src/utun-routing.o ../src/utun-etcp_api.o ../src/utun-aes_encrypt.o ../src/utun-aes_decrypt.o ../src/utun-ccm_mode.o ../src/utun-cmac_mode.o ../src/utun-ctr_mode.o ../src/utun-ecc.o ../src/utun-ecc_dh.o ../src/utun-ecc_dsa.o ../src/utun-sha256.o ../src/utun-ecc_platform_specific.o ../src/utun-utils.o ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -I../src -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source -g -O2 -o test_etcp_api.exe test_etcp_api-test_etcp_api.o ../src/utun-config_parser.o ../src/utun-config_updater.o ../src/utun-route_lib.o ../src/utun-route_bgp.o ../src/utun-routing.o ../src/utun-tun_if.o ../src/utun-tun_windows.o ../src/utun-utun_instance.o ../src/utun-etcp.o ../src/utun-etcp_connections.o ../src/utun-etcp_loadbalancer.o ../src/utun-pkt_normalizer.o ../src/utun-etcp_api.o ../src/utun-secure_channel.o ../src/utun-crc32.o -lcrypto ../lib/libuasync.a -lpthread -lws2_32 -liphlpapi -ladvapi32 -lcrypto +x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../lib -g -O2 -MT test_ll_queue-test_ll_queue.o -MD -MP -MF .deps/test_ll_queue-test_ll_queue.Tpo -c -o test_ll_queue-test_ll_queue.o `test -f 'test_ll_queue.c' || echo './'`test_ll_queue.c +C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../src/utun-ecc.o:ecc.c:(.data+0x0): undefined reference to `default_CSPRNG' +collect2.exe: error: ld returned 1 exit status +make[3]: *** [Makefile:899: test_crypto.exe] Error 1 +make[3]: *** Waiting for unfinished jobs.... +C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../src/utun-ecc.o:ecc.c:(.data+0x0): undefined reference to `default_CSPRNG' +collect2.exe: error: ld returned 1 exit status +make[3]: *** [Makefile:955: test_pkt_normalizer_standalone.exe] Error 1 +In file included from ../lib/u_async.h:8, + from test_ll_queue.c:14: +../lib/platform_compat.h:44:23: error: static declaration of 'gettimeofday' follows non-static declaration + 44 | static inline int gettimeofday(struct timeval *tv, void *tz) { + | ^~~~~~~~~~~~ +In file included from test_ll_queue.c:11: +C:/msys64/ucrt64/include/sys/time.h:42:13: note: previous declaration of 'gettimeofday' with type 'int(struct timeval * restrict, void * restrict)' + 42 | int __cdecl gettimeofday(struct timeval *__restrict__, + | ^~~~~~~~~~~~ +make[3]: *** [Makefile:1217: test_ll_queue-test_ll_queue.o] Error 1 +make[3]: Leaving directory '/c/ARM/_uTun/utun2/tests' +make[2]: *** [Makefile:844: all] Error 2 +make[2]: Leaving directory '/c/ARM/_uTun/utun2/tests' +make[1]: *** [Makefile:379: all-recursive] Error 1 make[1]: Leaving directory '/c/ARM/_uTun/utun2' make: *** [Makefile:320: all] Error 2 -Build completed successfully! -Binary: src/utun.exe -Make sure wintun.dll is in the same directory as utun.exe +ERROR: Build failed! +Check build_win.log (Windows) or build_linux.log (Linux) for details diff --git a/lib/platform_compat.h b/lib/platform_compat.h index 0f3274bf..1be73ce8 100644 --- a/lib/platform_compat.h +++ b/lib/platform_compat.h @@ -40,7 +40,8 @@ #endif // gettimeofday for Windows (timezone already defined in time.h) - #ifndef HAVE_GETTIMEOFDAY + // Note: MSYS2 already has gettimeofday in sys/time.h, so we skip it here + #if !defined(HAVE_GETTIMEOFDAY) && !defined(__MINGW32__) static inline int gettimeofday(struct timeval *tv, void *tz) { (void)tz; if (tv) { diff --git a/tests/test_crypto b/tests/test_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P zJF+Q`k3unA=2hAN9OrTeICrC^W;PmlSdFz+&29s`aLgo{SjK|6+r%NfX7-wxYrDg_ zqNd}OI+j`~iL6_IEXPK{ zfOT!F52oSM$>iF;{x=>-n$;ff+!|fn@*XU!fec#a+dI{ZRnrxyK74Pk3cWNnp{&^n G)b?-lgo={@ delta 591 zcmZ`#O-NKx82x_UeQ!o_-ou%gX-W+-7@@^LQJcVpxNufuiyRTc#gqv`A}-v`U{DZ3 z&SJU|j=89X2pY6_Enp!IyxOW;TXmmJ zb8NeFZ?x}4a(lG)?Of^o$`=>zEZ?4Gf0psXeqmDqsPX6&2yKbBgLtoK3OPiE)RLLp zv;dq$bU<|TO9vq2l|=4HVcx)`fyxm;INvOuGoG;;qld>CJIbgWSE9KtEL)J07{E^kJ z=}b&bLM~jCR!ReONqJex4K-EtW*txRa7#)5tYbG0>v#i;nAHy(ID%L7egktYzT^_- z)||vr`5L9LQoc)9>CJ?m>%p_Wg*3wG`qwS`oWw=HuY=YXFr(cnru@xw#oj8aAKSudCFVTq~HdY67wx8x00B zS2n-W^(vi@5B`%5Ojw5Pe*YQ`e)k_g<$*M^{`HYB;k@n+xCaA0X6T(>GL+T30q-0D D@i~Y~ diff --git a/tests/test_pkt_normalizer_standalone b/tests/test_pkt_normalizer_standalone index b07a31c81ff58fe701915f8b0648552de418f9b2..91e18a8483cca333ad78bb41bf3c92fd4e386d93 100755 GIT binary patch delta 642 zcmZutO=uHg5S{scHcevVVpnz>TMdGmL(yPMJXn-ca0@+&Xrr{EAv8sT#3o2?sr3+l zf=!|Dd9YqQ*jB`X;vPi&fr26yyc7?L)W05@1T2O0=zJ6piVJUM-kZnH+nrgnXV&cb z0=M|LN`F0b_fuv6{KCP{U-`a6;mFl8FO@lZWzLp=7GENObXtxBHL(-G$h743ENS*F z*}XKgCf@PXYfH?TMJ$s*NTc`M+`33GHk*7p+Za z*FR1bTxA(ds=_LZ6qD^YIDj<=5Fmt}OMqmoo8EtfXq>QhI0YjR^6$wQ|x<1Wlyp_UTd8Va*TPGf3Zh#OnZBy zJZ<5icdMI!3A5VkP1n=_ziHsO7dgv^IbQQh=XvK3>{ri@i9~dO{tX47BS9*nA&Azg zNErt|i|L5;@MU$_6+4_Bl-$}beU>dl1|}-wf&_zisf(`IjrY~0D;)f&=3LR~yeR%< zUeaD^@OWw672dilgPEsKWM3~o^B&aDgltu*hHS&4y3&wGaY((=Ew6Bc+I7{lAy<9_ DHJX@9 delta 627 zcmZutO-NKx7`@;9dGnXkkWb!dGd2XpEF=YEHVs7xJ)1W6J2NPvFpVvS5FKJxskNA> zAsvuD7rBZ+jHocUi-;@;k}$|cTZu>)&Ik!I?&`Zpo9Mwg-_JSkzH{Hgj+rRnLpG1Bf&pS-z7D^l(1Wr$97cEg3QbvNefFv@TMz|!aJ)aD;^hn2?w