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:This compiles and links program.c to smallest possible program size to the file program.
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 program.c
$ propeller-elf-gcc -Os -o program program.c
Another example is -S:
This will generate an assembly source file from program.c$ propeller-elf-gcc -Os -S program.c
Another example is (-c):
This compiles program.c only without linking. This is good for when you have separate files containing library code.$ propeller-elf-gcc -Os -c program.c
One common way to compile and link a larger program having multiple files with one command would be like this:
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 -Os -o program program.c somefile.c anotherfile.c
$ propeller-elf-gcc -o calc.elf -Os -Wall calc.c -lm
-O0Reduce compilation time and make debugging produce the expected results. This is the default.
-O or -O1Optimize (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.
-O2Optimize 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.
-O3Optimize 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.
-OsOptimize 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.
-mcogGenerate 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.
-mlmmGenerate 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.
-mxmmcGenerate 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-singleGenerate 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-splitGenerate 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.
-mfcacheEnable 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-fcacheDisable the LMM COG Fast Cache
-m32bit-doublesMake 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-doublesMake the double type be 64 bits long. This is the default. The macro __PROPELLER_64BIT_DOUBLES__ is defined by default.
-lmLink the math library. Required for floating point math at run time.
-lpthreadLink 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.