Open gussen opened 2 years ago
This seems very surprising! Can you give any more information?
Is anyone else experiencing this problem?
Some more info
All versions runs in a REPL.
cabal repl Resolving dependencies... Build profile: -w ghc-8.10.7 -O1 In order, the following will be built (use -v for more details):
- TestFormatting-0.1.0.0 (exe:TestFormatting) (configuration changed) Configuring executable 'TestFormatting' for TestFormatting-0.1.0.0.. Preprocessing executable 'TestFormatting' for TestFormatting-0.1.0.0.. GHCi, version 8.10.7: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( Main.hs, interpreted ) [Formatting changed] Ok, one module loaded. Main> main Hello, Haskell! Tre: 3 Main> :q Leaving GHCi.
If using formatting 7.0.0 and GHC 8.10.7 this crashes without printing anything.
someFormatting :: IO ()
someFormatting = F.fprint ("Tre: " % F.int % "\n") (3::Int)
main :: IO ()
main = do
putStrLn "Hello, Haskell!"
If using GHC 9.2.5 on another computer it still ends without any output. It doesn't matter if I build with -O1 or -O2. If I build with a function that is using formatting, e.g.
someFormatting = F.fprint ("Tre: " % F.int % "\n") (3::Int)
It ends with no output even if I don't call the function. If I remove the function from the program it works OK.
If trying to run the executable inside the debugger WinDbg I get this error: The application was unable to start correctly (0xc000007b).
If looking at the dependencies of the executable I can see that "libstdc++-6.dll" is a dependency when when building against formatting 7.0.0 and not when building with 6.3.7. I have many versions of that dll on my system so I copied "C:\ghcup\ghc\8.10.7\mingw\bin\libstdc++-6.dll" to the same directory as the built executable but it still didn't work.
If building formatting with 'no-double-conversion' set to True everything works fine.
I have now tested with double-conversion package and there is some strange linking problem. If using a MSYS2/MinGW64 shell I can get it to work on one of my machines. From Windows GUI or PowerShell it doesn't work. There are other reports of linking problems on Windows: https://gitlab.haskell.org/ghc/ghc/-/issues/20010.
@gussen You mentioned GHC 9.2.x. Note that versions 9.2 and before of GHC had problems on Windows, which is why everything was rewritten to use Clang. See release notes:
A complete overhaul of GHC’s Windows support. This includes a migration to a fully Clang-based C toolchain, a deep refactoring of the linker, and many fixes in WinIO.
It might work better on GHC 9.4. Note that to use double-conversion on 9.4, you need to use it from git, since a compatible release wasn't yet released.
On Windows 10, 64-bit, GHC 8.10.7
If using formatting version 6.3.7 this small program works. It prints "Hello" and "Tre: 3".
If using formatting 7.0.0 or 7.1.3 it crashes. It doesn't write "Hello" or "Tre: 3".