GM2(1)

πŸ“¦
version 10.5.0 Β· 2 versions
, in ubuntu noble

πŸ’– GM2(1) Β· GNU πŸ’–

✨ NAME ✨

gm2 - The GNU Modula-2 Compiler πŸ¦‹ okay so this is THE compiler for GNU Modula-2, bestie.

πŸŽ€ SYNOPSIS πŸŽ€

The source page leaves this section totally empty πŸ’€ so there's no synopsis to share, sorry bestie.

🌸 DESCRIPTION 🌸

Same deal here, this section is blank in the source πŸ™ˆ nothing to add.

✨ OPTIONS ✨

okay so the file name suffix is basically the main character here πŸ‘‘ whatever ending your input file has decides what kind of compilation happens. These are the input file names gm2 vibes with:

  • file.mod β€” Modula-2 implementation or program source files. If your project uses a different source file extension, check out -fmod= πŸ’…
  • file.def β€” Modula-2 definition module source files. These don't get compiled on their own πŸ₯Ί GNU Modula-2 parses them whenever a program or implementation module needs them while compiling. Using a different extension in your project? See -fdef= ✨

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

  • -g β€” creates debugging info so debuggers like gdb can inspect and control your executables πŸ”
  • -I β€” sets the search path for definition and implementation modules. Example: gm2 -g -c -I.:../../libs foo.mod. If you skip this one, the default path is the current directory followed by the right language dialect library directories πŸ—‚οΈ
  • -fobject-path= β€” sets the path for objects during the linking stage. Example: gm2 -g -fobject-path=.:../../libs/O2 -I.:../../libs foo.mod. Pairing -I with -fobject-path= lets you keep different styles of objects separate from their source files. Like, you could compile implementation modules at different optimization levels, with or without debugging, and stash them in separate directories 🧚 If -fobject-path= isn't specified, it gets set internally from the -I path. If -I wasn't specified either, it uses the current directory. Either way, the appropriate language dialect library directories get tacked onto the end of the path.
  • -fdebug-builtins β€” calls a real function instead of the builtin equivalent. This is super useful 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 one's 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, creating a file called _m2_modulename.cpp. Also an internal command line option πŸ”’
  • -fruntime-modules= β€” takes a comma separated list of the runtime modules and their order. These modules get initialized first, before any other modules in the application dependency. By default the list is Storage,SYSTEM,M2RTS,RTExceptions,IOLink. These modules only get linked into your executable if they're actually required, so a long list won't change the executable size. It just sets the initialisation order should they be needed πŸ“¦
  • -fnil β€” generates code to detect accessing data through a NIL value pointer πŸ›‘οΈ
  • -fno-nil β€” does NOT generate that NIL pointer check πŸ™…β€β™€οΈ
  • -fwholediv β€” generates code to detect whole number division by zero or modulus by zero βž—
  • -fno-wholediv β€” does NOT generate that division or modulus by zero check
  • -findex β€” generates code to check whether array index values are out of bounds πŸ“Š
  • -fno-index β€” does NOT generate that array index bounds check
  • -frange β€” generates code to check the assignment range, return value range, set range and constructor range 🎯
  • -fno-range β€” does NOT generate any of those range checks
  • -freturn β€” generates code to check that functions always exit with a RETURN and never just fall out at the end πŸ”š
  • -fcase β€” turns on compile time checking for whether a CASE statement needs an ELSE clause when you didn't specify one 🧐
  • -fsoft-check-all β€” turns on ALL the runtime checks at once πŸ”₯ It's the same as invoking GNU Modula-2 with -fnil -frange -findex -fwholediv -fcase -freturn.
  • -fauto-init β€” turns on auto initialization of pointers to NIL. Whenever a block gets 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 get made to the runtime exception libraries either 🚫
  • -v β€” displays all calls to subsidiary programs, like the C preprocessor and the GNU Modula-2 linker and compiler πŸ“£
  • -fm2-statistics β€” generates quadruple information: the number of quadruples generated, the number remaining after optimisation, and the number of source lines compiled πŸ“ˆ
  • -fm2-whole-program β€” compiles all implementation modules and the program module at once. Be careful if you're compiling different dialect modules, especially with negative operands to modulus πŸ‘€ But paired with -O3, this option can deliver huge performance improvements πŸš€
  • -fm2-g β€” improves the debugging experience for new programmers, at the expense of generating nop instructions if necessary. This makes sure single stepping is precise over all the code-related keywords. Like, when you end a list of nested IF statements, the multiple END keywords get mapped onto a sequence of nop instructions 🧸
  • -fm2-lower-case β€” renders keywords in error messages using lower case πŸ“
  • -fmakelist β€” only applies when linking a program module. The compiler generates a modulename.lst file containing a list of the initialisation order for all modules that are going 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, so you can modify it if you need to πŸ“ Once the .lst file exists, the compiler can link your project using the -fuselist option. It has no effect if the -c option is present.
  • -fmod= β€” okay so this one tells GM2 to treat your chosen suffix as the filename ending for implementation and module files πŸ’– The default suffix is .mod. If you use this flag, GM2 will still fall back to .mod when it needs to read an implementation module and your suffixed file isn't there πŸ¦‹
  • -fxcode β€” main character energy ✨ it makes every error and warning come out in the Xcode format πŸ’…
  • -fonlylink β€” lowkey the most chill option πŸ“ it only links your Modula-2 application and skips compiling the program module beforehand 🧚
  • -funbounded-by-reference β€” this one is a whole vibe πŸ”₯ it turns on an optimization that tries to pass non "VAR" unbounded parameters by reference, so the implicit copy inside the callee procedure is skipped 🌸 GM2 will only do this if, inside the callee, the parameter is never written to, no address is calculated on the array, and it isn't passed on as a "VAR" parameter πŸ™ˆ
⚠️ Be careful with this one, bestie. It's possible to write code that breaks this optimization, so use it with real care πŸ’€ 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 😭

Because it's so risky πŸ’€, this option is not enabled when the -O option is specified.

  • -Wverbose-unbounded β€” the tell-me-everything flag πŸŽ€ it informs you which non "VAR" unbounded parameters will be passed by reference 🫢 This only produces output if -funbounded-by-reference is also on the command line, so don't expect it to say anything without that buddy πŸ‘‘
  • -Wstudents β€” a little style check, iykyk ✨ it looks for bad programming style and is aimed at new Modula-2 users, since it catches situations that could cause confusion and mistakes 🧚 It checks whether variables with the same name are declared in different scopes, and whether variables look like keywords 🌈 Experienced users might find it a bit too aggressive, ngl πŸ˜…
  • -Wpedantic β€” the strict auntie of warnings πŸ’œ It forces the compiler to 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 being read, that variables aren't only written to but also read from, and that variables are declared and used πŸ”₯ If the compiler finds a variable being read before it's written, it will terminate 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 β€” name-matching energy 🌸 Procedure parameter names get checked in the definition module against their implementation module counterparts 🫢 This isn't needed in ISO or PIM versions of Modula-2, but it can be extremely useful, as long as you're intentionally writing code this way ✨
  • -Wpedantic-cast β€” this one has receipts 🧾 It warns if the ISO system function is used and the size of the variable is different from the size of the type πŸ‘€ This is legal in ISO Modula-2, but it can be dangerous 😬 Some users prefer using VAL in these situations and using CAST only for changes in type on objects that have the same size πŸ’…
  • -Wunused-variable β€” the clutter police 🧹 it warns if a variable has been declared and never used πŸ“
  • -Wunused-parameter β€” same energy, different target 🌿 it warns if a parameter has been declared and never used πŸ¦‹
  • -Wall β€” TURN ON EVERYTHING 🌈 this turns on all Modula-2 warnings, so get ready for a lot of feedback πŸ˜­πŸ‘‘

🧚 ENVIRONMENT 🧚

This section is totally empty, bestie 🫠 There's nothing in here for us to talk about πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹

Check these out for more info, they're giving πŸ“šβœ¨: gpl(7), gfdl(7), fsf-funding(7), gcc(1) and the Info entries for gm2 and gcc 🫢

Copyright (c) 1999-2020 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 πŸ“œ 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) πŸŽ€


Okay that's a wrap on GM2 πŸ’…βœ¨ Thanks for reading along, bestie, you did amazing 🫢 Love you, mwah πŸ’–πŸŒΈ

πŸ“¦ where this page comes from