build/test on Windows 10 with MinGW
When building LibUV for Perl 5 (not Perl 6), we have to make use of cmake with MinGW and gmake.
Strawberry Perl (even Portables work here) makes both MinGW and gmake available to you out of the box and throws them both into your $env:PATH. You can then run cpanm Alien::cmake3 to get the latest cmake. perl -MAlien::cmake3 -E "say Alien::cmake3->bin_dir" will give you the path to the newly installed cmake bin directory. Add that to your path via: $env:PATH+="C:\Strawberry\ll_5.26.1.1_normal\lib\perl5\MSWin32-x64-multi-thread\auto\share\dist\Alien-cmake3\bin\".
Now, you have cmake, MinGW, and gmake binaries available in your path. Here's the build attempt I'm trying:
Unzip libuv-v1.23.1.tar.gz to C:\temp\libuv-v1.23.1
PS C:\temp\out> md -Force C:\temp\out\1.23.1\
Now we have a directory in which we can store our build.
PS C:\temp\out> cmake -G "MinGW Makefiles" -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true -DCMAKE_INSTALL_PREFIX:PATH=C:/temp/out/1.23.1/ -DCMAKE_MAKE_PROGRAM:PATH=gmake -DBUILD_TESTING=ON C:/temp/libuv-v1.23.1
Now, compile the project:
PS C:\temp\out> gmake all test
This will compile fine, but fail when it tries to run the test suite:
[100%] Linking C executable uv_run_tests.exe
CMakeFiles
\uv_run_tests.dir/objects.a(test-spawn.c.obj):test-spawn.c:(.text+0x43b0): undefined reference to `quote_cmd_arg'
CMakeFiles\uv_run_tests.dir/objects.a(test-spawn.c.obj
):test-spawn.c
:(.text+0x461e
): undefined reference
to `make_program_args
'
CMakeFiles
\uv_run_tests.dir/objects.a
(test-spawn.c.obj):test
-spawn.c:(.text
+0x4676): undefined
reference to
`make_program_args
'
CMakeFiles\uv_run_tests.dir
/objects.a(test-spawn.c.obj
):test-spawn.c:(.text+0x4b60): undefined reference to `make_program_env
'
collect2.exe: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles\uv_run_tests.dir\build.make:2391: uv_run_tests.exe] Error 1
gmake[1]: *** [CMakeFiles\Makefile2:301: CMakeFiles/uv_run_tests.dir/all] Error 2
gmake: *** [Makefile:94: all] Error 2
Here's the entire output log
Is there something especially stupid that I'm doing wrong?
That copied/pasted text above makes it appear as if there are newlines at the end. However, I'm thinking that may be due to some oddities in how MS redirects STDERR and STDOUT to a file via >> ?
This screenshot shows what it looks like if I just run it in the shell without redirecting the output: https://image.ibb.co/hwbTwp/build_ss.png
Thanks to @xenu the following patch allows the tests to run as expected:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f13efc8..c739c1a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -342,7 +342,7 @@ target_link_libraries(uv_a ${uv_libraries})
if(BUILD_TESTING)
include(CTest)
add_executable(uv_run_tests ${uv_test_sources})
- target_compile_definitions(uv_run_tests PRIVATE ${uv_defines})
+ target_compile_definitions(uv_run_tests PRIVATE ${uv_defines} USING_UV_SHARED=1)
target_compile_options(uv_run_tests PRIVATE ${uv_cflags})
target_include_directories(uv_run_tests PRIVATE include)
target_link_libraries(uv_run_tests uv ${uv_test_libraries})
However, the tests fail:
[100%] Building C object CMakeFiles/uv_run_tests.dir/test/runner-win.c.obj
In file included from C:\temp\libuv-v1.23.1\test\runner.h:97:0,
from C:\temp\libuv-v1.23.1\test\runner-win.c:33:
C:\temp\libuv-v1.23.1\test\runner-win.h:23:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable : 4996)
C:\temp\libuv-v1.23.1\test\runner-win.c: In function 'process_wait':
C:\temp\libuv-v1.23.1\test\runner-win.c:192:14: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + n) {
^~
C:\temp\libuv-v1.23.1\test\runner-win.c: In function 'process_read_last_line':
C:\temp\libuv-v1.23.1\test\runner-win.c:266:32: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
for (start = read - 1; start >= 0; start--) {
^~
C:\temp\libuv-v1.23.1\test\runner-win.c: At top level:
C:\temp\libuv-v1.23.1\test\runner-win.c:306:12: warning: function declaration isn't a prototype [-Wstrict-prototypes]
static int clear_line() {
^~~~~~~~~~
[100%] Linking C executable uv_run_tests.exe
[100%] Built target uv_run_tests
Running tests...
Test project C:/temp/out
Start 1: uv_test
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
1/2 Test #1: uv_test ..........................***Failed 120.35 sec
Start 2: uv_test_a
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
2/2 Test #2: uv_test_a ........................***Failed 123.36 sec
0% tests passed, 2 tests failed out of 2
Total Test time (real) = 243.74 sec
The following tests FAILED:
1 - uv_test (Failed)
2 - uv_test_a (Failed)
Errors while running CTest
gmake: *** [Makefile:61: test] Error 8
PS C:\temp\out>
It looks like two tests are failing:
not ok 47 - fs_event_watch_dir_short_path
# exit code 3
# Output from process `fs_event_watch_dir_short_path`:
# Assertion failed in C:\temp\libuv-v1.23.1\test\test-fs-event.c on line 495: r == 0
not ok 168 - process_priority
# exit code 3
# Output from process `process_priority`:
# Assertion failed in C:\temp\libuv-v1.23.1\test\test-process-priority.c on line 58: priority == UV_PRIORITY_HIGHEST
@genio can you try https://github.com/cjihrig/libuv/commit/cf1e84ac15e3160722de59835e74edde10a56abc as a fix for the process_priority test? See https://github.com/nodejs/node/pull/22817 for an explanation of what's likely happening there.
That does fix the process_priority test for me. Can you also work up the change @xenu supplied for the CMakeLists.txt?
Thanks!