Skip to content

Commit 6d6b3e0

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.
1 parent 3953e9c commit 6d6b3e0

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

tools/profiles/debug.json

Lines changed: 4 additions & 4 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", "-fno-delete-null-pointer-checks",
88
"-fomit-frame-pointer", "-Og", "-g3", "-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", "-x", "assembler-with-cpp"],
11+
"c": ["-c", "-std=gnu11"],
12+
"cxx": ["-c", "-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", "-fno-delete-null-pointer-checks",
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", "-fno-delete-null-pointer-checks",
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
@@ -125,7 +125,8 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
125125
self.cppc += self.flags['cxx'] + self.flags['common']
126126

127127
self.flags['ld'] += self.cpu
128-
self.ld = [join(tool_path, "arm-none-eabi-gcc")] + self.flags['ld']
128+
self.ld = [join(tool_path, "arm-none-eabi-gcc")]
129+
self.ld += self.flags['ld'] + self.flags['common']
129130
self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc", "nosys"]
130131
self.preproc = [join(tool_path, "arm-none-eabi-cpp"), "-E", "-P"]
131132

0 commit comments

Comments
 (0)