Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the -f and -m in gcc/clang compiler options stand for

Tags:

gcc

Summary: What do the -f and -m in gcc and clang compiler options stand for?

Details:

When using clang I've noticed that many compiler options start with -f and others start with -m. I assume that there is some historical reason for this and I was curious so I looked at the gcc help and saw the following:

Options starting with -g, -f, -m, -O, -W, or --param are automatically passed on to the various sub-processes invoked by gcc. In order to pass other options on to these processes the -W options must be used.

If I had to guess I think that -f might stand for frontend and -m for machine. But I'd be interested to hear a more comprehensive answer, possibly including the other sub-processes that gcc invokes.

like image 536
Gabriel Southern Avatar asked Apr 26 '13 01:04

Gabriel Southern


People also ask

What is GCC and Clang?

GCC is a mature compiler with support for many languages. As can be seen from the name Clang supports mostly C, C++, and Objective-C. But the framework underlying Clang called LLVM is extensible enough to support newer languages like Julia and Swift.

What GCC compiler stands for?

GCC stands for “GNU Compiler Collection”. GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Fortran, Ada, D, and Go.

What is G ++ and Clang?

gcc and g++ are the traditional GNU compilers for C and C++ code. Recently, clang (and clang++) using LLVM has been gaining popularity as an alternative compiler.


2 Answers

I don't have specific sources that state what 'f' and 'm' mean, but we can infer based on usage patterns found in documentation.

'f' stands for 'flag'.

Flags are on if specified via '-fFLAG' and off via '-fno-FLAG'

ex:

  -fpic         # flag to set position independent code 
  -fno-builtin  # don't recognize build in functions ... 

The technical definition is that 'f' defines "Control the interface conventions used in code generation".

Src: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html (e.g -fpci, when this flag is set)


'm' stands for mode. One general characteristic is that it sometimes has parameters. e.g
 -mabi=name   #abi mode = name
 -mcpu=cpu

Src: https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html (e.g ... when this mode...)

like image 60
Leo Ufimtsev Avatar answered Dec 18 '22 10:12

Leo Ufimtsev


According to gcc onlinedocs, options of the form -ffoo and -fno-foo stand for machine independent code generation conventions.

Examples: fpic, -fno-pic

-m options stand for machine dependent options.

eg: -mcpu, -march, -matomic

https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options

https://gcc.gnu.org/onlinedocs/gcc/Submodel-Options.html#Submodel-Options

like image 41
Mah35h Avatar answered Dec 18 '22 10:12

Mah35h