psas / stm32

PSAS STM32F4xx firmware development.
30 stars 20 forks source link

Code Review Issue: gcc (cortex-m4) flags review #17

Closed kwilsonpdx closed 10 years ago

kwilsonpdx commented 10 years ago

It may be a valuable exercise to have a group review of all the complier and linker flags we have chosen to use for STM32 flight-_ applications.

Here is an example of some of the flags we are currently using during compile:

arm-none-eabi-gcc -c -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -Wno-main -ffunction-sections -fdata-sections -fno-common -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/lst/utils_hal.lst -DCORTEX_USE_FPU=FALSE -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/utils_hal.o.d -mthumb -DTHUMB ...

BartMassey commented 10 years ago

Aren't you using the STM32F4? Why would you have the epic FPU turned off?

kwilsonpdx commented 10 years ago

Aren't you using the STM32F4? Why would you have the epic FPU turned off?

PSAS development is a Traveling Carnival Of Wonder.

(I'll open an issue about turning the FPU ON)

ThirteenFish commented 10 years ago

For clarity the options have been broken out into sections:

Optimizations

The following are brought in by setting USE_LINK_GC to yes which seems to imply they're for link time garbage collection. On flight-rnh it reduced binaries by about 12% and I didn't need memstreams.c

Warnings

We can't use -std=c99 or -Wpedantic because ChibiOS makes heavy use of GCCs extensions to asm. -std=gnu99 should be used instead.

Debugging

-ggdb - like -g but with extra info for gdb specifically

Assembler Flags

-Wa,-alms=build/lst/

Arch

-mcpu=cortex-m4 -mno-thumb-interwork

ChibiOS Specific

-DCORTEX_USE_FPU=FALSE - When set to true mfloat-abi should be set to hard instead of softp like it is now -DTHUMB_PRESENT -DTHUMB_NO_INTERWORKING

Build

-MD -MP -MF .dep/build.d

TODO: Investigate what features newlib offers

Warnings that might be of interest

There are a large number of warning flags that for one reason or another aren't enabled by -Wall and -Wextra. This is a preliminary list of those that might be of interest. With some of them ChibiOS generates a large number of warnings so they're only really useful as a one off thing.

Other flags

ThirteenFish commented 10 years ago

There's always more flags to explore, but for the upcoming flight I think we're largely satisfied with the review that's already taken place. We can re-open this later.