Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#9056 closed feature request (wontfix)

--make paths are not deduplicated

Reported by: evincarofautumn Owned by:
Priority: normal Milestone:
Component: Driver Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

I had a build script with an accidental duplicate dependency, which caused GHC to be run like so:

ghc --make Main.hs Main.hs

This results in a spurious error from GhcMake.checkDuplicates:

<no location info>:
  module ‘main:Main’ is defined in multiple files: Main.hs Main.hs

Attachments (1)

0001-Deduplicate-input-filenames-9056.patch (2.8 KB) - added by thomie 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by thomie

Component: CompilerDriver
difficulty: UnknownEasy (less than 1 hour)

Changed 3 years ago by thomie

comment:2 Changed 3 years ago by thomie

I was working on a patch for this (attached, unfinished), but now don't think there's actually a bug here. I find the current error message quite clear, and think that it can be expected from a build system or the user not to supply the same filename twice. Please do reopen if you disagree, perhaps as a feature request.

Fwiw: gcc doesn't seem to deduplicate input filenames either, giving a similar error message.

$ cat test.c
int main(void) {
  return 0;
  }

$ gcc test.c test.c
/tmp/ccL0QwIZ.o: In function `main':
test.c:(.text+0x0): multiple definition of `main'
/tmp/ccxMTZBK.o:test.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

If we do want this:

It is not as simple as just deduplicating filenames. For starters, comparing paths with (==) returns False for ./foo and foo, so System.FilePath.equalFilePaths should be used. But what about relative vs absolute paths? What about Main and Main.hs, are they the same? What about Main.lhs and Main.hs?

comment:3 Changed 3 years ago by thomie

Resolution: wontfix
Status: newclosed
Type: bugfeature request

comment:4 Changed 3 years ago by rwbarton

I generally agree with thomie here, but I think there is some room for interpretation since ghc's make mode already is a bit "do what I mean". For example, if module A imports module B, then ghc A.hs B.hs does the same as ghc A.hs, so there seems to be some kind of deduplication happening already.

Note: See TracTickets for help on using tickets.