what does the first m in -masm mean?

Viewed 268

I'm new to gcc, just a question on gcc -masm, I know that by using masm we can elect the (dis-)assembly dialect from ATT(default), to Intel. And -masm is a GNU option and has nothing to do with Microsoft's Macro Assembler (masm). But then what does the first m in -masm mean?

1 Answers

gcc has so many options that there needs to be a way to break them up into groups, if programmers are to have any chance of remembering the ones they need. This is done by using the first letter of the option to indicate the group it belongs to, and the rest to describe the specific option itself.

-m introduces a machine option: something that is specific to gcc's behavior when compiling for a particular machine. Your -masm= only makes sense for x86, since it selects between x86 assembly dialects. There are many other x86-specific options (-march=pentium to generate code that runs best on a Pentium, -mno-red-zone to change the "red zone" calling convention, etc) and many more for other architectures (-mthumb on ARM to select a particular instruction mode it has).

Some other groups worth knowing about:

  • -W for options to request warnings about various possible problems in your code: -Wuninitialized to get warnings about uninitialized variables, for instance.

    (Exception: -Wp, -Wa, -Wl aren't for warnings, but are used to "pass through" options to the preprocessor / assembler / linker respectively.)

  • -f to set flags that affect the parsing, optimization and code generation process, in a somewhat machine-independent way: -fstrength-reduce to request a particular optimization called "strength reduction", -fpic for position-independent code, etc.

  • -O for options that control the overall amount or priorities of optimization: -O0 for none, -O3 for lots, -Os to optimize for size, etc.

  • -g for options controlling debug information to be included in the generated object files.

  • -d for options that are meant to be used by compiler developers, that might dump information about the compilation process.

Related