Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5905 closed bug (wontfix)

ghc with incorrect arguments deletes source file

Reported by: dowski Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.3
Keywords: Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Compile-time performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I'm just learning haskell and I mistakenly passed the -o argument to ghc instead of -c. When combined with the -i argument (which I also mistakenly supplied, thinking of ghci), this unlinks the file named by -o.

This is certainly a case of PEBKAC, but ghc should probably do something other than unlinking the file.

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3
$ ls path/to/
source.hs
$ ghc -i . -o path/to/source.hs 
/usr/bin/ld: cannot find .: File format not recognized
collect2: ld returned 1 exit status
$ ls path/to/
$

Change History (2)

comment:1 Changed 8 years ago by simonmar

difficulty: Unknown
Resolution: wontfix
Status: newclosed

ghc is just calling ld, it is ld that unlinks the output file. gcc behaves exactly the same way:

$ touch foo.c 
$ gcc . -o foo.c
/usr/bin/ld: .: No such file: File format not recognized
collect2: ld returned 1 exit status
$ ls foo.c
ls: cannot access foo.c: No such file or directory

comment:2 Changed 8 years ago by dowski

This makes sense. Thanks for the explanation.

Note: See TracTickets for help on using tickets.