M2(1)
๐ M2(1) ยท GNU ๐
okay so bestie, this is gm2, the GNU Modula-2 Compiler, and we're about to make Modula-2 make sense fr fr. no cap, this page is long, so it comes in 2 parts and this is part 1. more parts follow, so don't sign off yet ๐
โจ
โจ NAME โจ
gm2 โ The GNU Modula-2 Compiler ๐ฆ
๐ SYNOPSIS ๐
(the original leaves this blank in part 1, bestie โ no synopsis body yet, so we're moving straight to the good stuff)
๐ฆ DESCRIPTION ๐ฆ
(also blank in this part of the OG page โ the real action starts under OPTIONS)
๐ OPTIONS ๐
For any given input file, the file name suffix determines what kind of compilation is done. The following kinds of input file names are supported:
file.modโ Modula-2 implementation or program source files. See the-fmod=option if you wish to compile a project which uses a different source file extension.file.defโ Modula-2 definition module source files. Definition modules are not compiled separately, in GNU Modula-2 definition modules are parsed as required when program or implementation modules are compiled. See the-fdef=option if you wish to compile a project which uses a different source file extension.
You can specify more than one input file on the gm2 command line, bestie โ yes, plural files, go off. ๐ธ
-gโ create debugging information so that debuggers such asgdbcan inspect and control executable. ๐-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 toNIL. Whenever a block is created all pointers declared within this scope will have their addresses assigned toNIL. ๐ซถ-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 on was not specified. ๐-fcppโ preprocess the source withcpp -lang-asm -traditional-cppFor further details about these options If-fcppis supplied then all definition modules and implementation modules which are parsed will be prepossessed bycpp. ๐-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 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. ๐งฑ-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. ๐ก-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-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. ๐งช-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 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 aRETURNand do not fall out at the end. Return checking can be disabled via-fno-return. โฉ๏ธ-fruntime-modules=โ specify, using a comma separated list, the run time modules and their order. These modules will 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. โ๏ธ-fscaffold-dynamicโ the option ensures that gm2 will 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. ๐จ-fscaffold-c++โ generate a C++ source scaffold for the current module being compiled. โโ-fscaffold-mainโ force the generation of the main function. This is not necessary if the-cis omitted. ๐ฌ-fscaffold-staticโ the option ensures that gm2 will 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. ๐งฑ-fsharedโ generate a shared library from the module. ๐ค-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. โ-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. ๐-fswigโ generate a swig interface file. ๐-funbounded-by-referenceโ okay so this one enables optimization of unbounded parameters by attempting to pass non-VARunbounded parameters by reference. It's giving avoid the implicit copy inside the callee procedure energy. 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. But bestie, listen: it is possible to write code to break this optimization, so 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 -O option 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. ๐ซ-fwholedivโ generate code to detect whole number division by zero or modulus by zero. Slay, no more sneaky zeros. โจ-fwholevalueโ generate code to detect whole number overflow and underflow. Protect the vibes. ๐ก๏ธ-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. ๐-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. Lowkey limited but still iconic. ๐-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. ๐ข
๐ SEE ALSO ๐
Go read gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc. Bestie homework, but make it cute. ๐
๐ COPYRIGHT ๐
Copyright (c) 1999-2024 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).
๐ source/version: gcc-14 โข date: 2026-09-02 โข page: M2(1) โ periodt. ๐
๐ฆ where this page comes from
- ubuntu stonking: gm2-14-loongarch64-linux-gnu 14.4.0-2ubuntu1cross2
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms