-
Notifications
You must be signed in to change notification settings - Fork 87
Description
I was using the SDL package just fine on Windows about a year ago. Since then, it seems things have changed and I have not managed to get SDL2 working at all.
On GHC 9.12 and below, when trying to build sdl2 I get errors like:
error: ld.lld: warning: ignoring unknown argument: -exclude-symbols:console_ansi_main
ld.lld: warning: ignoring unknown argument: -exclude-symbols:console_wmain
ld.lld: warning: ignoring unknown argument: -exclude-symbols:WinMain
ld.lld: error: -exclude-symbols:console_ansi_main is not allowed in .drectve
ld.lld: error: -exclude-symbols:console_wmain is not allowed in .drectve
ld.lld: error: -exclude-symbols:WinMain is not allowed in .drectve
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think this is because the version of Clang shipped with GHC 9.12 is too old, so that's not a problem with the sdl2 package.
Now, GHC 9.14 has updated the version of Clang and includes many other Windows-related fixes, so I was hopeful. Indeed, the bug above seems to have gone away. However, the following simple program:
main :: IO ()
main = do
putStrLn "Hello"
getLine
putStrLn "Goodbye"seems to run into issues when compiling with a dependency on sdl2. When I run the program, I get:
<stdin>: hGetLine: invalid argument (Bad file descriptor)
While handling GHC.Internal.IO.FD.fdRead: invalid argument (Bad file descriptor)
This is with a trivial cabal package with build-depends: base, sdl2 == 2.5.5.0 (sdl2-2.5.5.1 doesn't seem to compile, but that's a separate issue that I've fixed in #321). Removing the dependency on sdl2 makes it all work fine.
I'm using the mingw-w64-clang-x86_64-SDL2-2.32.10-1 system library, if that makes a difference.
I've opened an issue on the GHC issue tracker as well.