Opened 5 years ago

Closed 5 years ago

#4287 closed bug (fixed)

GHC command invocation debug output not in correct format for cmd.exe

Reported by: ezyang Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.12.3
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


A frequent operation when debugging a misbehaving GHC build is manually performing an invocation that GHC made to some external process. To aid this, -v3 prints out the command that GHC invoked.

Ideally, we would like to be able to copy paste this printed command to our terminal and have it work correctly (with temporary files kept and such.) However, the output for Windows is quite misleading. Consider the following command:

C:\Program Files\Haskell Platform\2010.2.0.0\lib\..\mingw\bin\windres --preprocessor="C:\Program Files\Haskell Platform\2010.2.0.0\lib\..\mingw\bin\gcc" "-E" "-xc" "-DRC_INVOKED" --use-temp-file --input=C:\Users\ezyang\ghc672_0\ghc672_0.rc --output=C:\Users\ezyang\ghc672_0\ghc672_0.o --output-format=coff

The primary problem is that arguments are not escaped or quoted. This is seen in the executable path in this command, which has a space in it.

This is a major usability bug when command line arguments contain argments in them. For example, -E is meant as a flag to gcc, not windres. However, the printed command line is quite misleading.

This should be relatively easy to fix.

Change History (3)

comment:1 Changed 5 years ago by ezyang

Well, actually, cmd.exe's shell quoting rules are pretty arcane, so it might be better to universally assume sh semantics and do courteous things like escape backslashes and spaces appropriately.

comment:2 Changed 5 years ago by simonmar

The process library provides a transformation that quotes things correctly for Windows, as long as the program being spawned uses the standard command-line parsing routines. See System.Process.Internals.translate.

comment:3 Changed 5 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in HEAD:

Wed Sep 29 00:58:44 BST 2010  Ian Lynagh <[email protected]>
  * Use showCommandForUser when showing tracing commands
Note: See TracTickets for help on using tickets.