Skip to content

Commit ab35e97

Browse files
authored
Merge branch 'main' into dependabot/github_actions/github/codeql-action-3.28.17
2 parents d47102f + 1adcd40 commit ab35e97

20 files changed

Lines changed: 86 additions & 36 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: Harden Runner
31-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
31+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
3232
with:
3333
egress-policy: audit
3434

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
steps:
3737
- name: Harden Runner
38-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
38+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
3939
with:
4040
egress-policy: audit
4141

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
pull-requests: write
2020
steps:
2121
- name: Harden Runner
22-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
22+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2323
with:
2424
egress-policy: audit
2525

.github/workflows/global.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Harden Runner
20-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
20+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2121
with:
2222
egress-policy: audit
2323

.github/workflows/markdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Harden Runner
19-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
19+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2020
with:
2121
egress-policy: audit
2222

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Harden Runner
24-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
24+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
2525
with:
2626
egress-policy: audit
2727

2828
- name: Download test results
29-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
29+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
3030
with:
3131
pattern: test-results-*
3232
path: testreport/

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131

3232
steps:
3333
- name: Harden Runner
34-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
34+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
3535
with:
3636
egress-policy: audit
3737

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Harden Runner
32-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
32+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
3333
with:
3434
egress-policy: audit
3535

@@ -44,7 +44,7 @@ jobs:
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Harden Runner
47-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
47+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
4848
with:
4949
egress-policy: audit
5050

@@ -80,7 +80,7 @@ jobs:
8080
runs-on: ubuntu-latest
8181
steps:
8282
- name: Harden Runner
83-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
83+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
8484
with:
8585
egress-policy: audit
8686

@@ -106,7 +106,7 @@ jobs:
106106
runs-on: ${{ matrix.platform }}
107107
steps:
108108
- name: Harden Runner
109-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
109+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
110110
with:
111111
egress-policy: audit
112112

@@ -168,12 +168,12 @@ jobs:
168168
pull-requests: write
169169
steps:
170170
- name: Harden Runner
171-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
171+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
172172
with:
173173
egress-policy: audit
174174

175175
- name: Download Artifacts
176-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
176+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
177177
with:
178178
path: artifacts
179179

@@ -190,7 +190,7 @@ jobs:
190190
runs-on: ubuntu-latest
191191
steps:
192192
- name: Harden Runner
193-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
193+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
194194
with:
195195
egress-policy: audit
196196

.github/workflows/tpip-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
actions: write
3030
steps:
3131
- name: Harden Runner
32-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
32+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
3333
with:
3434
egress-policy: audit
3535

@@ -78,7 +78,7 @@ jobs:
7878
timeout-minutes: 5
7979
steps:
8080
- name: Harden Runner
81-
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
81+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
8282
with:
8383
egress-policy: audit
8484

@@ -88,7 +88,7 @@ jobs:
8888
fetch-depth: 0
8989

9090
- name: Restore Changes
91-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
91+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
9292
with:
9393
name: tpip-report
9494

pkg/maker/buildcontent.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (c *Cbuild) CMakeTargetCompileOptionsGlobal(name string, scope string) stri
345345
}
346346
}
347347
// add global misc options
348-
c.GetCompileOptionsLanguageMap(c.BuildDescType.Misc, &optionsMap)
348+
c.GetCompileOptionsLanguageMap((c.BuildDescType.Lto), c.BuildDescType.Misc, &optionsMap)
349349

350350
// pre-includes global
351351
for _, preInclude := range c.PreIncludeGlobal {
@@ -370,11 +370,11 @@ func (c *Cbuild) CMakeTargetLinkLibraries(name string, scope string, libraries .
370370
return content
371371
}
372372

373-
func (c *Cbuild) CMakeTargetCompileOptions(name string, scope string, misc Misc, preIncludes []string, parent string) string {
373+
func (c *Cbuild) CMakeTargetCompileOptions(name string, scope string, lto bool, misc Misc, preIncludes []string, parent string) string {
374374
content := "\ntarget_compile_options(" + name + " " + scope
375375
content += "\n $<TARGET_PROPERTY:" + parent + ",INTERFACE_COMPILE_OPTIONS>"
376376
optionsMap := make(map[string][]string)
377-
c.GetCompileOptionsLanguageMap(misc, &optionsMap)
377+
c.GetCompileOptionsLanguageMap(lto, misc, &optionsMap)
378378
for _, preInclude := range preIncludes {
379379
optionsMap["C,CXX"] = append(optionsMap["C,CXX"], "${_PI}\""+preInclude+"\"")
380380
}
@@ -406,19 +406,31 @@ func (c *Cbuild) CMakeTargetCompileOptionsAbstractions(name string, abstractions
406406
return content
407407
}
408408

409-
func (c *Cbuild) GetCompileOptionsLanguageMap(misc Misc, optionsMap *map[string][]string) {
409+
func (c *Cbuild) GetCompileOptionsLanguageMap(lto bool, misc Misc, optionsMap *map[string][]string) {
410410
for _, language := range c.Languages {
411411
switch language {
412412
case "ASM":
413413
if len(misc.ASM) > 0 {
414414
(*optionsMap)[language] = append((*optionsMap)[language], misc.ASM...)
415415
}
416416
case "C", "CXX":
417-
if language == "C" && len(misc.C) > 0 {
418-
(*optionsMap)[language] = append((*optionsMap)[language], misc.C...)
417+
if language == "C" {
418+
if lto {
419+
c.LinkerLto = true
420+
(*optionsMap)[language] = append((*optionsMap)[language], "${CC_LTO}")
421+
}
422+
if len(misc.C) > 0 {
423+
(*optionsMap)[language] = append((*optionsMap)[language], misc.C...)
424+
}
419425
}
420-
if language == "CXX" && len(misc.CPP) > 0 {
421-
(*optionsMap)[language] = append((*optionsMap)[language], misc.CPP...)
426+
if language == "CXX" {
427+
if lto {
428+
c.LinkerLto = true
429+
(*optionsMap)[language] = append((*optionsMap)[language], "${CXX_LTO}")
430+
}
431+
if len(misc.CPP) > 0 {
432+
(*optionsMap)[language] = append((*optionsMap)[language], misc.CPP...)
433+
}
422434
}
423435
if len(misc.CCPP) > 0 {
424436
(*optionsMap)[language] = append((*optionsMap)[language], misc.CCPP...)
@@ -460,6 +472,9 @@ func GetFileOptions(file Files, hasAbstractions bool, delimiter string) string {
460472
case "CXX":
461473
options = append(file.Misc.CPP, file.Misc.CCPP...)
462474
}
475+
if file.Lto {
476+
options = append(options, "${"+prefix+"_LTO}")
477+
}
463478
if hasAbstractions {
464479
options = append(options, "${"+prefix+"_OPTIONS_FLAGS}")
465480
}
@@ -759,6 +774,7 @@ func (c *Cbuild) CMakeSetFileProperties(file Files, abstractions CompilerAbstrac
759774
// file build options
760775
language := GetLanguage(file)
761776
hasMisc := !IsCompileMiscEmpty(file.Misc)
777+
c.LinkerLto = c.LinkerLto || file.Lto
762778
// file compiler abstractions
763779
hasAbstractions := !AreAbstractionsEmpty(abstractions, []string{language})
764780
if hasAbstractions {
@@ -768,9 +784,9 @@ func (c *Cbuild) CMakeSetFileProperties(file Files, abstractions CompilerAbstrac
768784
filename := c.AddRootPrefix(c.ContextRoot, file.File)
769785
isGenerated := slices.Contains(c.GeneratedFiles, filename)
770786
// set file properties
771-
if hasMisc || hasAbstractions || isGenerated {
787+
if hasMisc || file.Lto || hasAbstractions || isGenerated {
772788
content += "\nset_source_files_properties(\"" + filename + "\" PROPERTIES"
773-
if hasMisc || hasAbstractions {
789+
if hasMisc || file.Lto || hasAbstractions {
774790
content += "\n COMPILE_OPTIONS \"" + GetFileOptions(file, hasAbstractions, ";") + "\""
775791
}
776792
if isGenerated {
@@ -834,6 +850,9 @@ func (c *Cbuild) LinkerOptions() (linkerVars string, linkerOptions string) {
834850
if len(c.BuildDescType.Processor.Trustzone) > 0 {
835851
linkerOptions += "\n " + AddShellPrefix("${LD_SECURE}")
836852
}
853+
if c.LinkerLto {
854+
linkerOptions += "\n " + AddShellPrefix("${LD_LTO}")
855+
}
837856
options := c.BuildDescType.Misc.Link
838857
for _, language := range c.Languages {
839858
if language == "C" {

0 commit comments

Comments
 (0)