Opened 11 years ago

Closed 8 years ago

#3104 closed bug (wontfix)

-main-is should be a link time option, not compile time

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

Description

The -main-is flag specifies which function name to use as main. However, when doing separate compilation:

ghc -c Foo.hs
ghc Foo.o

You have to give the -main-is in the first step - the compilation, rather than in the second step, the linking. It feels like this flag should be a link time option, and would give greater flexibility allowing one object file to be used in multiple projects with different main commands.

If you compile with ghc --make this issue isn't really a problem.

Change History (7)

comment:1 Changed 11 years ago by igloo

difficulty: Unknown
Milestone: 6.12.1

comment:2 Changed 11 years ago by NeilMitchell

Cc: ndmitchell@… added

comment:3 Changed 10 years ago by igloo

Milestone: 6.12.16.14.1
Type of failure: None/Unknown

comment:4 Changed 9 years ago by igloo

Milestone: 7.0.17.0.2

comment:5 Changed 9 years ago by igloo

Milestone: 7.0.27.2.1

comment:6 Changed 8 years ago by igloo

Milestone: 7.2.17.4.1

comment:7 Changed 8 years ago by simonmar

Resolution: wontfix
Status: newclosed

We could do this, and indeed I started to do it, but for a couple of reasons it's not completely satisfactory.

  • We want to check that the specified function is exported and has the right type. These checks are currently compulsory because -main-is is a compile-time as well as link-time option, but if -main-is was only required at link-time then the checks would be optional. The consequence of getting the type wrong is a segfault; not ideal.
  • Currently -main-is can specify an identifier that is re-exported from another module. This can't be done at link-time, so it would only work for identifiers defined and exported from the same module.

So I backed off.

Note: See TracTickets for help on using tickets.