M2(1)
π M2(1) β the GNU manual π
β¨ NAME β¨
okay bestie, gm2 is just the GNU Modula-2 Compiler π
the whole name, no notes π
β¨ SYNOPSIS β¨
β¨ DESCRIPTION β¨
β¨ OPTIONS β¨
okay so first things first π for every input file, the file name suffix decides what kind of compilation happens. these are the kinds gm2 knows about:
file.modβ Modula-2 implementation or program source files π¦ if your project uses a different source extension, check out-fmod=file.defβ Modula-2 definition module source files π these don't get compiled on their own. in GNU Modula-2 they get parsed as needed when program or implementation modules are compiled. if your project uses another extension, look at-fdef=πΈ
You can specify more than one input file on the gm2 command line,
-gβ make debugging info so debuggers likegdbcan inspect and control the executable π₯-Iβ the search path for definition and implementation modules π§ for example:gm2 -g -c -I.:../../libs foo.mod. if you don't specify this, the default path is the current directory followed by the right language dialect library directories β¨-fauto-initβ turns on auto initialization of pointers toNILπ«Ά whenever a block is created, every pointer declared in that scope gets its address assigned toNIL-fboundsβ turns on run time checking for subrange, array index and indirection viaNILpointers π-fcaseβ compile time checking to see whether aCASEstatement needs anELSEclause when you didn't specify one π-fcppβ okay this one preprocesses your source withcpp -lang-asm -traditional-cpp. For further details about these options If-fcppis supplied then all definition modules and implementation modules which are parsed will be preprocessed by cpp π-fdebug-builtinsβ calls a real function instead of the builtin equivalent π super useful for checking the parameter values going into a builtin, since you can single step right into an intrinsic function π¦-fdef=β recognize the specified suffix as a definition module filename β¨ the default implementation and module filename suffix is.def. If you use this option, GNU Modula-2 will still fall back to that default if a requested definition module isn't found π-fdump-system-exportsβ displays all inbuilt system items π this is an internal command line option, so it's more of a behind-the-scenes thing-fexceptionsβ turns on exception handling code π this one is on by default. You can disable it with-fno-exceptions, and then no references get made to the run time exception libraries-fextended-opaqueβ lets opaque types be implemented as any type π₯ this is a GNU Modula-2 extension, and it needs the implementation module that defines the opaque type to be available so it can be resolved when compiling the module that imports it-ffloatvalueβ turns on run time checking to see whether a floating point number is about to exceed its range πΈ-fgen-module-list=filenameβ tries to find all modules when linking and generates a module list π§ if the filename is-, then the contents aren't written and it's only used to force the linking of all module ctors. This option can't be used if-fuse-list=is enabled π ββοΈ-findexβ generates code to check whether array index values are out of bounds π you can turn array index checking off with-fno-index-fisoβ turns on ISO standard features π¦ right now this enables the ISOSYSTEMmodule and changes the default library search path so the ISO libraries get searched before the PIM libraries. It also affects how theDIVandMODoperators behave-flibs=β modifies the default library search path π the libraries you can supply arem2pim,m2iso,m2min,m2logandm2cor. These map onto the Programming in Modula-2 base libraries, ISO standard libraries, minimal library support, the Logitech compatible library, and Programming in Modula-2 with coroutines. You can specify multiple libraries, comma separated, and precedence goes to the first one in the list. You don't need-flibs=m2pimor-flibs=m2isoif you also specify-fpim,-fpim2,-fpim3,-fpim4or-fiso. Unless you're using-flibs=m2min, you should includem2pim, since it provides the base modules all the other dialects use π«Ά and-fno-libs=-stops thegm2driver from touching the search and library paths-static-libgm2β on systems that ship the m2 runtimes as both shared and static libraries, this forces the static version π₯-fm2-debug-trace=β turns on trace debugging with a comma separated list:line,token,quad,allπ this is an internal command line option-fm2-dump=β enables dumping of the modula-2 internal representation of data structures using a comma separated list π the list can containquad,gimple,decl,all-fm2-dump-decl=filestemβ dumps the modula-2 representation of a symbol to the filestem you specify π this only takes effect if-fm2-dump-filteris specified-fm2-dump-gimple=filestemβ dumps the modula-2 gimple representation to the filestem you specify π§-fm2-dump-quad=filestemβ dumps the quadruple representation to the filestem you specify π¦-fm2-dump-filter=rulesβ filters the language dumps-fdump-lang-decl,-fdump-lang-gimpleand-fdump-lang-quadon rules πruleshas to be a comma separated list, and it 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. Right now it only filters on procedure names, and regexp matching isn't implemented π three examples following the forms above:-fm2-dump-filter=_M2_hello_init,-fm2-dump-filter=m2pim.StrIO.WriteStringand-fm2-dump-filter=StrLib.mod:StrIO.WriteString-fm2-file-offset-bits=β forces the typeSYSTEM.COFF_Tto be built with the number of bits you specify β¨ if you don't use this option, the default isCSSIZE_Tbits-fm2-gβ makes the debugging experience better for new programmers π the tradeoff is thatnopinstructions may be generated when needed, so single stepping is precise over all code related keywords. For example, when a list of nestedIFstatements ends with severalENDkeywords, those get mapped onto a sequence ofnopinstructions π-fm2-lower-caseβ renders keywords in error messages in lower case πΈ-fm2-pathname=β specifies the module mangled prefix name for all modules in the include paths that follow π§-fm2-pathnameIβ for internal use only π the driver uses it to copy the user facing-Ioption-fm2-pathname-root=pathrootβ adds search paths derived from the specifiedpathrootπ«Ά-fm2-pathname-rootIβ for internal use only π the driver uses it to copy every user-fm2-pathname-root=facing option, in order, along with all the other-Ioptions π
okay that's the first half of the options, bestie π¦
-fruntime-modules=β β¨ Give this a comma-separated list and you decide which run time modules come first and in what order. They get initialized before any other modules in the application dependency. By default the list is"m2iso:RTentity,m2iso:Storage,m2iso:SYSTEM," "m2iso:M2RTS,m2iso:RTExceptions,m2iso:IOLink". These modules only get linked into your executable if they're actually required, so a long list won't make your executable bigger. It only sets the initialization order for when they're needed π§-fscaffold-dynamicβ π This makes gm2 generate a dynamic scaffold when it compiles implementation and program modules. It's on by default. Use-fno-scaffold-dynamicto turn it off, or pick-fno-scaffold-staticinstead.-fscaffold-cβ πΈ Generates a C source scaffold for the module you're currently compiling.-fscaffold-c++β π¦ Generates a C++ source scaffold for the module you're currently compiling.-fscaffold-mainβ π Forces themainfunction to be generated. You don't need this if-cis left out.-fscaffold-staticβ π Makes gm2 generate a static scaffold inside the program module. That scaffold is a sequence of calls to every dependent module's initialization and finalization procedures. It's super useful for debugging and single stepping through the initialization blocks of implementation modules π₯-fsharedβ π Generates a shared library from the module.-fsoft-check-allβ π Turns on every run time check. It's the same as invoking GNU Modula-2 with-fnil-frange-findex-fwholevalue-fwholediv-fcase-freturn.-fsourcesβ π Shows the path to the source of each module. You can use this at compile time to double-check you're using the right definition module π«Ά-fswigβ π§ Generates a swig interface file.-funbounded-by-referenceβ π₯ This turns on an optimization for unbounded parameters. It tries to pass nonVARunbounded parameters by reference, which skips the implicit copy inside the callee procedure. GNU Modula-2 only lets unbounded parameters go by reference if, inside the callee, they aren't written to, no address is calculated on the array, and they aren't passed as aVARparameter. You can still write code that breaks this optimization, so use it carefully. For example, you could take the address of an array, pass both the address and the array to a procedure, read from the array inside that procedure, and write to the location through the address parameter.
β οΈ Bestie, this one is dangerous! Because of that, it is not enabled when the -O option is specified.
-fuse-list=filenameβ π If-fscaffold-staticis enabled, this uses the filefilenamefor the initialization order of modules. If-fscaffold-dynamicis enabled instead, the file is used to force linking of all module ctors. You can't use this option if-fgen-module-list=is enabled π-fwholedivβ β Generates code that detects whole number division by zero and modulus by zero.-fwholevalueβ π’ Generates code that detects whole number overflow and underflow.-Wcase-enumβ β οΈ Gives you a warning if aCASEstatement selects on an enumerated type expression and is missing one or moreCASElabels. If theCASEstatement has a defaultELSEclause, no warning is issued. The-Walloption turns this flag on too π-Wuninit-variable-checkingβ π Gives you a warning if a variable gets used before it's initialized. The checking only happens in the first basic block in each procedure. It doesn't check parameters, array types, or set types.-Wuninit-variable-checking=all,known,condβ π Gives you a warning if a variable gets used before it's initialized. Checking only happens in the first basic block in each procedure ifknownis specified. Ifcondorallis specified, checking keeps going into conditional branches of the flow graph. All checking stops when a procedure call is invoked or the top of a loop is encountered. The-Walloption turns this on with-Wuninit-variable-checking=known. Using-Wuninit-variable-checking=allwill increase compile time π’-fwidesetβ π Turns on access to the run time support library moduleM2WIDESET. It's on by default. You can disable wideset support with-fno-wideset, and then there will be no reference to the run timeM2WIDESETlibrary.
β¨ SEE ALSO β¨
gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc π
π COPYRIGHT π
Copyright (c) 1999-2026 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. There are 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) π
That's the whole page, bestie! π¦ Source: gcc-16, dated 2026-03-22, M2(1) π Stay iconic! π β¨
π¦ where this page comes from
- ubuntu resolute: gm2-16-s390x-linux-gnu 16-20260322-1ubuntu1cross1
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms