M2(1)

โœจ M2(1) from GNU โœจ

Okay bestie, this is the M2(1) page from the GNU manual, and it's all about gm2, the GNU Modula-2 Compiler ๐Ÿ’–๐Ÿฆ‹


๐ŸŒธ NAME ๐ŸŒธ

gm2 - The GNU Modula-2 Compiler ๐Ÿ‘‘

๐Ÿงš SYNOPSIS ๐Ÿงš

This one's empty in the original page, so there's nothing to see here ๐Ÿ™ˆ

๐Ÿ’… DESCRIPTION ๐Ÿ’…

This section is also blank in the original, so we're skipping straight to the good stuff โœจ

๐ŸŽ€ OPTIONS ๐ŸŽ€

okay so for any input file, the file name suffix decides what kind of compilation happens ๐Ÿ”ฅ these are the file types gm2 supports:

  • 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, definition modules are parsed whenever a program or implementation module needs them โœจ if your project uses a different extension, check out -fdef= ๐Ÿ’œ

You can specify more than one input file on the gm2 command line,

Now for the options, periodt ๐Ÿ’…โœจ

  • -g โ€” creates debugging info so debuggers like gdb can inspect and control the executable ๐Ÿ”๐Ÿฆ‹
  • -I โ€” sets the search path for definition and implementation modules ๐Ÿ—บ๏ธ for example: gm2 -g -c -I.:../../libs foo.mod. If you don't set this, the default path is the current directory followed by the right language dialect library directories ๐ŸŒธ
  • -fauto-init โ€” turns on auto initialization of pointers to NIL ๐Ÿงธ every time a block gets created, all the pointers declared in that scope get their addresses set to NIL ๐Ÿ’–
  • -fbounds โ€” turns on run time checks for subranges, array indexes, and indirection through a NIL pointer ๐Ÿ›ก๏ธ
  • -fcase โ€” compile time checking to see whether a CASE statement needs an ELSE clause when you didn't write one ๐Ÿ‘€
  • -fcpp โ€” preprocesses the source with cpp -lang-asm -traditional-cpp ๐Ÿงน For further details about these options, check the cpp docs ๐Ÿ“– If you pass -fcpp, every definition and implementation module that gets parsed will be preprocessed by cpp ๐Ÿซถ
  • -fdebug-builtins โ€” calls a real function instead of the builtin equivalent ๐Ÿ”Ž This is super handy for debugging the parameter values going into a builtin function, since you can single step into an intrinsic function ๐Ÿพ
  • -fdef= โ€” recognizes the suffix you give 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 ๐Ÿ’œ
  • -fdump-system-exports โ€” displays all inbuilt system items ๐Ÿงพ This one is an internal command line option, so it's more of a behind-the-scenes thing ๐Ÿ™ˆ
  • -fexceptions โ€” turns on exception handling code ๐ŸŽˆ It's on by default ๐Ÿ’… You can turn it off 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 the module importing that opaque type gets compiled ๐Ÿงฉ
  • -ffloatvalue โ€” turns on run time checking to see whether a floating point number is about to go out of range ๐Ÿ“ˆ
  • -fgen-module-list=filename โ€” tries to find all modules at link time and generates a module list ๐Ÿ“œ If the filename is -, the contents aren't written and the option is only used to force linking of all module ctors ๐Ÿซ  You can't use this option if -fuse-list= is enabled ๐Ÿšซ
  • -findex โ€” generates code to check whether array index values are out of bounds ๐Ÿ”ข You can disable it with -fno-index ๐Ÿ™…โ€โ™€๏ธ
  • -fiso โ€” turns on ISO standard features ๐ŸŒ Right now this enables the ISO SYSTEM module and changes the default library search path so the ISO libraries get searched before the PIM libraries ๐Ÿ“š It also changes how the DIV and MOD operators behave ๐Ÿงฎ
  • -flibs= โ€” modifies the default library search path ๐Ÿ›ค๏ธ The libraries you can pick are: m2pim, m2iso, m2min, m2log and m2cor ๐Ÿ’– These 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 several, separated by commas, and the first one in the list gets precedence ๐Ÿ‘‘ You don't need -flibs=m2pim or -flibs=m2iso if you also specify -fpim, -fpim2, -fpim3, -fpim4 or -fiso ๐Ÿซถ Unless you're using -flibs=m2min, you should include m2pim, because it provides the base modules that all the other dialects use ๐ŸŒธ The option -fno-libs=- stops the gm2 driver from touching the search and library paths ๐Ÿ™…โ€โ™€๏ธ
  • -static-libgm2 โ€” on systems that offer the m2 runtimes as both shared and static libraries, this forces the static version ๐Ÿชจ
  • -fm2-g โ€” makes debugging easier for new programmers ๐Ÿฃ The trade-off is that it may generate nop instructions, so you can single step precisely through all the code-related keywords ๐Ÿ‘ฃ For example, when a list of nested IF statements ends with several END keywords, those get mapped onto a sequence of nop instructions ๐Ÿฅฑ
  • -fm2-lower-case โ€” shows keywords in error messages in lower case ๐Ÿ”ค
  • -fm2-pathname= โ€” sets 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 -I option ๐Ÿ”
  • -fm2-plugin โ€” inserts a plugin that identifies run time errors at compile time ๐Ÿ•ต๏ธโ€โ™€๏ธ It's on by default โœ…
  • -fm2-prefix= โ€” sets the module mangled prefix name ๐Ÿช„ Every exported symbol from a definition module will get that prefix ๐Ÿ’œ
  • -fm2-statistics โ€” generates quadruple information ๐Ÿ“Š That's the number of quadruples generated, the number of quadruples left after optimization, and the number of source lines compiled ๐Ÿงฎ
  • -fm2-strict-type โ€” an experimental flag that turns on the new strict type checker ๐Ÿงช โš ๏ธ Still experimental, so use it with caution ๐Ÿ’€
  • -fm2-whole-program โ€” compiles all implementation modules and the program module all at once ๐Ÿƒโ€โ™€๏ธ๐Ÿ’จ
Be careful here, bestie! You need to take care if you're compiling different dialect modules, especially with negative operands to modulus ๐Ÿšจ But when you pair this option with -O3, it can deliver huge performance improvements ๐Ÿš€
  • -fmod= โ€” recognizes the suffix you give as implementation and module filenames ๐ŸŒท The default implementation and module filename suffix is .mod. If you use this option, GNU Modula-2 still falls back to that default when it needs to read an implementation module and the suffixed filename you gave doesn't exist ๐Ÿซถ
  • -fnil โ€” generates code to detect data access through a NIL value pointer ๐Ÿ•ณ๏ธ You can turn off dereference checking through a NIL pointer with -fno-nil ๐Ÿ™…โ€โ™€๏ธ
  • -fpim โ€” turns on PIM standard features ๐Ÿ“˜ Right now this enables the PIM SYSTEM module and decides which identifiers are pervasive (declared in the base module) ๐ŸŒ If you don't use any other -fpim[234] switch, division and modulus behave the way PIM4 defines them ๐Ÿงฎ
  • -fpim2 โ€” turns on PIM-2 standard features ๐Ÿ“— Right now this removes SIZE from being a pervasive identifier (declared in the base module) ๐Ÿ™…โ€โ™€๏ธ It moves SIZE into the SYSTEM module instead ๐Ÿ“ฆ It also changes how the DIV and MOD operators behave ๐Ÿงฎ
  • -fpim3 โ€” turns on PIM-3 standard features ๐Ÿ“™ Right now this only changes how the DIV and MOD operators behave ๐Ÿงฎ
  • -fpim4 โ€” turns on PIM-4 standard features ๐Ÿ“• Right now this only changes how the DIV and MOD operators behave ๐Ÿงฎ
  • -fpositive-mod-floor-div โ€” forces DIV and MOD to behave the way PIM4 defines them โœจ All modulus results come out positive, and division results get rounded to the floor ๐ŸŒธ
  • -fpthread โ€” links against the pthread library ๐Ÿงต It's on by default, and you can disable it with -fno-pthread ๐Ÿ™…โ€โ™€๏ธ GNU Modula-2 uses the GCC pthread libraries to implement coroutines, so check out the SYSTEM implementation module if you want the details ๐Ÿซถ
  • -frange โ€” generates code to check the assignment range, return value range, set range and constructor range ๐Ÿ“ You can disable range checking with -fno-range ๐Ÿ™…โ€โ™€๏ธ
  • -freturn โ€” generates code to check that functions always exit with a RETURN and don't just fall out the end ๐Ÿšช You can disable return checking with -fno-return ๐Ÿ™…โ€โ™€๏ธ
  • -fruntime-modules= โ€” takes a comma separated list that sets the run time modules and their order ๐Ÿงพ These modules get initialized first, 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 ๐Ÿง  Adding a long list of dependent modules won't change the size of the executable, it just states the initialization order in case they're needed ๐Ÿฆ‹
  • -fscaffold-dynamic โ€” makes sure gm2 generates a dynamic scaffold infrastructure when compiling implementation and program modules ๐Ÿ—๏ธ It's on by default ๐Ÿ’– Use -fno-scaffold-dynamic to turn it off, or pick -fno-scaffold-static instead ๐Ÿ”€
  • -fscaffold-c โ€” generates a C source scaffold for the module you're compiling right now ๐ŸŒฑ
  • -fscaffold-c++ โ€” generates a C++ source scaffold for the module you're compiling right now ๐Ÿ’œ
  • -fscaffold-main โ€” forces the generation of the main function ๐ŸŽฏ You don't need this if -c is omitted ๐Ÿ™ˆ
  • -fscaffold-static โ€” makes sure gm2 generates a static scaffold within the program module ๐Ÿงฑ The static scaffold is made of sequences of calls to all dependent module initialization and finalization procedures ๐Ÿ“ž It's really 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 all run time checks ๐Ÿ›ก๏ธโœจ This is the same as invoking GNU Modula-2 with -fnil -frange -findex -fwholevalue -fwholediv -fcase -freturn ๐Ÿ’…
  • -fsources โ€” displays the path to the source of each module ๐Ÿ—‚๏ธ You can use it at compile time to double check that the right definition module is being used ๐Ÿ”
  • -fswig โ€” generates a swig interface file ๐Ÿชถ
  • -funbounded-by-reference โ€” Okay bestie, this one is a speed boost for unbounded parameters ๐Ÿš€. It tries to pass non VAR unbounded parameters by reference, so the callee doesn't make its own implicit copy. GNU Modula-2 only does this if, inside the callee, the parameter is never written to, no address is calculated on the array, and it isn't passed as a VAR parameter. ngl, it's still possible to 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 the procedure, and write to that location through the address parameter. Chaotic ๐Ÿ’€
Due to the dangerous nature of this option, it is not enabled when the -O option is specified. Don't go looking for it under -O ๐Ÿ™ˆ
  • -fuse-list=filename โ€” Use the file filename to set the initialization order of modules, but only if -fscaffold-static is enabled ๐Ÿ—‚๏ธ. If -fscaffold-dynamic is enabled instead, this file is used to force linking of all module ctors ๐Ÿ”—. This option cannot be used if -fgen-module-list= is enabled.
  • -fwholediv โ€” Generates code that detects whole number division by zero and modulus by zero ๐Ÿงฎ. Bestie, that's a safety net โœจ.
  • -fwholevalue โ€” Generates code that detects whole number overflow and underflow ๐Ÿ“ˆ๐Ÿ“‰. No surprise numbers sneaking up on you ๐Ÿซถ.
  • -Wcase-enum โ€” Gives you a warning if a CASE statement selects on an enumerated type expression and it's missing one or more CASE labels ๐Ÿ‘€. If the CASE statement has a default ELSE clause, no warning is issued, so you're covered. The -Wall option turns this flag on for you ๐Ÿ’–.
  • -Wuninit-variable-checking โ€” Warns you if a variable gets used before it's initialized ๐Ÿซฃ. The checking only happens in the first basic block of each procedure. It doesn't check parameters, array types or set types, so those are on their own ๐Ÿ™ƒ.
  • -Wuninit-variable-checking=all,known,cond โ€” Same vibe of warning, but with more levels ๐ŸŽš๏ธ. The checking only happens in the first basic block of each procedure if known is specified. If cond or all is specified, the checking keeps going into conditional branches of the flow graph ๐ŸŒˆ. All checking stops when a procedure call is invoked or when the top of a loop is encountered ๐Ÿ›‘. The -Wall option turns this flag on with -Wuninit-variable-checking=known. Heads up that -Wuninit-variable-checking=all will increase compile time โณ.

๐Ÿ”— SEE ALSO ๐Ÿ”—


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) ๐Ÿฆ‹.

Okay that's the whole page, bestie ๐ŸŽ€ It's gcc-14 energy, dated 2024-04-12, and it's M2(1) forever ๐Ÿ’–๐ŸŒˆ

๐Ÿ“ฆ where this page comes from