1M2(1) GNU M2(1)
2
3
4
6 gm2 - The GNU Modula-2 Compiler
7
11 For any given input file, the file name suffix determines what kind of
12 compilation is done. The following kinds of input file names are
13 supported:
14
15 file.mod
16 Modula-2 implementation or program source files. See the -fmod=
17 option if you wish to compile a project which uses a different
18 source file extension.
19
20 file.def
21 Modula-2 definition module source files. Definition modules are
22 not compiled separately, in GNU Modula-2 definition modules are
23 parsed as required when program or implementation modules are
24 compiled. See the -fdef= option if you wish to compile a project
25 which uses a different source file extension.
26
27 You can specify more than one input file on the gm2 command line,
28
29 "-g"
30 create debugging information so that debuggers such as gdb can
31 inspect and control executable.
32
33 "-I"
34 used to specify the search path for definition and implementation
35 modules. An example is: "gm2 -g -c -I.:../../libs foo.mod". If
36 this option is not specified then the default path is added which
37 consists of the current directory followed by the appropriate
38 language dialect library directories.
39
40 "-fauto-init"
41 turns on auto initialization of pointers to NIL. Whenever a block
42 is created all pointers declared within this scope will have their
43 addresses assigned to NIL.
44
45 "-fbounds"
46 turns on run time subrange, array index and indirection via "NIL"
47 pointer checking.
48
49 "-fcase"
50 turns on compile time checking to check whether a "CASE" statement
51 requires an "ELSE" clause when on was not specified.
52
53 "-fcpp"
54 preprocess the source with cpp -lang-asm -traditional-cpp For
55 further details about these options If -fcpp is supplied then all
56 definition modules and implementation modules which are parsed will
57 be prepossessed by cpp.
58
59 "-fdebug-builtins"
60 call a real function, rather than the builtin equivalent. This can
61 be useful for debugging parameter values to a builtin function as
62 it allows users to single step code into a real function.
63
64 "-fdef="
65 recognize the specified suffix as a definition module filename.
66 The default implementation and module filename suffix is .def. If
67 this option is used GNU Modula-2 will still fall back to this
68 default if a requested definition module is not found.
69
70 "-fdump-system-exports"
71 display all inbuilt system items. This is an internal command line
72 option.
73
74 "-fexceptions"
75 turn on exception handling code. By default this option is on.
76 Exception handling can be disabled by -fno-exceptions and no
77 references are made to the run time exception libraries.
78
79 "-fextended-opaque"
80 allows opaque types to be implemented as any type. This is a GNU
81 Modula-2 extension and it requires that the implementation module
82 defining the opaque type is available so that it can be resolved
83 when compiling the module which imports the opaque type.
84
85 "-ffloatvalue"
86 turns on run time checking to check whether a floating point number
87 is about to exceed range.
88
89 "-fgen-module-list=filename"
90 attempt to find all modules when linking and generate a module
91 list. If the filename is - then the contents are not written and
92 only used to force the linking of all module ctors. This option
93 cannot be used if -fuse-list= is enabled.
94
95 "-findex"
96 generate code to check whether array index values are out of
97 bounds. Array index checking can be disabled via -fno-index.
98
99 "-fiso"
100 turn on ISO standard features. Currently this enables the ISO
101 "SYSTEM" module and alters the default library search path so that
102 the ISO libraries are searched before the PIM libraries. It also
103 effects the behavior of "DIV" and "MOD" operators.
104
105 "-flibs="
106 modifies the default library search path. The libraries supplied
107 are: m2pim, m2iso, m2min, m2log and m2cor. These map onto the
108 Programming in Modula-2 base libraries, ISO standard libraries,
109 minimal library support, Logitech compatible library and
110 Programming in Modula-2 with coroutines. Multiple libraries can be
111 specified and are comma separated with precedence going to the
112 first in the list. It is not necessary to use -flibs=m2pim or
113 -flibs=m2iso if you also specify -fpim, -fpim2, -fpim3, -fpim4 or
114 -fiso. Unless you are using -flibs=m2min you should include m2pim
115 as the they provide the base modules which all other dialects
116 utilize. The option -fno-libs=- disables the gm2 driver from
117 modifying the search and library paths.
118
119 "-static-libgm2"
120 On systems that provide the m2 runtimes as both shared and static
121 libraries, this option forces the use of the static version.
122
123 "-fm2-g"
124 improve the debugging experience for new programmers at the expense
125 of generating "nop" instructions if necessary to ensure single
126 stepping precision over all code related keywords. An example of
127 this is in termination of a list of nested "IF" statements where
128 multiple "END" keywords are mapped onto a sequence of "nop"
129 instructions.
130
131 "-fm2-lower-case"
132 render keywords in error messages using lower case.
133
134 "-fm2-pathname="
135 specify the module mangled prefix name for all modules in the
136 following include paths.
137
138 "-fm2-pathnameI"
139 for internal use only: used by the driver to copy the user facing
140 -I option.
141
142 "-fm2-plugin"
143 insert plugin to identify run time errors at compile time (default
144 on).
145
146 "-fm2-prefix="
147 specify the module mangled prefix name. All exported symbols from
148 a definition module will have the prefix name.
149
150 "-fm2-statistics"
151 generates quadruple information: number of quadruples generated,
152 number of quadruples remaining after optimization and number of
153 source lines compiled.
154
155 "-fm2-strict-type"
156 experimental flag to turn on the new strict type checker.
157
158 "-fm2-whole-program"
159 compile all implementation modules and program module at once.
160 Notice that you need to take care if you are compiling different
161 dialect modules (particularly with the negative operands to
162 modulus). But this option, when coupled together with "-O3", can
163 deliver huge performance improvements.
164
165 "-fmod="
166 recognize the specified suffix as implementation and module
167 filenames. The default implementation and module filename suffix
168 is .mod. If this option is used GNU Modula-2 will still fall back
169 to this default if it needs to read an implementation module and
170 the specified suffixed filename does not exist.
171
172 "-fnil"
173 generate code to detect accessing data through a "NIL" value
174 pointer. Dereferencing checking through a "NIL" pointer can be
175 disabled by -fno-nil.
176
177 "-fpim"
178 turn on PIM standard features. Currently this enables the PIM
179 "SYSTEM" module and determines which identifiers are pervasive
180 (declared in the base module). If no other -fpim[234] switch is
181 used then division and modulus operators behave as defined in PIM4.
182
183 "-fpim2"
184 turn on PIM-2 standard features. Currently this removes "SIZE"
185 from being a pervasive identifier (declared in the base module).
186 It places "SIZE" in the "SYSTEM" module. It also effects the
187 behavior of "DIV" and "MOD" operators.
188
189 "-fpim3"
190 turn on PIM-3 standard features. Currently this only effects the
191 behavior of "DIV" and "MOD" operators.
192
193 "-fpim4"
194 turn on PIM-4 standard features. Currently this only effects the
195 behavior of "DIV" and "MOD" operators.
196
197 "-fpositive-mod-floor-div"
198 forces the "DIV" and "MOD" operators to behave as defined by PIM4.
199 All modulus results are positive and the results from the division
200 are rounded to the floor.
201
202 "-fpthread"
203 link against the pthread library. By default this option is on.
204 It can be disabled by -fno-pthread. GNU Modula-2 uses the GCC
205 pthread libraries to implement coroutines (see the SYSTEM
206 implementation module).
207
208 "-frange"
209 generate code to check the assignment range, return value range set
210 range and constructor range. Range checking can be disabled via
211 -fno-range.
212
213 "-freturn"
214 generate code to check that functions always exit with a "RETURN"
215 and do not fall out at the end. Return checking can be disabled
216 via -fno-return.
217
218 "-fruntime-modules="
219 specify, using a comma separated list, the run time modules and
220 their order. These modules will initialized first before any other
221 modules in the application dependency. By default the run time
222 modules list is set to "m2iso:RTentity,m2iso:Storage,m2iso:SYSTEM,"
223 "m2iso:M2RTS,m2iso:RTExceptions,m2iso:IOLink". Note that these
224 modules will only be linked into your executable if they are
225 required. Adding a long list of dependent modules will not effect
226 the size of the executable it merely states the initialization
227 order should they be required.
228
229 "-fscaffold-dynamic"
230 the option ensures that gm2 will generate a dynamic scaffold
231 infrastructure when compiling implementation and program modules.
232 By default this option is on. Use -fno-scaffold-dynamic to turn it
233 off or select -fno-scaffold-static.
234
235 "-fscaffold-c"
236 generate a C source scaffold for the current module being compiled.
237
238 "-fscaffold-c++"
239 generate a C++ source scaffold for the current module being
240 compiled.
241
242 "-fscaffold-main"
243 force the generation of the main function. This is not necessary
244 if the -c is omitted.
245
246 "-fscaffold-static"
247 the option ensures that gm2 will generate a static scaffold within
248 the program module. The static scaffold consists of sequences of
249 calls to all dependent module initialization and finalization
250 procedures. The static scaffold is useful for debugging and single
251 stepping the initialization blocks of implementation modules.
252
253 "-fshared"
254 generate a shared library from the module.
255
256 "-fsoft-check-all"
257 turns on all run time checks. This is the same as invoking GNU
258 Modula-2 using the command options "-fnil" "-frange" "-findex"
259 "-fwholevalue" "-fwholediv" "-fcase" "-freturn".
260
261 "-fsources"
262 displays the path to the source of each module. This option can be
263 used at compile time to check the correct definition module is
264 being used.
265
266 "-fswig"
267 generate a swig interface file.
268
269 "-funbounded-by-reference"
270 enable optimization of unbounded parameters by attempting to pass
271 non "VAR" unbounded parameters by reference. This optimization
272 avoids the implicit copy inside the callee procedure. GNU Modula-2
273 will only allow unbounded parameters to be passed by reference if,
274 inside the callee procedure, they are not written to, no address is
275 calculated on the array and it is not passed as a "VAR" parameter.
276 Note that it is possible to write code to break this optimization,
277 therefore this option should be used carefully. For example it
278 would be possible to take the address of an array, pass the address
279 and the array to a procedure, read from the array in the procedure
280 and write to the location using the address parameter.
281
282 Due to the dangerous nature of this option it is not enabled when
283 the -O option is specified.
284
285 "-fuse-list=filename"
286 if -fscaffold-static is enabled then use the file filename for the
287 initialization order of modules. Whereas if -fscaffold-dynamic is
288 enabled then use this file to force linking of all module ctors.
289 This option cannot be used if -fgen-module-list= is enabled.
290
291 "-fwholediv"
292 generate code to detect whole number division by zero or modulus by
293 zero.
294
295 "-fwholevalue"
296 generate code to detect whole number overflow and underflow.
297
298 "-Wcase-enum"
299 generate a warning if a "CASE" statement selects on an enumerated
300 type expression and the statement is missing one or more "CASE"
301 labels. No warning is issued if the "CASE" statement has a default
302 "ELSE" clause. The option -Wall will turn on this flag.
303
304 "-Wuninit-variable-checking"
305 issue a warning if a variable is used before it is initialized.
306 The checking only occurs in the first basic block in each
307 procedure. It does not check parameters, array types or set types.
308
309 "-Wuninit-variable-checking=all,known,cond"
310 issue a warning if a variable is used before it is initialized.
311 The checking will only occur in the first basic block in each
312 procedure if known is specified. If cond or all is specified then
313 checking continues into conditional branches of the flow graph.
314 All checking will stop when a procedure call is invoked or the top
315 of a loop is encountered. The option -Wall will turn on this flag
316 with -Wuninit-variable-checking=known. The
317 -Wuninit-variable-checking=all will increase compile time.
318
320 gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2
321 and gcc.
322
324 Copyright (c) 1999-2023 Free Software Foundation, Inc.
325
326 Permission is granted to copy, distribute and/or modify this document
327 under the terms of the GNU Free Documentation License, Version 1.3 or
328 any later version published by the Free Software Foundation; with no
329 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
330 copy of the license is included in the man page gfdl(7).
331
332
333
334gcc-13 2023-10-11 M2(1)