Skip to content

Commit a5240da

Browse files
author
Filip Jagodzinski
committed
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'".
1 parent f87a8e0 commit a5240da

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

tools/profiles/debug.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"GCC_ARM": {
3-
"common": ["-c", "-Wall", "-Wextra",
3+
"common": ["-Wall", "-Wextra",
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
77
"-MMD",
8-
"-fomit-frame-pointer", "-Og", "-g3", "-DMBED_DEBUG",
8+
"-fomit-frame-pointer", "-Og", "-DMBED_DEBUG",
99
"-DMBED_TRAP_ERRORS_ENABLED=1"],
10-
"asm": ["-x", "assembler-with-cpp"],
11-
"c": ["-std=gnu11"],
12-
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
10+
"asm": ["-c", "-g3", "-x", "assembler-with-cpp"],
11+
"c": ["-c", "-g3", "-std=gnu11"],
12+
"cxx": ["-c", "-g3", "-std=gnu++14", "-fno-rtti", "-Wvla"],
1313
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
1414
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1515
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",

tools/profiles/develop.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"GCC_ARM": {
3-
"common": ["-c", "-Wall", "-Wextra",
3+
"common": ["-Wall", "-Wextra",
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
77
"-MMD",
88
"-fomit-frame-pointer", "-Os", "-g", "-DMBED_TRAP_ERRORS_ENABLED=1"],
9-
"asm": ["-x", "assembler-with-cpp"],
10-
"c": ["-std=gnu11"],
11-
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
9+
"asm": ["-c", "-x", "assembler-with-cpp"],
10+
"c": ["-c", "-std=gnu11"],
11+
"cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"],
1212
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
1313
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1414
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",

tools/profiles/release.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"GCC_ARM": {
3-
"common": ["-c", "-Wall", "-Wextra",
3+
"common": ["-Wall", "-Wextra",
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
77
"-MMD",
88
"-fomit-frame-pointer", "-Os", "-flto", "-DNDEBUG", "-g"],
9-
"asm": ["-x", "assembler-with-cpp"],
10-
"c": ["-std=gnu11"],
11-
"cxx": ["-std=gnu++14", "-fno-rtti", "-Wvla"],
9+
"asm": ["-c", "-x", "assembler-with-cpp"],
10+
"c": ["-c", "-std=gnu11"],
11+
"cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"],
1212
"ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
1313
"-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
1414
"-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
15-
"-Wl,-n", "-Os", "-flto"]
15+
"-Wl,-n"]
1616
},
1717
"ARMC6": {
1818
"common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz",

tools/toolchains/gcc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
149149
self.cppc += self.flags['cxx'] + self.flags['common']
150150

151151
self.flags['ld'] += self.cpu
152-
self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld']
152+
self.ld = [join(tool_path, "arm-none-eabi-gcc")]
153+
self.ld += self.flags['ld'] + self.flags['common']
153154
self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc", "nosys"]
154155
self.preproc = [join(tool_path, "arm-none-eabi-cpp"), "-E", "-P"]
155156

0 commit comments

Comments
 (0)