Supplements‎ > ‎

Command Line Examples

GCC has hundreds of options. Some of the more common ones are summarized here. Most options are generic to GCC, but there are some Propeller specific options defined below.  For more in-depth explanations of these options, see the gcc.pdf document (also linked at the bottom of this page).  Note that there is a Propeller specific section 3.17.33.


In a command window, usually one will run the GCC compiler with a syntax like this:
 $ propeller-elf-gcc program.c
This will compile and link program to a default file called "a.out".  The $ sign is a common "prompt" seen in command windows. It says enter a command. So all commands described will have $ in front of them.Certain options give you control over what happens with Propeller GCC. For example -o and -Os:
 $ propeller-elf-gcc -Os -o program program.c
This compiles and links program.c to smallest possible program size to the file program.

Another example is -S:
 $ propeller-elf-gcc -Os -S program.c
This will generate an assembly source file from program.c
Another example is (-c):
 $ propeller-elf-gcc -Os -c program.c
This compiles program.c only without linking. This is good for when you have separate files containing library code.
One common way to compile and link a larger program having multiple files with one command would be like this:
 $ propeller-elf-gcc -Os -o program program.c somefile.c anotherfile.c
When linking a program with a library it is important to note that the library flag must be added after the .c files that need the library resource. The example below will work to bring in the floating point version of printf for math functions, but moving the -lm before calc.c will cause a run time error.
 $ propeller-elf-gcc -o calc.elf -Os -Wall calc.c -lm


Common GCC Optimization Options

Propeller GCC and the GCC family offers 5 different optimization options. The default optimization is no optimization at all -O0 (minus Oh Zero).
-O0
Reduce compilation time and make debugging produce the expected results. This is the default.
-O or -O1
Optimize (for size and speed). Optimizing compilation takes somewhat more time, and a lot more memory for a large function. With ‘-O’, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.
-O2
Optimize for speed. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to ‘-O’, this option increases both compilation time and the performance of the generated code.
-O3
Optimize yet more. This particular option has shown some minor failures in the GCC test suite for the Propeller port. The errors are considered non-fatal, but the results may cause problems. Use -O2 if you suspect a problem with -O3.
-Os
Optimize for size. This is probably the most desirable optimization for Propeller. ‘-Os’ enables all ‘-O2’ optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.

Propeller Specific GCC Compiler Options

These options are defined for the Parallax Propeller. The __PROPELLER__ or __propeller__ macros are generated when using Propeller-GCC.
-mcog
Generate code for COG model. In this model the code is placed in cog internal memory (which has only 2K). Data is placed in hub memory. This is the native execution mode, but is very restricted because of the small code size available. The macro __PROPELLER_COG__ will be defined when this option  is passed to the compiler.
-mlmm
Generate code for LMM (Large Memory Model). In this model both code and data are placed in hub. A small kernel runs in cog memory to fetch code and execute it. This is the default. __PROPELLER_COG__, __PROPELLER_XMM__, and __PROPELLER_XMMC__ are not defined by default.
-mxmmc
Generate code for XMMC (eXternal Memory Model – Code). In this model code is placed in external memory (flash or RAM) and data is placed in the hub. A kernel is run in cog memory to fetch instructions from the external memory.  The macro __PROPELLER_XMMC__ will be defined when this option is passed to the compiler.
-mxmm-single
Generate code for XMM-SINGLE model. In this model both code and data are placed in external memory like SRAM or SDRAM; only the stack remains in the hub memory. A kernel is run in cog memory to fetch instructions from the external memory. The macro __PROPELLER_XMM__ will be defined when this option is passed to the compiler.  The macro __PROPELLER_XMM__ will be defined when this option is passed to the compiler.
-mxmm-split
Generate code for XMM-SPLIT model. In this model both code and data are placed in external memory. Typically code is in Flash or other read-only memory, data is in SRAM, and stack remains in the hub memory. A kernel is run in cog memory to fetch instructions and data from the external memory.  The macro __PROPELLER_XMM__ will be defined when this option is passed to the compiler. 
-mfcache
Enable FastCache. This causes loops and small functions to be compiled so that they will be loaded into cog memory at run time, executing much faster.
-mno-fcache
Disable the LMM COG Fast Cache
-m32bit-doubles
Make the floating point double type 32 bits long. This is not compliant with the C standard, but does cause programs to execute much faster if the full 64 bit precision is not required.   The macro __PROPELLER_32BIT_DOUBLES__ will be defined when this option is passed to the compiler.
-m64bit-doubles
Make the double type be 64 bits long. This is the default.  The macro __PROPELLER_64BIT_DOUBLES__ is defined by default.


Common Propeller GCC Linker Options

These library options are available with Propeller GCC:
-lm
Link the math library. Required for floating point math at run time.
-lpthread
Link the pthread library. Required for using "pthread". The pthread library in a normal computer means POSIX threads. Propeller does not support POSIX threads. The pthread interface can be used to enable "N" threads to run in "M" COGs in LMM model programs. In XMM/C model programs all threads run on a single COG.
-lstdc++
Link the standard C++ library. Required for standard C++ features in the "std" namespace. C++ programs can be used without the standard C++ library on Propeller for simple programs to provide a non-dynamic object.method interface.
-lsupc++
Link the C++ support library. Required for some C++ features not covered by the standard C++ library. This library is not necessary for simple C++ programs.


Miscellaneous Options

-fno-rtti
Do not include run time type identification for C++.


Ċ
gcc.pdf
(3072k)
Steve Denson,
Jun 18, 2012, 1:54 AM
Comments