GM2(1)
๐ gm2: GM2(1) from the GNU manual ๐
manual name: GM2(1) ๐ธ
โจ NAME โจ
okay bestie, the whole NAME section is just gm2 - The GNU Modula-2 Compiler ๐. that's it, that's the compiler, and it's iconic ๐
โจ SYNOPSIS โจ
this section is blank on this page ๐ so the heading is all you get for now.
โจ DESCRIPTION โจ
also blank here ๐ nothing to see, moving on bestie.
โจ OPTIONS โจ
so the file name suffix you give gm2 decides what kind of compilation it does ๐
these are the input file kinds it supports:
๐ Input files
file.modโ Modula-2 implementation or program source files. if your project uses a different source file extension, check out the-fmod=option ๐ฆfile.defโ Modula-2 definition module source files. these aren't compiled on their own ๐ โโ๏ธ in GNU Modula-2, definition modules get parsed whenever a program or implementation module needs them. if your project uses a different source extension, see the-fdef=option ๐
you can throw more than one input file on the gm2 command line too โจ
๐๏ธ Options
-gโ debug info time! ๐ it creates debugging information so debuggers like gdb can inspect and control your executables ๐ง-Iโ sets the search path for definition and implementation modules ๐บ๏ธ for example:
gm2 -g -c -I.:../../libs foo.mod
if you don't pass -I, the default path is added: the current directory first, then the right language dialect library directories ๐
-fobject-path=โ sets the path for objects during the linking stage ๐งฑ for example:
gm2 -g -fobject-path=.:../../libs/O2 -I.:../../libs foo.mod
mixing -I and -fobject-path= keeps your objects separate from your source files, which is so organised ๐ซถ like you could compile implementation modules with different optimisation levels, with or without debugging, and stash each set in its own folder. if you skip -fobject-path=, it's set internally from whatever path -I gave. no -I either? then it uses the current directory. either way, the right language dialect library directories get tacked onto the end of the path ๐
-fdebug-builtinsโ calls a real function instead of the builtin equivalent ๐ง super handy for debugging parameter values passed to a builtin, since you can single step your code right into a real function ๐ช-fdump-system-exportsโ displays all inbuilt system items ๐งพ heads up, this is an internal command line option ๐-fswigโ generates a swig interface file ๐-fsharedโ generates a shared library from the module ๐-fmakeinitโ generates the start-up C++ code for the module, and a file called_m2_modulename.cppgets created ๐ ๏ธ also internal, so don't worry about it too much ๐-fruntime-modules=โ takes a comma separated list of the runtime modules and their order ๐ those modules get initialised first, before any other modules in the application dependency. the default list isStorage,SYSTEM,M2RTS,RTExceptions,IOLink๐ and here's the tea: these modules only get linked into your executable if they're actually needed. so a super long list won't make your executable bigger. it just sets the initialisation order, if they're needed ๐ซ-fnilโ generates code that detects accessing data through aNILvalue pointer ๐จ-fno-nilโ does NOT generate thatNILpointer check ๐ โโ๏ธ-fwholedivโ generates code that detects whole number division by zero or modulus by zero ๐งฎ-fno-wholedivโ does NOT generate that division or modulus by zero check ๐ โโ๏ธ-findexโ generates code that checks whether array index values are out of bounds ๐-fno-indexโ does NOT generate that array bounds check ๐ โโ๏ธ-frangeโ generates code that checks the assignment range, return value range, set range and constructor range ๐ฏ-fno-rangeโ does NOT check the assignment range, return value range, set range or constructor range ๐ โโ๏ธ-freturnโ generates code that checks functions always exit with aRETURNand don't just fall out at the end ๐-fcaseโ turns on compile time checking for whether aCASEstatement needs anELSEclause when you didn't specify one ๐-fsoft-check-allโ turns on all the runtime checks ๐ฅ it's the same as using-fnil-frange-findex-fwholediv-fcase-freturnall together ๐ฏ-fauto-initโ turns on auto initialisation of pointers to NIL ๐ whenever a block gets created, every pointer declared in that scope has its address set to NIL ๐ซถ-fno-exceptionsโ turns off all generation of exception handling code ๐ซ and nothing references the runtime exception libraries ๐-vโ displays all the calls to subsidiary programs, like the C preprocessor and the GNU Modula-2 linker and compiler ๐ต๏ธโโ๏ธ-fm2-statisticsโ generates quadruple information: how many quadruples were generated, how many are left after optimisation, and how many source lines got compiled ๐-fm2-whole-programโ compiles all implementation modules and the program module at once ๐ ngl be careful if you're compiling different dialect modules, especially with negative operands to modulus ๐ฌ but paired with-O3, this can deliver huge performance improvements โก-fm2-gโ makes debugging way nicer for new programmers ๐ the cost is that it may generatenopinstructions to keep single stepping precise over all the code related keywords. for example, when a list of nestedIFstatements ends, multipleENDkeywords get mapped onto a sequence ofnopinstructions ๐ซ-fm2-lower-caseโ renders keywords in error messages in lower case ๐ค-fmakelistโ only applies when linking a program module ๐งพ the compiler generates amodulename.lstfile that lists the initialisation order of all the modules being linked, and the actual link does NOT happen ๐ โโ๏ธ the GNU Modula-2 linker scans allIMPORTs, builds a list of dependencies, and produces an ordered list for initialisation. it'll probably get the order wrong if your project has cyclic dependencies ๐ญ but the.lstfile is plain text, so you can edit it if you need to ๐ once the.lstfile exists, the compiler can use it to link your project via the-fuselistoption. it has no effect if-cis present ๐fno-pthreadโ does not automatically link against the pthread library ๐งต this is likely useful if gm2 is configured as a cross compiler targeting embedded systems ๐ค by default, GNU Modula-2 uses the GCC pthread libraries to implement coroutines (see the SYSTEM implementation module) ๐ฆ-fuselistโ once gm2 has been told to link the program module, this option uses the filemodulename.lstfor the initialisation order of modules ๐-fcppโ preprocesses the source withcpp -lang-asm -traditional-cpp. for further details about these options, see. if-fcppis supplied, then every definition module and implementation module that gets parsed will be preprocessed by cpp ๐ง-fisoโ turns on ISO standard features ๐ right now this enables the ISOSYSTEMmodule, and it changes the default library search path so the ISO libraries are searched before the PIM libraries. it also affects the behaviour ofDIVandMODoperators. See-fpimโ turns on PIM standard features ๐ right now this enables the PIMSYSTEMmodule and decides which identifiers are pervasive (declared in the base module). if no other-fpim[234]switch is used, division and modulus operators behave as defined in PIM4. See-fpim2โ turns on PIM-2 standard features ๐ right now this removesSIZEfrom being a pervasive identifier (declared in the base module) and placesSIZEin theSYSTEMmodule instead. it also affects the behaviour ofDIVandMODoperators. See-fpim3โ turns on PIM-3 standard features ๐ right now this only affects the behaviour ofDIVandMODoperators. See-fpim4โ turns on PIM-4 standard features ๐ right now this only affects the behaviour ofDIVandMODoperators. See-fpositive-mod-floor-divโ forces theDIVandMODoperators to behave as defined by PIM4 ๐ all modulus results come out positive, and division results are rounded to the floor. See-flibs=โ modifies the default library search path ๐ the libraries you can supply arem2pim,m2iso,m2min,m2logandm2cor. those map onto: the Programming in Modula-2 base libraries, the ISO standard libraries, minimal library support, the Logitech compatible library, and Programming in Modula-2 with coroutines. you can list multiple libraries, comma separated, and the first one in the list gets precedence ๐ฅ 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, because it provides the base modules that all the other dialects use ๐ซถ-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 it can be resolved when compiling the module that imports the opaque type ๐-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 ๐-fmodulesโ displays the path to each module's object file ๐งฑ this option can only be invoked with the-coption, and it's used to see where the objects are when linking happens ๐-fdef=โ recognises 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 still falls back to that default when a requested definition module isn't found ๐ฆ-fmod=โ okay so this one lets you pick your own suffix ๐ for implementation and module filenames. The default is.mod, and if you use this flag, GNU Modula-2 will still fall back to.modwhen it needs an implementation module and your suffixed filename isn't there ๐-fxcodeโ makes every error and warning come out in the Xcode format ๐ปโจ-fonlylinkโ only links your Modula-2 app. It skips compiling the program module first ๐๐ธ-funbounded-by-referenceโ this one is a whole vibe ๐ฅ It turns on optimisation for unbounded parameters by trying to pass nonVARunbounded parameters by reference, which means the implicit copy inside the callee procedure gets skipped. GNU Modula-2 only lets an unbounded parameter go by reference if, inside the callee, it's never written to, no address gets calculated on the array, and it isn't passed as aVARparameter. You can still write code that breaks this optimisation, so be careful. For example, you could take the address of an array, pass both the address and the array into a procedure, read from the array in there, and then write to the location through the address parameter ๐
Heads up, bestie: this option is seriously risky ๐ Because of that, it is not enabled when the -O option is specified.
-Wverbose-unboundedโ tells you which nonVARunbounded parameters are going to be passed by reference ๐ It only shows anything if-funbounded-by-referenceis also on your command line.-Wstudentsโ a style check for bad programming habits ๐ It's made for new Modula-2 users, since it catches stuff that could cause confusion and then mistakes. It flags variables with the same name declared in different scopes, and variables that look like keywords. Experienced users might find it a bit too aggressive ๐ญ-Wpedanticโ forces the compiler to reject nestedWITHstatements that reference the same record type ๐ โโ๏ธ It also won't allow multiple imports of the same item from a module. On top of that, it checks that procedure variables are written to before they're read, that variables aren't only written to but also read from, and that variables are declared and used. If the compiler spots a variable being read before it's written, it stops and prints a message. It also checks thatFORloop indices aren't used outside the end of the loop without being reset first ๐-Wpedantic-param-namesโ checks procedure parameter names in the definition module against their counterparts in the implementation module ๐ง This isn't required in ISO or PIM versions of Modula-2, but it can be super useful, as long as your code is intentionally written that way โจ-Wpedantic-castโ warns if the ISO system function is used and the size of the variable is different from the size of the type ๐ซฃ It's legal in ISO Modula-2, but it can be dangerous. Some people prefer usingVALin these situations, and only usingCASTfor type changes on objects that are the same size ๐-Wunused-variableโ warns you if a variable is declared but never used ๐๏ธ-Wunused-parameterโ warns you if a parameter is declared but never used ๐๏ธ-Wallโ turns on all Modula-2 warnings at once ๐ฅ๐
๐ ENVIRONMENT ๐
This page doesn't list any environment variables, so there's nothing to see here, bestie ๐ซถ
๐ธ SEE ALSO ๐ธ
gpl(7),gfdl(7),fsf-funding(7),gcc(1)๐ฆ- The Info entries for
gm2andgcc๐
๐ฆ COPYRIGHT ๐ฆ
Copyright (c) 1999-2020 Free Software Foundation, Inc. ๐
Okay, so you're allowed to copy, distribute, and/or modify this document under 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) ๐
Bestie, that's the whole page ๐ This one's from gcc-10 and was last dated 2023-07-07. Go be a Modula-2 main character ๐โจ
๐ฆ where this page comes from
- ubuntu jammy: gm2-10-m68k-linux-gnu 10.5.0-1ubuntu1~22.04cross1
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms