GCC: Use 'common' flags at link time

According to GCC man:
To use the link-time optimizer, -flto and optimization options should be
specified at compile time and during the final link. It is recommended
that you compile all the files participating in the same link with the
same options and also specify those options at link time.

Additionally, move the '-g3' flag out of 'common' flags in the debug
profile. Although the '-g' is correctly ignored by the linker, the
'-glevel' is not and causes a build error "ld: unrecognized option
'-g3'".
pull/11856/head
Filip Jagodzinski 2019-11-12 15:32:55 +01:00
parent f87a8e0f52
commit a5240da3b4
4 changed files with 16 additions and 15 deletions

View File

@ -1,15 +1,15 @@
{
"GCC_ARM": {
"common": ["-c", "-Wall", "-Wextra",
"common": ["-Wall", "-Wextra",
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
"-fmessage-length=0", "-fno-exceptions",
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
"-MMD",
"-fomit-frame-pointer", "-Og", "-g3", "-DMBED_DEBUG",
"-fomit-frame-pointer", "-Og", "-DMBED_DEBUG",
"-DMBED_TRAP_ERRORS_ENABLED=1"],
"asm": ["-x", "assembler-with-cpp"],
"c": ["-std=gnu11"],
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
"asm": ["-c", "-g3", "-x", "assembler-with-cpp"],
"c": ["-c", "-g3", "-std=gnu11"],
"cxx": ["-c", "-g3", "-std=gnu++14", "-fno-rtti", "-Wvla"],
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",

View File

@ -1,14 +1,14 @@
{
"GCC_ARM": {
"common": ["-c", "-Wall", "-Wextra",
"common": ["-Wall", "-Wextra",
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
"-fmessage-length=0", "-fno-exceptions",
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
"-MMD",
"-fomit-frame-pointer", "-Os", "-g", "-DMBED_TRAP_ERRORS_ENABLED=1"],
"asm": ["-x", "assembler-with-cpp"],
"c": ["-std=gnu11"],
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
"asm": ["-c", "-x", "assembler-with-cpp"],
"c": ["-c", "-std=gnu11"],
"cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"],
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",

View File

@ -1,18 +1,18 @@
{
"GCC_ARM": {
"common": ["-c", "-Wall", "-Wextra",
"common": ["-Wall", "-Wextra",
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
"-fmessage-length=0", "-fno-exceptions",
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
"-MMD",
"-fomit-frame-pointer", "-Os", "-flto", "-DNDEBUG", "-g"],
"asm": ["-x", "assembler-with-cpp"],
"c": ["-std=gnu11"],
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
"asm": ["-c", "-x", "assembler-with-cpp"],
"c": ["-c", "-std=gnu11"],
"cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"],
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
"-Wl,-n", "-Os", "-flto"]
"-Wl,-n"]
},
"ARMC6": {
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz",

View File

@ -149,7 +149,8 @@ class GCC(mbedToolchain):
self.cppc += self.flags['cxx'] + self.flags['common']
self.flags['ld'] += self.cpu
self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld']
self.ld = [join(tool_path, "arm-none-eabi-gcc")]
self.ld += self.flags['ld'] + self.flags['common']
self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc", "nosys"]
self.preproc = [join(tool_path, "arm-none-eabi-cpp"), "-E", "-P"]