Skip to content

Windows: `ghc-debug-stub-0.6.0.0` does not build

The build (with GHC 9.6.6) fails with:

ghc-debug-stub> [1 of 1] Compiling GHC.Debug.Stub
ghc-debug-stub>
ghc-debug-stub> cbits\stub.cpp:8:10: error:
ghc-debug-stub>      fatal error: 'sys/socket.h' file not found
ghc-debug-stub>   |
ghc-debug-stub> 8 | #include <sys/socket.h>
ghc-debug-stub>   |          ^
ghc-debug-stub> #include <sys/socket.h>
ghc-debug-stub>          ^~~~~~~~~~~~~~
ghc-debug-stub> 1 error generated.
ghc-debug-stub> `clang++.exe' failed in phase `C++ Compiler'. (Exit code: 1)

I understand that sys/socket.h may be Unix-like operating systems only, although I also found this: https://www.gnu.org/software/gnulib/manual/gnulib.html#sys_002fsocket_002eh (I am not sure how I would make use of it to solve the problem).

If ghc-debug-stub does not currently support Windows, perhaps that should be reflected in its Cabal file and could be stated more explicitly in its Haddock documentation?

(As an aside, I saw that MSYS2 package msys2-runtime-devel provided /usr/include/sys/socket.h. So, naively, I added that package to the MSYS2 environment (stack exec -- pacman -S msys2-runtime-devel and specified:

extra-include-dirs:
- D:/sr/programs/x86_64-windows/msys2-20230526/usr/include/

This also fails, but for different reasons (extract only of a long list):

Building library for ghc-debug-stub-0.6.0.0..
In file included from cbits\stub.cpp:5:0: error:
In file included from D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\iostream:37:0: error:
In file included from D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\ios:214:0: error:
In file included from D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\__locale:18:0: error:
In file included from D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\memory:808:0: error:
In file included from D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\__functional_base:23:0: error:

D:\sr\programs\x86_64-windows\ghc-9.6.6\lib\..\mingw\include\c++\v1\new:324:12: error:
     error: no member named '_aligned_malloc' in the global namespace; did you mean 'aligned_alloc'?
      return ::_aligned_malloc(__size, __alignment);
             ~~^
    |
324 |   return ::_aligned_malloc(__size, __alignment);
    |            ^

D:\sr\programs\x86_64-windows\msys2-20230526\usr\include\stdlib.h:332:8: error:
     note: 'aligned_alloc' declared here
    |
332 | void *  aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
    |        ^
void *  aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
        ^

I understand that _alligned_malloc is provided by Window's <malloc.h> header.)

Edited by Mike Pilgrem