PRU Options (Using the GNU Compiler Collection (GCC))

#### 3.20.40 PRU Options ¶

These command-line options are defined for PRU target:

`-minrt` ¶

  Link with a minimum runtime environment. This can significantly reduce the size of the final ELF binary, but some standard C runtime features are removed.

  This option disables support for static initializers and constructors. Beware that the compiler could still generate code with static initializers and constructors. It is up to the programmer to ensure that the source program does not use those features.

  The minimal startup code does not pass `argc` and `argv` arguments to `main`, so the latter must be declared as `int main (void)`. This is already the norm for most firmware projects.

`-mmcu=mcu` ¶

  Specify the PRU hardware variant to use. A correspondingly-named spec file is loaded, passing the memory region sizes to the linker and defining hardware-specific C macros.

  Newlib provides only the `sim` spec, intended for running regression tests using a simulator. Specs for real hardware can be obtained by installing the GnuPruMcu package.

`-mno-relax` ¶

  Make GCC pass the `--no-relax` command-line option to the linker instead of the `--relax` option.

`-mloop` ¶
`-mno-loop`

  Allow (or do not allow) GCC to use the LOOP instruction.

`-mmul` ¶
`-mno-mul`

  Allow (or do not allow) GCC to use the PRU multiplier unit.

`-mfillzero` ¶
`-mno-fillzero`

  Allow (or do not allow) GCC to use the FILL and ZERO instructions.

`-mabi=variant` ¶

  Specify the ABI variant to output code for. `-mabi=ti` selects the unmodified TI ABI, while `-mabi=gnu` selects a GNU variant that copes more naturally with certain GCC assumptions. These are the differences:

  ‘`Function Pointer Size`’

    TI ABI specifies that function (code) pointers are 16-bit, whereas GNU supports only 32-bit data and code pointers.

  ‘`Optional Return Value Pointer`’

    Function return values larger than 64 bits are passed by using a hidden pointer as the first argument of the function. TI ABI, though, mandates that the pointer can be NULL in case the caller is not using the returned value. GNU always passes and expects a valid return value pointer.

  ‘`Size Of Struct Containing Bit-fields`’

    TI ABI mandates that struct size is determined by the bit-field type, if it contains any. On the other hand, GNU allocates the smallest amount of bytes which would fit the bit-field.

    For example, TI ABI reserves 4 bytes for this struct, whereas GNU reserves a single byte:

        struct S { int i:1; };

  ‘`Access Size For Volatile Bit-fields`’

    TI ABI mandates that volatile bit-fields are accessed using their type. In contrast, GNU ABI uses the smallest integer type fitting the bit-field.

    For example, TI ABI requires a single load of 4 bytes for the following bit-field. GNU generates a load of 1 byte:

        struct S { volatile int i:1; };

  The current `-mabi=ti` implementation simply raises a compile error when any of the above code constructs is detected. As a consequence the standard C library cannot be built and it is omitted when linking with `-mabi=ti`.

  Relaxation is a GNU feature and for safety reasons is disabled when using `-mabi=ti`. The TI toolchain does not emit relocations for QBBx instructions, so the GNU linker cannot adjust them when shortening adjacent LDI32 pseudo instructions.