Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#9259 closed feature request (fixed)

GHCi should list its available command line options

Reported by: jstolarek Owned by: kolmodin
Priority: normal Milestone: 8.0.1
Component: Driver Version:
Keywords: newcomer Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D337
Wiki Page:

Description

GHC can now list its command line options with --show-options (#7843). GHCi should be able to do the same.

Attachments (1)

interactive_showoptions_9259.patch (2.0 KB) - added by afleck 3 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 3 years ago by jstolarek

Oh, and once this is done we should update driver/ghci-usage.txt to inform user about this possibility (see driver/ghc-usage.txt for an example).

comment:2 Changed 3 years ago by jstolarek

difficulty: Easy (less than 1 hour)Unknown

After a quick look at the source code I'm not sure if this is that simple. --show-options triggers pre-startup mode, which terminates the compiler before it even starts. But ghci is an alias for ghc --interactive, so we'd have to recognize a special case of --interactive and --show-options being used at the same time. That's probably possible, but it requires more work than I'm willing to put into this at the moment. Leaving this as a newcomer-friendly task. The relevant code is in ghc/Main.hs. It is also important to distinguish which options are supported with GHCi and which are not. I'm not sure if this information is stored in one place somewhere in the compiler, but we need to have access to it.

When this is fixed the user documentation needs to be updated as well.

comment:3 Changed 3 years ago by kolmodin

Making --interactive and --show-options work together is simple, just a few more lines to setMode. The time consuming part with this task is to cleanly separate which flags work in GHC and which work in GHCi. The flags are defined in a few different places;

  • ModeFlags defined in ghc/Main.hs which apply to both GHC and GHCi.
  • StaticFlags defined in compiler/main/StaticFlags.hs which applies to both GHC and GHCi.
  • DynFlags defined in compiler/main/DynFlags.hs. There are a few different kinds of flags here (dynflags, package flags, fflags, fwarn, ...), each of which where some are for GHC and some for GHCi. For some flags there is code guarding to make sure you don't mix them, like together with --interactive you cannot use -prof, -threaded, -unreg, -debug or -ticky. For other flags there is no such code, and it's not always obvious where each flag has effect.

comment:4 Changed 3 years ago by kolmodin

Owner: set to kolmodin

comment:5 Changed 3 years ago by kolmodin

Differential Rev(s): Phab:D337

Changed 3 years ago by afleck

comment:6 Changed 3 years ago by afleck

Oops, sorry. I didn't realize there was already a patch on Phabricator. I'm new to this...

comment:7 Changed 3 years ago by jstolarek

Keywords: newcomer added

comment:8 Changed 3 years ago by thomie

I am currently running into panics using ghc-7.9.20141113 --interactive --show-options, see #9799. I guess these will go away once Phab:D337 is landed.

comment:9 Changed 3 years ago by Austin Seipp <austin@…>

In 624a7c5a2eee0c0ba486a45550680052c2c79849/ghc:

ghc: allow --show-options and --interactive together

Summary:
Previously 'ghc --show-options' showed all options that GHC can possibly
accept. With this patch, it'll only show the options that have effect in
non-interactive modes.
This change also adds support for using 'ghc --interactive --show-options'
which previously was disallowed. This command will show all options that have
effect in the interactive mode.
The CmdLineParser is updated to know about the GHC modes, and then each flag
is annotated with which mode it has effect.
This fixes #9259.

Test Plan:
Try out --show-options with --interactive on the command line. With and without
--interactive should give different results.
Run the test suite, mode001 has been updated to verify this new flag
combination.

Reviewers: austin, jstolarek

Reviewed By: austin, jstolarek

Subscribers: jstolarek, thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D337

GHC Trac Issues: #9259

comment:10 Changed 3 years ago by kolmodin

With the patch 624a7c5a2eee0c0ba486a45550680052c2c79849 mentioned above, the bulk of the work is done.

What remains is to;

  • Clean up DynFlags, a lot of the lines are over 80 chars
  • Let more people look at the partitioning of the flags into ghc/ghci/all, correcting any mistakes where a flag has been assigned to the wrong mode
  • Some flags are defined in DynFlags but not documented in the User's Guide. Should they be marked as hidden? Mail ghc-devs and find out.
  • Possibly update documentation about ghc's new ability to use --interactive and --show-options together.

comment:11 Changed 3 years ago by Austin Seipp <austin@…>

In 6d47ab3ab3684c4245bdccd97d19db83887aae9c/ghc:

Shorten long lines in DynFlags, add details to ghci usage guide.

Summary:
Shorten long lines in DynFlags.
Describe --show-options in ghci usage guide.

Reviewers: jstolarek, austin

Reviewed By: jstolarek, austin

Subscribers: thomie, carter

Differential Revision: https://phabricator.haskell.org/D532

GHC Trac Issues: #9259

comment:12 Changed 2 years ago by thomie

Milestone: 7.12.1
Resolution: fixed
Status: newclosed

I think all work is done here.

comment:13 in reply to:  12 Changed 2 years ago by jstolarek

Replying to thomie:

I think all work is done here.

Well, I think we still didn't solve this:

  • Some flags are defined in DynFlags but not documented in the User's Guide. Should they be marked as hidden? Mail ghc-devs and find out.

I don't think we git any replies about these flags and without that we cannot do better. Not sure if we should keep this ticket open as a reminder?

comment:14 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.