M2(1)
π NAME π
okay so bestie, welcome to M2(1), the GNU manual page for gm2 β that's The GNU Modula-2 Compiler β¨ no cap, that's the whole name section, short and iconic.
π¦ SYNOPSIS π¦
the original page leaves this bit completely blank π so we're just gonna vibe here respectfully. Moving on.
π DESCRIPTION π
also blank in the original π it's giving "mysterious" and honestly? we respect the silence. The real tea is all down in OPTIONS, so let's go.
π OPTIONS π
okay so here's the thing bestie β for any given input file, the file name suffix is what decides what kind of compilation gets done. the vibes are entirely in the extension, periodt. These are the input file name kinds 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 get 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.
and you can specify more than one input file on the gm2 command line, π
-gβ creates debugging information so that debuggers such asgdbcan inspect and control the executable π. main character move for anyone who's ever wondered why their program is Like That.-Iβ used to specify the search path for definition and implementation modules. Example, for the visual learners:gm2 -g -c -I.:../../libs foo.mod. If this option isn't specified, the default path gets added, which consists of the current directory followed by the appropriate language dialect library directories πΈ.-fauto-initβ turns on auto initialization of pointers toNILπ. Whenever a block is created, all pointers declared within this scope will have their addresses assigned toNIL. rude of them to be usable otherwise tbh.-fboundsβ turns on run time subrange, array index and indirection viaNILpointer checking π₯.-fcaseβ turns on compile time checking to check whether aCASEstatement requires anELSEclause when one was not specified. she's nosy and we love that for her.-fcppβ preprocess the 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 prepossessed bycpp. (the original page really does say "prepossessed" and honestly bestie, she ate, we're keeping it exactly as written π)-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.-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-exceptionsand no references are made to the run time exception libraries.-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.-ffloatvalueβ turns on run time checking to check whether a floating point number is about to exceed range πΈ.-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.-findexβ generate code to check whether array index values are out of bounds. Array index checking can be disabled via-fno-indexπ .-fisoβ turn on ISO standard features β¨. Currently this enables the ISOSYSTEMmodule and alters the default library search path so that the ISO libraries are searched before the PIM libraries. It also effects the behavior ofDIVandMODoperators.-flibs=β modifies the default library search path. The libraries supplied are:m2pim,m2iso,m2min,m2logandm2corπ. 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=m2pimor-flibs=m2isoif you also specify-fpim,-fpim2,-fpim3,-fpim4or-fiso. Unless you are using-flibs=m2minyou should includem2pimas the they provide the base modules which all other dialects utilize. The option-fno-libs=-disables thegm2driver 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 π.-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-filteris 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-gimpleand-fdump-lang-quadon rules. rules must be a comma separated list which can take three forms: the full decl textual name of a procedure,[libname.]module.identor[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.WriteStringand-fm2-dump-filter=StrLib.mod:StrIO.WriteStringπ.-fm2-file-offset-bits=β force the typeSYSTEM.COFF_Tto be built using the specified number of bits. If this option is not used then default isCSSIZE_Tbits.-fm2-gβ improve the debugging experience for new programmers at the expense of generatingnopinstructions if necessary to ensure single stepping precision over all code related keywords π«Ά. An example of this is in termination of a list of nestedIFstatements where multipleENDkeywords are mapped onto a sequence ofnopinstructions.-fm2-lower-caseβ render keywords in error messages using lower case. she's chill like that π .-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-Ioption.-fm2-pathname-root=pathrootβ add search paths derived from the specified pathroot.-fm2-pathname-rootIβ for internal use only β¨: used by the driver to copy every user-fm2-pathname-root=facing option in order with all other-Ioptions.-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 π.-fm2-strict-typeβ experimental flag to turn on the new strict type checker π§ͺ. (experimental, bestie β that's not a cute nickname, that's a warning)-fm2-strict-type-reasonβ provides more detail why the types are incompatible π.-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 aNILvalue pointer π. Dereferencing checking through aNILpointer can be disabled by-fno-nil.-fpimβ turn on PIM standard features β¨. Currently this enables the PIMSYSTEMmodule 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 removesSIZEfrom being a pervasive identifier (declared in the base module). It placesSIZEin theSYSTEMmodule. It also effects the behavior ofDIVandMODoperators.-fpim3β turn on PIM-3 standard features β¨. Currently this only effects the behavior ofDIVandMODoperators.-fpim4β turn on PIM-4 standard features β¨. Currently this only effects the behavior ofDIVandMODoperators.-fpositive-mod-floor-divβ forces theDIVandMODoperators to behave as defined by PIM4 π₯. All modulus results are positive and the results from the division are rounded to the floor.-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 theSYSTEMimplementation 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 aRETURNand do not fall out at the end π«Ά. Return checking can be disabled via-fno-return.
still in the flags, bestie β the buffet continues π β¨
-fruntime-modules=β this one lets you specify, using a comma separated list, the run time modules and their order. These modules get 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. No cap.-fscaffold-dynamicβ this option ensures thatgm2will generate a dynamic scaffold infrastructure when compiling implementation and program modules. By default this option is on. Use-fno-scaffold-dynamicto turn it off or select-fno-scaffold-static.-fscaffold-cβ generate a C source scaffold for the current module being compiled. Cute.-fscaffold-c++β generate a C++ source scaffold for the current module being compiled. C++ bestie, we see you.-fscaffold-mainβ force the generation of themainfunction. This is not necessary if the-cis omitted.-fscaffold-staticβ this option ensures thatgm2will generate a static scaffold within the program module. The static scaffold consists of sequences of calls to all dependent module initialization and finalization procedures. The static scaffold is useful for debugging and single stepping the initialization blocks of implementation modules. Lowkey iconic for debugging.-fsharedβ generate a shared library from the module. Sharing is caring.-fsoft-check-allβ turns on all run time checks. This is the same as invoking GNU Modula-2 using the command options-fnil-frange-findex-fwholevalue-fwholediv-fcase-freturn. All the safety rails, bestie.-fsourcesβ displays the path to the source of each module. This option can be used at compile time to check the correct definition module is being used. Vibe check for modules.-fswigβ generate a swig interface file. Swiggy.-funbounded-by-referenceβ enable optimization of unbounded parameters by attempting to pass nonVARunbounded 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 aVARparameter. Note that it is possible to write code to break this optimization, therefore this option should be used 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. Due to the dangerous nature of this option it is not enabled when the-Ooption is specified.-fuse-list=filenameβ if-fscaffold-staticis enabled then use the file filename for the initialization order of modules. Whereas if-fscaffold-dynamicis enabled then use this file to force linking of all module ctors. This option cannot be used if-fgen-module-list=is enabled. So don't try to use both, bestie.-fwholedivβ generate code to detect whole number division by zero or modulus by zero. Math girlies stay safe.-fwholevalueβ generate code to detect whole number overflow and underflow. Protecting your numbers from the void.-Wcase-enumβ generate a warning if aCASEstatement selects on an enumerated type expression and the statement is missing one or moreCASElabels. No warning is issued if theCASEstatement has a defaultELSEclause. The option-Wallwill turn on this flag. Periodt.-Wuninit-variable-checkingβ issue 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 it's a first-block bestie, not a whole-program detective.-Wuninit-variable-checking=all,known,condβ issue a warning if a variable is used before it is initialized. The checking will only occur in the first basic block in each procedure ifknownis specified. Ifcondorallis 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-Wallwill turn on this flag with-Wuninit-variable-checking=known. The-Wuninit-variable-checking=allwill increase compile time. Choose your fighter wisely.-fwidesetβ turn on access to the runtime support library moduleM2WIDESET. By default this option is on. Wideset provision can be disabled by-fno-widesetand no reference will be made to the run timeM2WIDESETlibrary.
SEE ALSO π
gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc. Go read those too, bestie π
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; 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).
This page is from gcc-16, dated 2026-09-18, and it's the M2(1) man page β slay, you read the whole thing π
β¨
π¦ where this page comes from
- ubuntu stonking: gm2-16-powerpc-linux-gnu 16.2.0-3ubuntu1cross1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms