[GHC] #8641: ghc with -odir and -prof cannot create the specified output directory

#8641: ghc with -odir and -prof cannot create the specified output directory -----------------------------------+--------------------------------------- Reporter: wmarshall | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time crash Unknown/Multiple | Test Case: Difficulty: Unknown | Blocking: Blocked By: | Related Tickets: | -----------------------------------+--------------------------------------- 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof (or any stub file) does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Changes (by ezyang): * owner: => ezyang * version: 7.6.3 => 7.9 Comment: Applies to Linux too. The actual source of the problem is when compilation of the file involves a stub file (so foreign exports will trigger this too); we've forgotten to call createDirectoryIfMissing in DriverPipeline.hs. Should be easy to fix but I need to cook up a test- case... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof (or any stub file) does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Comment (by ezyang): Proposed patch: {{{ diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 2c71967..93edf05 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1261,6 +1261,10 @@ runPhase (RealPhase SplitAs) _input_fn dflags liftIO $ createDirectoryIfMissing True split_odir + -- we create directories for the object file, because it + -- might be a hierarchical module. + liftIO $ createDirectoryIfMissing True (takeDirectory output_fn) + -- remove M_split/ *.o, because we're going to archive M_split/ *.o -- later and we don't want to pick up any old objects. fs <- liftIO $ getDirectoryContents split_odir }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof (or any stub file) does not create the specified
output directory
---------------------------------------+-----------------------------------
Reporter: wmarshall | Owner: ezyang
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time crash | Unknown/Multiple
Test Case: | Difficulty: Unknown
Blocking: | Blocked By:
| Related Tickets:
---------------------------------------+-----------------------------------
Comment (by ezyang):
{{{
From c7498bbdaa74dadd976c75c4e303c2050aa78277 Mon Sep 17 00:00:00 2001
From: "Edward Z. Yang"

#8641: ghc with -odir and -prof (or any stub file) does not create the specified
output directory
---------------------------------------+-----------------------------------
Reporter: wmarshall | Owner: ezyang
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time crash | Unknown/Multiple
Test Case: | Difficulty: Unknown
Blocking: | Blocked By:
| Related Tickets:
---------------------------------------+-----------------------------------
Comment (by Edward Z. Yang

#8641: ghc with -odir and -prof (or any stub file) does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: ezyang Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Changes (by ezyang): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof (or any stub file) does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: ezyang Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged in 7.8, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8641: ghc with -odir and -prof (or any stub file) does not create the specified output directory ---------------------------------------+----------------------------------- Reporter: wmarshall | Owner: ezyang Type: bug | Status: closed Priority: normal | Milestone: 7.8.3 Component: Compiler | Version: 7.9 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time crash | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ---------------------------------------+----------------------------------- Changes (by thoughtpolice): * milestone: => 7.8.3 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8641#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC