| ... |
... |
@@ -58,9 +58,10 @@ Windows. |
|
58
|
58
|
Options overview
|
|
59
|
59
|
----------------
|
|
60
|
60
|
|
|
61
|
|
-GHC's behaviour is controlled by options, which for historical reasons
|
|
62
|
|
-are also sometimes referred to as command-line flags or arguments.
|
|
63
|
|
-Options can be specified in three ways:
|
|
|
61
|
+GHC's behaviour is controlled by options. Options can be specified in four ways:
|
|
|
62
|
+(1) directly on the command line; (2) via files (response files); (3) in source
|
|
|
63
|
+files, using a pragma; and (4) when using GHCi, from within GHCi.
|
|
|
64
|
+
|
|
64
|
65
|
|
|
65
|
66
|
Command-line arguments
|
|
66
|
67
|
~~~~~~~~~~~~~~~~~~~~~~
|
| ... |
... |
@@ -76,7 +77,8 @@ An invocation of GHC takes the following form: |
|
76
|
77
|
|
|
77
|
78
|
ghc [argument...]
|
|
78
|
79
|
|
|
79
|
|
-Command-line arguments are either options or file names.
|
|
|
80
|
+Command-line arguments are either options, file names or response file arguments
|
|
|
81
|
+(see further below).
|
|
80
|
82
|
|
|
81
|
83
|
Command-line options begin with ``-``. They may *not* be grouped:
|
|
82
|
84
|
``-vO`` is different from ``-v -O``. Options need not precede filenames:
|
| ... |
... |
@@ -111,16 +113,47 @@ to the files ``Foo.hs`` and ``Bar.hs``. |
|
111
|
113
|
Command-line arguments in response files
|
|
112
|
114
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
113
|
115
|
|
|
114
|
|
-In addition to passing arguments via the command-line, arguments can be passed
|
|
115
|
|
-via GNU-style response files. For instance,
|
|
|
116
|
+GHC's use of response files is similar to that of GCC. A response file argument
|
|
|
117
|
+is ``@`` followed immediately by the absolute or relative path identifying the
|
|
|
118
|
+response file.
|
|
|
119
|
+
|
|
|
120
|
+.. note::
|
|
|
121
|
+
|
|
|
122
|
+ In PowerShell, ``@`` is used to identify a splatting variable. Consequently,
|
|
|
123
|
+ GHC response file arguments must be enclosed in quotation marks on the
|
|
|
124
|
+ command line to avoid parsing errors.
|
|
|
125
|
+
|
|
|
126
|
+A response file argument is equivalent to the command-line arguments in the
|
|
|
127
|
+response file in the order that they appear in the file. A response file can
|
|
|
128
|
+include a response file argument.
|
|
|
129
|
+
|
|
|
130
|
+In a response file:
|
|
|
131
|
+
|
|
|
132
|
+* any unescaped whitespace is assumed to separate command-line arguments and is
|
|
|
133
|
+ otherwise ignored;
|
|
|
134
|
+* a backslash character (``\``) always escapes the following character; and
|
|
|
135
|
+* matching pairs of unescaped single quote (``'``) or double quote (``"``)
|
|
|
136
|
+ characters escape blocks of characters.
|
|
|
137
|
+
|
|
|
138
|
+For example,
|
|
116
|
139
|
|
|
117
|
140
|
.. code-block:: bash
|
|
118
|
141
|
|
|
119
|
|
- $ cat response-file
|
|
|
142
|
+ $ cat response-file1
|
|
120
|
143
|
-O1
|
|
|
144
|
+ @response-file2
|
|
|
145
|
+
|
|
|
146
|
+ $ cat response-file2
|
|
121
|
147
|
Hello.hs
|
|
122
|
148
|
-o Hello
|
|
123
|
|
- $ ghc @response-file
|
|
|
149
|
+
|
|
|
150
|
+ $ ghc @response-file1
|
|
|
151
|
+
|
|
|
152
|
+is equivalent to,
|
|
|
153
|
+
|
|
|
154
|
+.. code-block:: bash
|
|
|
155
|
+
|
|
|
156
|
+ $ ghc -O1 Hello.hs -o Hello
|
|
124
|
157
|
|
|
125
|
158
|
.. _source-file-options:
|
|
126
|
159
|
|