Skip to content

ghc with -odir and -prof (or any stub file) does not create the specified output directory

Calling ghc with -odir set to a non-existent directory causes ghc to create the directory. However, if the -prof option is also specified, ghc fails to create the directory and quits with an error.

Steps to reproduce:

$ echo 'main = print "Hello world"' > Main.hs

$ ghc Main.hs -odir bin
[1 of 1] Compiling Main             ( Main.hs, bin\Main.o )
Linking Main.exe ...

$ rm -Rvf bin
removed `bin/Main.o'
removed directory: `bin'

$ ghc Main.hs -odir bin -prof
[1 of 1] Compiling Main             ( Main.hs, bin\Main.o )
C:/Program Files (x86)/Haskell Platform/2013.2.0.0/mingw/bin/ld.exe: cannot open output file bin\Main.o: No such file or directory
collect2: ld returned 1 exit status

Expected result: The output directory is created regardless of whether -prof is specified.

The above commands were executed from within Cygwin, but the error occurs in the Windows command shell as well. (I used Cygwin here because it is easier to give precise instructions to reproduce the error.)

I have only tested this on Windows. I do not know if the issue exists on Linux or other platforms.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Edward Z. Yang
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information