M2(1)

✨ NAME ✨

Okay bestie, this is the GNU manual page for M2(1) 🌸 and the star of the show is gm2, the GNU Modula-2 Compiler πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

Nothing to see here, bestie πŸ«₯ this section is blank in the original page.

πŸ¦‹ DESCRIPTION πŸ¦‹

Same deal, this one is empty too πŸ™ˆ no notes!

πŸ‘‘ OPTIONS πŸ‘‘

Okay so this is the big one 😭 For any input file, the file name suffix decides what kind of compilation happens. These are the input file names that are supported:

  • file.mod β€” Modula-2 implementation or program source files. Using a different source file extension for your project? Check out the -fmod= option 🧚
  • file.def β€” Modula-2 definition module source files. These don't get compiled on their own, ngl πŸ’€ In GNU Modula-2, definition modules are parsed as needed when program or implementation modules are compiled. Different extension? See the -fdef= option.

You can specify more than one input file on the gm2 command line πŸ’…

  • -g β€” create debugging information so debuggers like gdb can inspect and control executables πŸ”
  • -I β€” used to set the search path for definition and implementation modules πŸ—ΊοΈ An example is gm2 -g -c -I.:../../libs foo.mod. If you don't specify this, the default path is the current directory followed by the appropriate language dialect library directories.
  • -fobject-path= β€” sets the path for objects during the linking stage 🧳 An example is gm2 -g -fobject-path=.:../../libs/O2 -I.:../../libs foo.mod. Pairing -I with -fobject-path= lets projects keep different styles of objects separate from their source. For example, you could compile implementation modules at different optimisation levels, with or without debugging, and keep them in separate directories. If -fobject-path= isn't specified, it's set internally using the path from -I. If -I isn't specified either, it uses the current directory. In every case, the appropriate language dialect library directories get tacked onto the end of the path.
  • -fdebug-builtins β€” call a real function instead of the builtin equivalent πŸ”§ This is super handy for debugging the parameter values passed to a builtin, since you can single step your code right into a real function.
  • -fdump-system-exports β€” display all inbuilt system items 🫣 This is an internal command line option.
  • -fswig β€” generate a swig interface file 🐍
  • -fshared β€” generate a shared library from the module πŸ“š
  • -fmakeinit β€” generate the start up C++ code for the module 🏁 A file called _m2_modulename.cpp gets created. This is an internal command line option.
  • -fruntime-modules= β€” specify, as a comma separated list, the runtime modules and their order 🧩 These modules get initialised first, before any other modules in the application dependency. By default the list is Storage,SYSTEM,M2RTS,RTExceptions,IOLink. Heads up: these modules only get linked into your executable if they're actually required. So a long list of dependent modules won't change the size of your executable. It just sets the initialisation order should they be needed.
  • -fnil β€” generate code to detect accessing data through a NIL pointer value 🚨
  • -fno-nil β€” do not generate that NIL pointer detection code πŸ™…
  • -fwholediv β€” generate code to detect whole number division by zero or modulus by zero βž—
  • -fno-wholediv β€” do not generate that division and modulus by zero detection code
  • -findex β€” generate code to check whether array index values are out of bounds πŸ“
  • -fno-index β€” do not generate that array index bounds checking code
  • -frange β€” generate code to check the assignment range, return value range, set range and constructor range 🎯
  • -fno-range β€” do not generate code to check the assignment range, return value range, set range and constructor range
  • -freturn β€” generate code to check that functions always exit with a RETURN and don't just fall out at the end πŸšͺ
  • -fcase β€” turns on compile time checking for whether a CASE statement needs an ELSE clause when one wasn't specified 🧐
  • -fsoft-check-all β€” turns on all runtime checks 🌈 This is the same as using -fnil -frange -findex -fwholediv -fcase -freturn together.
  • -fauto-init β€” turns on auto initialisation of pointers to NIL πŸͺ„ Whenever a block is created, every pointer declared within that scope has its address assigned to NIL.
  • -fno-exceptions β€” turns off all generation of exception handling code πŸ™ƒ No references are made to the runtime exception libraries.
  • -v β€” display all calls to subsidiary programs, such as the C preprocessor, the GNU Modula-2 linker and compiler πŸ“£
  • -fm2-statistics β€” generates quadruple information πŸ“Š That's the number of quadruples generated, the number remaining after optimisation, and the number of source lines compiled.
  • -fm2-whole-program β€” compile all implementation modules and the program module all at once πŸš€ Heads up: you need to take care if you're compiling different dialect modules (especially with negative operands to modulus) ⚠️ But when this is paired with -O3, it can deliver huge performance improvements 😀
  • -fm2-g β€” improves the debugging experience for new programmers πŸ§‘β€πŸŽ“ The trade-off is that nop instructions get generated where necessary, so single stepping is precise over all code related keywords. For example, ending a list of nested IF statements maps multiple END keywords onto a sequence of nop instructions.
  • -fm2-lower-case β€” render keywords in error messages using lower case πŸ”€
  • -fmakelist β€” only applicable when linking a program module πŸ“ The compiler generates a modulename.lst file that lists the initialisation order of all modules to be linked. The actual link does not happen. The GNU Modula-2 linker scans all IMPORTs, generates 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 .lst file is plain text and can be modified if needed. Once the .lst file exists, the compiler can use it to link your project via the -fuselist option. It has no effect if the -c option is present.
  • fno-pthread β€” do 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 file modulename.lst for the initialisation order of modules 🎯
  • -fcpp β€” preprocess the source with cpp -lang-asm -traditional-cpp 🧼 For further details about these options see. If -fcpp is supplied, then all definition modules and implementation modules that get parsed will be preprocessed by cpp.
  • -fiso β€” turns on ISO standard features 🌍 Currently this enables the ISO SYSTEM module and changes the default library search path so the ISO libraries are searched before the PIM libraries. It also affects the behaviour of the DIV and MOD operators. See
  • -fpim β€” turns on PIM standard features πŸ“˜ Currently this enables the PIM SYSTEM module 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. See
  • -fpim2 β€” turns on PIM-2 standard features πŸ“— Currently this removes SIZE from being a pervasive identifier (declared in the base module), and places SIZE in the SYSTEM module instead. It also affects the behaviour of the DIV and MOD operators. See
  • -fpim3 β€” turns on PIM-3 standard features πŸ“™ Currently this only affects the behaviour of the DIV and MOD operators. See
  • -fpim4 β€” turns on PIM-4 standard features πŸ“• Currently this only affects the behaviour of the DIV and MOD operators. See
  • -fpositive-mod-floor-div β€” forces the DIV and MOD operators to behave as defined by PIM4 πŸ’« All modulus results are positive, and division results are rounded to the floor. See
  • -flibs= β€” modifies the default library search path πŸ“š The libraries you can supply are m2pim, m2iso, m2min, m2log and m2cor:
    • m2pim β€” the Programming in Modula-2 base libraries
    • m2iso β€” the ISO standard libraries
    • m2min β€” minimal library support
    • m2log β€” the Logitech compatible library
    • m2cor β€” 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=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 🫢

  • -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 πŸ”Ž This can be used 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 -c option. It's used to see where the objects are located when linking occurs.
  • -fdef= β€” recognise 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.
  • -fmod= β€” okay so this one lets you pick the suffix GNU Modula-2 treats as implementation and module filenames πŸ’… The default is .mod. If you use this flag and the compiler needs to read an implementation module but your suffixed filename doesn't exist, it still falls back to .mod 🫢
  • -fxcode β€” every error and warning gets printed in the Xcode format, so everything shows up in that style ✨
  • -fonlylink β€” only links the Modula-2 application and skips compiling the program module first πŸŽ€
  • -funbounded-by-reference β€” this one is giving optimization πŸ‘‘ It tries to pass non VAR unbounded parameters by reference, which skips the implicit copy inside the callee procedure. The compiler only does this if, inside the callee, the parameter isn't written to, no address is calculated on the array, and it isn't passed as a VAR parameter. You can still write code that breaks the 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.
πŸ’€ Due to the dangerous nature of this option, it is not enabled when the -O option is specified.
  • -Wverbose-unbounded β€” tells you which non VAR unbounded parameters will be passed by reference πŸ” It only does anything if -funbounded-by-reference is also on the command line.
  • -Wstudents β€” a bad-style checker made for new Modula-2 users 🌸 It catches situations that could cause confusion and lead to mistakes, like 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 β€” the strict one 😀 It makes the compiler reject nested WITH statements that reference the same record type, and it doesn't allow multiple imports of the same item from a module. It also checks that procedure variables are written to before they're read, that variables aren't only written but also read, and that variables are declared and used. If the compiler finds a variable being read before it's written, it stops with a message. It also checks that FOR loop indices aren't used outside the end of the loop without being reset.
  • -Wpedantic-param-names β€” checks procedure parameter names in the definition module against their implementation module counterparts πŸ¦‹ This isn't required in ISO or PIM versions of Modula-2, but it can be super useful, as long as you're doing it on purpose.
  • -Wpedantic-cast β€” warns if the ISO system function is used and the size of the variable differs from the size of the type. This is legal in ISO Modula-2, but it can be dangerous 😬 Some people prefer VAL in these situations and save CAST for type changes on objects that are the same size.
  • -Wunused-variable β€” warns if a variable has been declared but never used 🧹
  • -Wunused-parameter β€” warns if a parameter has been declared but never used 🧹
  • -Wall β€” turns on all Modula-2 warnings, so you get the whole vibe check πŸ”₯

✨ ENVIRONMENT ✨

Nothing is listed in this section, bestie πŸ₯Ί

✨ SEE ALSO ✨

gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc πŸ“š


Copyright (c) 1999-2021 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). πŸ’œ

That's the whole page, bestie πŸ¦‹ Thanks for hanging with me through the gcc-12 flags, dated 2022-02-22 and filed under M2(1). Stay iconic πŸ’–βœ¨

πŸ“¦ where this page comes from