Opened 6 years ago

Last modified 7 months ago

#4243 new task

Make a proper options parser for the RTS

Reported by: igloo Owned by:
Priority: normal Milestone:
Component: Runtime System Version: 6.13
Keywords: Cc: hackage.haskell.org@…, simonmar, osa1
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking: #7535
Related Tickets: #9839 Differential Rev(s):
Wiki Page:

Description

The RTS options parsing is getting increasingly crufty, and the new rtsOptsEnabled options have made it even worse. We should really have a proper options parser.

Change History (22)

comment:1 Changed 6 years ago by simonmar

Agree.

comment:2 Changed 6 years ago by igloo

It should also be possible to link against the RTS in such a way that it won't try to parse the RTS arguments at all, e.g. so +RTS would be passed to the program as an argument (as opposed to the RTS failing, as it currently does when given that argument if linked with -no-rtsopts).

comment:3 Changed 6 years ago by igloo

See also #3910.

comment:4 Changed 5 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1

Punting

comment:5 Changed 4 years ago by igloo

  • difficulty set to Unknown
  • Milestone changed from 7.6.1 to 7.8.1

comment:6 Changed 3 years ago by liyang

  • Cc hackage.haskell.org@… added

comment:7 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Bumping priority down (these tickets haven't been closely followed or fixed in 7.4), and moving out to 7.10 and out of 7.8.3.

comment:8 Changed 2 years ago by thoughtpolice

  • Priority changed from high to normal

Actually dropping priority. :)

comment:9 Changed 21 months ago by thomie

  • Cc simonmar added

comment:10 Changed 20 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:11 Changed 17 months ago by carlostome

Maybe we should change rts/RtsFlags.c to make use of <getopt.h> because now the option parser is a bit scaring. I think I can do it myself. Any suggestions?

comment:12 Changed 17 months ago by thomie

Make sure that whatever you do also works, and behaves the same, on Windows, Mac, Solaris, FreeBSD. At least in theory. Is getopt.h posix only, or is avaible the way ghc is built on Windows (I don't know). configure.ac would also need updating?

I noticed Python keeps their own copy of getopt, would that be an option?

From https://hg.python.org/cpython/rev/a826a46bae54:

"Move our own getopt() implementation to _PyOS_GetOpt(), and use it regardless of whether the system getopt() does what we want. This avoids the hassle with prototypes and externs, and the check to see if the system getopt() does what we want."

comment:13 Changed 17 months ago by thomie

  • Blocking 7535 added

comment:14 Changed 17 months ago by carlostome

  • Owner set to carlostome

comment:15 Changed 14 months ago by osa1

  • Cc osa1 added

What keeps us from implementing RTS arg parser in Haskell?

comment:16 Changed 12 months ago by carlostome

  • Owner carlostome deleted

comment:17 Changed 12 months ago by bgamari

osa1, I think for the sake of simplicity it would be best to avoid going down that road. The RTS really just needs to work, even if Haskell-land is broken (e.g. as is often the case when debugging RTS bugs or bringing up new platforms).

comment:18 Changed 12 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:19 Changed 9 months ago by Ben Gamari <ben@…>

In 69822f0c/ghc:

RtsFlags: Refactor some of the deeper switches

This was previously nearly impossible to read; now it's merely
difficult.

Ideally we would do a more thorough refactoring of the RTS command line
parser (#4243) but this is more effort than I have time for at the
moment.

Test Plan: Try using affected RTS flags

Reviewers: simonmar, austin

Subscribers: thomie

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

GHC Trac Issues: #4243

comment:20 Changed 8 months ago by dobenour

Would it be okay to use re2c to generate the RTS options parser? I have a patch that provides a proper options parser using it.

Existing libraries like getopt did not seem suitable, due to the non-standard format of the RTS flags.

comment:21 Changed 8 months ago by simonmar

I'd prefer not to add a dependency on an external tool if possible.

comment:22 Changed 7 months ago by thomie

  • Milestone 8.0.1 deleted
Note: See TracTickets for help on using tickets.