Opened 3 years ago

Closed 3 years ago

#4869 closed bug (fixed)

ghci command line option -l should accept either -llibrary or -l library (POSIX requirement)

Reported by: hgolden Owned by:
Priority: high Milestone: 7.4.1
Component: GHCi Version: 7.0.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty:
Test Case: See description Blocked By:
Blocking: Related Tickets:

Description

According to POSIX, the -l option of GHCi should work with either the library name concatenated to the -l or as as separate argument immediately following the -l. At present it only works in the first case.

Examples of current behavior:

# failure (library name separated from -l)
hgolden@hbg-srv3 ~ $ ghci -l pcre
GHCi, version 7.0.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading object (dynamic)  ... failed.
<command line>: user specified .o/.so/.DLL could not be loaded (lib.so: cannot open shared object file: No such file or directory)
Whilst trying to load:  (dynamic) 
Additional directories searched: (none)

# success (library name concatenated with -l)
hgolden@hbg-srv3 ~ $ ghci -lpcre
GHCi, version 7.0.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Loading object (dynamic) pcre ... done
final link ... done
Prelude> :q
Leaving GHCi.

(This is a very minor bug with a trivial workaround. However, it should be easy to fix.)

Compare how GCC handles -l. While the -l library form is discouraged, it is accepted.

Change History (4)

comment:1 follow-up: Changed 3 years ago by igloo

  • Milestone set to 7.2.1

This is a POSIX requirement for cc or ld, presumably? With -optl prefixes this should already work.

If supporting "-l foo" is trivial then we may as well, but otherwise I think we should wontfix this.

comment:2 in reply to: ↑ 1 Changed 3 years ago by hgolden

Replying to igloo:

This is a POSIX requirement for cc or ld, presumably?

Yes. See the c99 description: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html

Also, the general POSIX guidelines for options specify separating options from arguments. This is not mandatory, only a guideline. I believe the principle of least astonishment (or surprise) justifies this change in GHCi (see http://www.faqs.org/docs/artu/ch11s01.html).

Looking at compiler/main/DynFlags.hs the patch may be as simple as changing

, Flag "l" (AnySuffix (upd . addOptl))

to

, Flag "l" (hasArg addOptl)

which is the same code as Flag "optl". I haven't tested this.

comment:3 Changed 3 years ago by simonmar

  • Priority changed from normal to high

Agreed. Moving to high priority since it's easy and we don't want to forget.

comment:4 Changed 3 years ago by batterseapower

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.