M2(1)

πŸ“¦
version 15.3.0 Β· 3 versions
, in ubuntu stonking

πŸ‘‘ M2(1) β€” the GNU Modula-2 compiler πŸ’–

okay so real talk, this is the manual page for gm2, the GNU Modula-2 compiler, from the GNU fam. It's manual page M2(1) in section 1 (the "user commands" girlies) and it's giving long, so buckle up bestie, we're doing this in parts 🌸


✨ NAME ✨

gm2 β€” The GNU Modula-2 Compiler 🧚


πŸ’« SYNOPSIS πŸ’«

(bestie, this section is literally empty in the source. iconic of it. everything lives down in OPTIONS, keep scrolling 🫢)


πŸ¦‹ DESCRIPTION πŸ¦‹

(also empty up top in the original, no cap. the real tea is all in OPTIONS πŸ’…)


πŸ”₯ OPTIONS πŸ”₯

okay so first things first: for any given input file, the file name suffix decides what kind of compilation happens. it's giving ✨vibe check by extension✨. here are the input file names that are supported:

  • file.mod β€” Modula-2 implementation or program source files. πŸ’– peep the -fmod= option if you wanna compile a project that uses a different source file extension.
  • file.def β€” Modula-2 definition module source files. lowkey important: definition modules are not compiled separately. in GNU Modula-2, definition modules are parsed as required when program or implementation modules are compiled. πŸ¦‹ peep the -fdef= option if you wanna compile a project that uses a different source file extension.

also, you can specify more than one input file on the gm2 command line, so go off πŸ’…


now the flags, bestie. there are a LOT of them. hydrate, sit pretty, and let's go πŸ“

  • -g β€” create debugging information so that debuggers such as gdb can inspect and control the executable. it's giving main character debugging energy ✨
  • -I β€” used to specify the search path for definition and implementation modules. an example is:
gm2 -g -c -I.:../../libs foo.mod

If this option is not specified then the default path is added, which consists of the current directory followed by the appropriate language dialect library directories. πŸŽ€

  • -fauto-init β€” turns on auto initialization of pointers to NIL. whenever a block is created, all pointers declared within this scope will have their addresses assigned to NIL. so fresh, so clean 🧼
  • -fbounds β€” turns on run time subrange, array index and indirection via NIL pointer checking. πŸ’€ it WILL catch you.
  • -fcase β€” turns on compile time checking to check whether a CASE statement requires an ELSE clause when one was not specified. not me forgetting the ELSE πŸ™ˆ
  • -fcpp β€” preprocess the source with cpp -lang-asm -traditional-cpp. For further details about these options… If -fcpp is supplied then all definition modules and implementation modules which are parsed will be preprocessed by cpp. 🌈
  • -fdebug-builtins β€” call a real function, rather than the builtin equivalent. this can be useful for debugging parameter values to a builtin function as it allows users to single step code into an intrinsic function. soooo satisfying to step through ngl πŸ”₯
  • -fdef= β€” recognize the specified suffix as a definition module filename. the default implementation and module filename suffix is .def. If this option is used, GNU Modula-2 will still fall back to this default if a requested definition module is not found. 🫢
  • -fdump-system-exports β€” display all inbuilt system items. this is an internal command line option. 🀫
  • -fexceptions β€” turn on exception handling code. By default this option is on. Exception handling can be disabled by -fno-exceptions, and no references are made to the run time exception libraries. 😭 (crying but in an exception-handled way)
  • -fextended-opaque β€” allows opaque types to be implemented as any type. this is a GNU Modula-2 extension ✨ and it requires that the implementation module defining the opaque type is available so that it can be resolved when compiling the module which imports the opaque type. it's giving transparency issues πŸ’…
  • -ffloatvalue β€” turns on run time checking to check whether a floating point number is about to exceed range. floaties get caught too πŸ¦‹
  • -fgen-module-list=filename β€” attempt to find all modules when linking and generate a module list. If the filename is - then the contents are not written and only used to force the linking of all module ctors. ⚠️ This option cannot be used if -fuse-list= is enabled. pick a lane bestie
  • -findex β€” generate code to check whether array index values are out of bounds. Array index checking can be disabled via -fno-index. out of bounds? not on my watch 🚫
  • -fiso β€” turn on ISO standard features. Currently this enables the ISO SYSTEM module and alters the default library search path so that the ISO libraries are searched before the PIM libraries. It also effects the behavior of DIV and MOD operators. πŸ‘‘ ISO girlies rise
  • -flibs= β€” modifies the default library search path. the libraries supplied are: m2pim, m2iso, m2min, m2log and m2cor. these map onto the Programming in Modula-2 base libraries, ISO standard libraries, minimal library support, Logitech compatible library and Programming in Modula-2 with coroutines. Multiple libraries can be specified and are comma separated, with precedence going to the first in the list. it is not necessary to use -flibs=m2pim or -flibs=m2iso if you also specify -fpim, -fpim2, -fpim3, -fpim4 or -fiso. Unless you are using -flibs=m2min you should include m2pim as they provide the base modules which all other dialects utilize. The option -fno-libs=- disables the gm2 driver from modifying the search and library paths. πŸŽ€
  • -static-libgm2 β€” on systems that provide the m2 runtimes as both shared and static libraries, this option forces the use of the static version. commitment issues? solved πŸ’…
  • -fm2-debug-trace= β€” turn on trace debugging using a comma separated list: line,token,quad,all. This is an internal command line option. 🀫
  • -fm2-dump= β€” enable dumping of modula-2 internal representation of data structures using a comma separated list. the list can contain: quad,gimple,decl,all. πŸ“¦
  • -fm2-dump-decl=filestem β€” dump the modula-2 representation of a symbol to the filestem specified. ⚠️ This option only takes effect if the -fm2-dump-filter is specified.
  • -fm2-dump-gimple=filestem β€” dump modula-2 gimple representation to the filestem specified. 🌸
  • -fm2-dump-quad=filestem β€” dump quadruple representation to the filestem specified. πŸ”’
  • -fm2-dump-filter=rules β€” filter the language dumps -fdump-lang-decl, -fdump-lang-gimple and -fdump-lang-quad on rules. rules must be a comma separated list which can take three forms: the full decl textual name of a procedure, [libname.]module.ident or [filename:]module.ident. This is an internal command line option. Currently it only filters on procedure names and regexp matching is not implemented. 😭 Three examples of its use following the previous forms could be:
-fm2-dump-filter=_M2_hello_init
-fm2-dump-filter=m2pim.StrIO.WriteString
-fm2-dump-filter=StrLib.mod:StrIO.WriteString
  • -fm2-file-offset-bits= β€” force the type SYSTEM.COFF_T to be built using the specified number of bits. If this option is not used then default is CSSIZE_T bits. πŸ“
  • -fm2-g β€” improve the debugging experience for new programmers at the expense of generating nop instructions if necessary to ensure single stepping precision over all code related keywords. an example of this is in termination of a list of nested IF statements where multiple END keywords are mapped onto a sequence of nop instructions. tiny nops, big kindness 🫢
  • -fm2-lower-case β€” render keywords in error messages using lower case. lowercase era πŸ’…
  • -fm2-pathname= β€” specify the module mangled prefix name for all modules in the following include paths. 🏷️
  • -fm2-pathnameI β€” for internal use only: used by the driver to copy the user facing -I option. 🀫
  • -fm2-plugin β€” insert plugin to identify run time errors at compile time (default on). ✨
  • -fm2-prefix= β€” specify the module mangled prefix name. All exported symbols from a definition module will have the prefix name. πŸ‘‘
  • -fm2-statistics β€” generates quadruple information: number of quadruples generated, number of quadruples remaining after optimization and number of source lines compiled. πŸ“Š the numbers girlies ate
  • -fm2-strict-type β€” experimental flag to turn on the new strict type checker. πŸ§ͺ handle with care bestie
  • -fm2-whole-program β€” compile all implementation modules and program module at once. ⚠️ Notice that you need to take care if you are compiling different dialect modules (particularly with the negative operands to modulus). But this option, when coupled together with -O3, can deliver huge performance improvements. πŸ”₯
  • -fmod= β€” recognize the specified suffix as implementation and module filenames. The default implementation and module filename suffix is .mod. If this option is used, GNU Modula-2 will still fall back to this default if it needs to read an implementation module and the specified suffixed filename does not exist. πŸ¦‹
  • -fnil β€” generate code to detect accessing data through a NIL value pointer. Dereferencing checking through a NIL pointer can be disabled by -fno-nil. πŸ’€ do NOT deref the void
  • -fpim β€” turn on PIM standard features. Currently this enables the PIM SYSTEM module and determines which identifiers are pervasive (declared in the base module). If no other -fpim[234] switch is used then division and modulus operators behave as defined in PIM4. πŸŽ€
  • -fpim2 β€” turn on PIM-2 standard features. Currently this removes SIZE from being a pervasive identifier (declared in the base module). It places SIZE in the SYSTEM module. It also effects the behavior of DIV and MOD operators. ✨
  • -fpim3 β€” turn on PIM-3 standard features. Currently this only effects the behavior of DIV and MOD operators. 🌸
  • -fpim4 β€” turn on PIM-4 standard features. Currently this only effects the behavior of DIV and MOD operators. πŸ’œ
  • -fpositive-mod-floor-div β€” forces the DIV and MOD operators to behave as defined by PIM4. All modulus results are positive and the results from the division are rounded to the floor. no negative vibes allowed 🚫✨
  • -fpthread β€” link against the pthread library. By default this option is on. It can be disabled by -fno-pthread. GNU Modula-2 uses the GCC pthread libraries to implement coroutines (see the SYSTEM implementation module). 🧡
  • -frange β€” generate code to check the assignment range, return value range set range and constructor range. Range checking can be disabled via -fno-range. πŸ“
  • -freturn β€” generate code to check that functions always exit with a RETURN and do not fall out at the end. Return checking can be disabled via -fno-return. πŸƒβ€β™€οΈ don't fall out bestie
  • -fruntime-modules= β€” specify, using a comma separated list, the run time modules and their order. These modules will be initialized first before any other modules in the application dependency. By default the run time modules list is set to:
m2iso:RTentity,m2iso:Storage,m2iso:SYSTEM,m2iso:M2RTS,m2iso:RTExceptions,m2iso:IOLink

Note that these modules will only be linked into your executable if they are required. Adding a long list of dependent modules will not effect the size of the executable β€” it merely states the initialization order should they be required. πŸ‘‘


part 1 done bestie, keep scrolling for more πŸ’–

  • -fscaffold-dynamic β€” bestie, this one tells gm2 to build out a dynamic scaffold infrastructure while it's compiling implementation modules and program modules. It's on by default okay?? If you wanna turn it off use -fno-scaffold-dynamic, or you can pick -fno-scaffold-static instead. πŸŽ€
  • -fscaffold-c β€” generates a C source scaffold for whichever module is being compiled rn. cute and useful.
  • -fscaffold-c++ β€” same vibe but it generates a C++ source scaffold for the module currently being compiled. ✨
  • -fscaffold-main β€” this forces the generation of the main function. and ngl you literally do not need it if -c is omitted. so like… keep that in mind πŸ’…
  • -fscaffold-static β€” makes gm2 generate a static scaffold inside the program module. What even is that? It's a bunch of sequences of calls to all the dependent module initialization and finalization procedures. The static scaffold is great for debugging and for single stepping through the initialization blocks of implementation modules. Obsessed tbh. πŸ¦‹
  • -fshared β€” generates a shared library from the module. periodt.
  • -fsoft-check-all β€” turns ON all the run time checks πŸ’€ and it's literally the same as invoking GNU Modula-2 with all these command options: -fnil -frange -findex -fwholevalue -fwholediv -fcase -freturn. that's the whole squad right there.
  • -fsources β€” displays the path to the source of each module. You can use this at compile time to check that the correct definition module is being used, iykyk. πŸ”
  • -fswig β€” generates a swig interface file. slay.
  • -funbounded-by-reference β€” enables optimization of unbounded parameters by attempting to pass non VAR unbounded parameters by reference. This optimization avoids the implicit copy inside the callee procedure. GNU Modula-2 will only allow unbounded parameters to be passed by reference if, inside the callee procedure, they are not written to, no address is calculated on the array and it is not passed as a VAR parameter.
⚠️ okay so listen β€” it is possible to write code that breaks this optimization, so you gotta use this option carefully. For example it would be possible to take the address of an array, pass the address and the array to a procedure, read from the array in the procedure and write to the location using the address parameter. sneaky behavior fr.

Due to the dangerous nature of this option it is not enabled when the -O option is specified. no cap.

  • -fuse-list=filename β€” if -fscaffold-static is enabled then use the file filename for the initialization order of modules. Whereas if -fscaffold-dynamic is enabled then use this file to force linking of all module ctors. 🫢 Heads up: this option cannot be used if -fgen-module-list= is enabled.
  • -fwholediv β€” generates code to detect whole number division by zero or modulus by zero. catch those problematics πŸ’€
  • -fwholevalue β€” generates code to detect whole number overflow and underflow. 🌈
  • -Wcase-enum β€” generates a warning if a CASE statement selects on an enumerated type expression and the statement is missing one or more CASE labels. No warning is issued if the CASE statement has a default ELSE clause. The option -Wall will turn on this flag. πŸ‘‘
  • -Wuninit-variable-checking β€” issues a warning if a variable is used before it is initialized. The checking only occurs in the first basic block in each procedure. It does not check parameters, array types or set types. so like, it's a vibe check but a limited one.
  • -Wuninit-variable-checking=all,known,cond β€” issues a warning if a variable is used before it is initialized. The checking will only occur in the first basic block in each procedure if known is specified. If cond or all is specified then checking continues into conditional branches of the flow graph. All checking will stop when a procedure call is invoked or the top of a loop is encountered. The option -Wall will turn on this flag with -Wuninit-variable-checking=known. The -Wuninit-variable-checking=all will increase compile time. 😭 (worth it tho)

🌸 SEE ALSO 🌸

gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc. the whole friend group fr fr πŸ’–


Copyright (c) 1999-2025 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the man page gfdl(7).


and that's a wrap bestie!! πŸŽ€βœ¨ this absolute icon of a man page goes out as gcc-15, dated 2026-09-15, and it lives under the name M2(1). go forth and compile slayfully πŸ’…πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from