Skip to content

Commit 443240e

Browse files
authored
[cbuild2cmake] Fix linker lto flag (#307)
1 parent a1642da commit 443240e

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

pkg/maker/buildcontent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func (c *Cbuild) LinkerOptions() (linkerVars string, linkerOptions string) {
850850
if len(c.BuildDescType.Processor.Trustzone) > 0 {
851851
linkerOptions += "\n " + AddShellPrefix("${LD_SECURE}")
852852
}
853-
if c.LinkerLto {
853+
if c.LinkerLto || c.BuildDescType.Lto {
854854
linkerOptions += "\n " + AddShellPrefix("${LD_LTO}")
855855
}
856856
options := c.BuildDescType.Misc.Link

test/data/solutions/build-cpp/project/project.AC6+ARMCM55.cbuild.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build:
66
compiler: AC6
77
device: ARMCM55
88
device-pack: ARM::[email protected]
9+
link-time-optimize: true
910
processor:
1011
dsp: on
1112
fpu: dp

test/data/solutions/build-cpp/ref/project.AC6+ARMCM55/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ target_compile_options(${CONTEXT} PUBLIC
5757
$<$<COMPILE_LANGUAGE:C>:
5858
"SHELL:${CC_CPU}"
5959
"SHELL:${CC_FLAGS}"
60+
"SHELL:${CC_LTO}"
6061
"SHELL:-std=gnu11"
6162
"SHELL:-Wno-macro-redefined"
6263
"SHELL:-Wno-pragma-pack"
@@ -66,6 +67,7 @@ target_compile_options(${CONTEXT} PUBLIC
6667
$<$<COMPILE_LANGUAGE:CXX>:
6768
"SHELL:${CXX_CPU}"
6869
"SHELL:${CXX_FLAGS}"
70+
"SHELL:${CXX_LTO}"
6971
"SHELL:-Wno-macro-redefined"
7072
"SHELL:-Wno-pragma-pack"
7173
"SHELL:-Wno-parentheses-equality"
@@ -87,6 +89,7 @@ target_link_libraries(${CONTEXT} PUBLIC
8789
target_link_options(${CONTEXT} PUBLIC
8890
"SHELL:${LD_CPU}"
8991
"SHELL:${_LS}\"${LD_SCRIPT_PP}\""
92+
"SHELL:${LD_LTO}"
9093
"SHELL:--entry=Reset_Handler"
9194
"SHELL:--map"
9295
"SHELL:--info summarysizes"

test/data/solutions/build-cpp/solution.csolution.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ solution:
1313
build-types:
1414
- type: AC6
1515
compiler: AC6
16+
link-time-optimize:
1617

1718
- type: GCC
1819
compiler: GCC

0 commit comments

Comments
 (0)