blob: c64f5eedd48bfcdb3877f1ab18b05c01e1eace46 [file] [log] [blame]
Colin Cross16b23492016-01-06 14:41:07 -08001// Copyright 2016 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
18 "fmt"
Colin Cross8ff9ef42017-05-08 13:44:11 -070019 "io"
Jeff Gaston72765392017-11-28 16:37:53 -080020 "sort"
Colin Cross16b23492016-01-06 14:41:07 -080021 "strings"
Vishwath Mohane7128792017-11-17 11:08:10 -080022 "sync"
Colin Cross16b23492016-01-06 14:41:07 -080023
Colin Cross635c3b02016-05-18 15:37:25 -070024 "android/soong/android"
Evgenii Stepanovaf36db12016-08-15 14:18:24 -070025 "android/soong/cc/config"
Colin Cross16b23492016-01-06 14:41:07 -080026)
27
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070028var (
29 // Any C flags added by sanitizer which libTooling tools may not
30 // understand also need to be added to ClangLibToolingUnknownCflags in
31 // cc/config/clang.go
Vishwath Mohanf3918d32017-02-14 07:59:33 -080032
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070033 asanCflags = []string{"-fno-omit-frame-pointer"}
34 asanLdflags = []string{"-Wl,-u,__asan_preinit"}
35 asanLibs = []string{"libasan"}
36
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000037 cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070038 "-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"}
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -070039 cfiLdflags = []string{"-flto", "-fsanitize-cfi-cross-dso", "-fsanitize=cfi",
Pirama Arumuga Nainarbdb17f02017-08-28 21:50:17 -070040 "-Wl,-plugin-opt,O1"}
Vishwath Mohane7128792017-11-17 11:08:10 -080041 cfiExportsMapPath = "build/soong/cc/config/cfi_exports.map"
Vishwath Mohane7128792017-11-17 11:08:10 -080042 cfiStaticLibsMutex sync.Mutex
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070043
Ivan Lozano30c5db22018-02-21 15:49:20 -080044 intOverflowCflags = []string{"-fsanitize-blacklist=build/soong/cc/config/integer_overflow_blacklist.txt"}
45 minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer", "-fno-sanitize-recover=integer"}
Dan Willemsencbceaab2016-10-13 16:44:07 -070046)
47
Colin Cross16b23492016-01-06 14:41:07 -080048type sanitizerType int
49
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -070050func boolPtr(v bool) *bool {
51 if v {
52 return &v
53 } else {
54 return nil
55 }
56}
57
Colin Cross16b23492016-01-06 14:41:07 -080058const (
59 asan sanitizerType = iota + 1
60 tsan
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070061 intOverflow
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000062 cfi
Colin Cross16b23492016-01-06 14:41:07 -080063)
64
65func (t sanitizerType) String() string {
66 switch t {
67 case asan:
68 return "asan"
69 case tsan:
70 return "tsan"
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070071 case intOverflow:
72 return "intOverflow"
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000073 case cfi:
74 return "cfi"
Colin Cross16b23492016-01-06 14:41:07 -080075 default:
76 panic(fmt.Errorf("unknown sanitizerType %d", t))
77 }
78}
79
80type SanitizeProperties struct {
81 // enable AddressSanitizer, ThreadSanitizer, or UndefinedBehaviorSanitizer
82 Sanitize struct {
Nan Zhang0007d812017-11-07 10:57:05 -080083 Never *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -080084
85 // main sanitizers
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -070086 Address *bool `android:"arch_variant"`
87 Thread *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -080088
89 // local sanitizers
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -070090 Undefined *bool `android:"arch_variant"`
91 All_undefined *bool `android:"arch_variant"`
92 Misc_undefined []string `android:"arch_variant"`
93 Coverage *bool `android:"arch_variant"`
94 Safestack *bool `android:"arch_variant"`
95 Cfi *bool `android:"arch_variant"`
96 Integer_overflow *bool `android:"arch_variant"`
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -070097 Scudo *bool `android:"arch_variant"`
Colin Cross16b23492016-01-06 14:41:07 -080098
Evgenii Stepanov1e405e12016-08-16 15:39:54 -070099 // Sanitizers to run in the diagnostic mode (as opposed to the release mode).
100 // Replaces abort() on error with a human-readable error message.
101 // Address and Thread sanitizers always run in diagnostic mode.
102 Diag struct {
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700103 Undefined *bool `android:"arch_variant"`
104 Cfi *bool `android:"arch_variant"`
105 Integer_overflow *bool `android:"arch_variant"`
106 Misc_undefined []string `android:"arch_variant"`
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700107 }
108
109 // value to pass to -fsanitize-recover=
Colin Cross16b23492016-01-06 14:41:07 -0800110 Recover []string
111
112 // value to pass to -fsanitize-blacklist
113 Blacklist *string
114 } `android:"arch_variant"`
115
Ivan Lozano30c5db22018-02-21 15:49:20 -0800116 SanitizerEnabled bool `blueprint:"mutated"`
117 SanitizeDep bool `blueprint:"mutated"`
118 MinimalRuntimeDep bool `blueprint:"mutated"`
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700119 UbsanRuntimeDep bool `blueprint:"mutated"`
Ivan Lozano30c5db22018-02-21 15:49:20 -0800120 InSanitizerDir bool `blueprint:"mutated"`
Colin Cross16b23492016-01-06 14:41:07 -0800121}
122
123type sanitize struct {
124 Properties SanitizeProperties
Colin Cross8ff9ef42017-05-08 13:44:11 -0700125
Jiyong Park27b188b2017-07-18 13:23:39 +0900126 runtimeLibrary string
127 androidMkRuntimeLibrary string
Colin Cross16b23492016-01-06 14:41:07 -0800128}
129
Vishwath Mohane7128792017-11-17 11:08:10 -0800130func init() {
131 android.RegisterMakeVarsProvider(pctx, cfiMakeVarsProvider)
132}
133
Colin Cross16b23492016-01-06 14:41:07 -0800134func (sanitize *sanitize) props() []interface{} {
135 return []interface{}{&sanitize.Properties}
136}
137
138func (sanitize *sanitize) begin(ctx BaseModuleContext) {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700139 s := &sanitize.Properties.Sanitize
140
Colin Cross16b23492016-01-06 14:41:07 -0800141 // Don't apply sanitizers to NDK code.
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700142 if ctx.useSdk() {
Nan Zhang0007d812017-11-07 10:57:05 -0800143 s.Never = BoolPtr(true)
Colin Cross16b23492016-01-06 14:41:07 -0800144 }
145
146 // Never always wins.
Nan Zhang0007d812017-11-07 10:57:05 -0800147 if Bool(s.Never) {
Colin Cross16b23492016-01-06 14:41:07 -0800148 return
149 }
150
Colin Cross16b23492016-01-06 14:41:07 -0800151 var globalSanitizers []string
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700152 var globalSanitizersDiag []string
153
Colin Cross16b23492016-01-06 14:41:07 -0800154 if ctx.clang() {
155 if ctx.Host() {
Colin Cross6510f912017-11-29 00:27:14 -0800156 globalSanitizers = ctx.Config().SanitizeHost()
Colin Cross16b23492016-01-06 14:41:07 -0800157 } else {
Colin Cross6510f912017-11-29 00:27:14 -0800158 arches := ctx.Config().SanitizeDeviceArch()
Colin Cross23ae82a2016-11-02 14:34:39 -0700159 if len(arches) == 0 || inList(ctx.Arch().ArchType.Name, arches) {
Colin Cross6510f912017-11-29 00:27:14 -0800160 globalSanitizers = ctx.Config().SanitizeDevice()
161 globalSanitizersDiag = ctx.Config().SanitizeDeviceDiag()
Colin Cross23ae82a2016-11-02 14:34:39 -0700162 }
Colin Cross16b23492016-01-06 14:41:07 -0800163 }
164 }
165
Colin Cross16b23492016-01-06 14:41:07 -0800166 if len(globalSanitizers) > 0 {
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000167 var found bool
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700168 if found, globalSanitizers = removeFromList("undefined", globalSanitizers); found && s.All_undefined == nil {
169 s.All_undefined = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000170 }
Colin Cross16b23492016-01-06 14:41:07 -0800171
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700172 if found, globalSanitizers = removeFromList("default-ub", globalSanitizers); found && s.Undefined == nil {
173 s.Undefined = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000174 }
175
Evgenii Stepanov774cb812016-12-28 15:52:54 -0800176 if found, globalSanitizers = removeFromList("address", globalSanitizers); found {
177 if s.Address == nil {
178 s.Address = boolPtr(true)
179 } else if *s.Address == false {
180 // Coverage w/o address is an error. If globalSanitizers includes both, and the module
181 // disables address, then disable coverage as well.
182 _, globalSanitizers = removeFromList("coverage", globalSanitizers)
183 }
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000184 }
185
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700186 if found, globalSanitizers = removeFromList("thread", globalSanitizers); found && s.Thread == nil {
187 s.Thread = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000188 }
189
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700190 if found, globalSanitizers = removeFromList("coverage", globalSanitizers); found && s.Coverage == nil {
191 s.Coverage = boolPtr(true)
192 }
193
194 if found, globalSanitizers = removeFromList("safe-stack", globalSanitizers); found && s.Safestack == nil {
195 s.Safestack = boolPtr(true)
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000196 }
197
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700198 if found, globalSanitizers = removeFromList("cfi", globalSanitizers); found && s.Cfi == nil {
Colin Cross6510f912017-11-29 00:27:14 -0800199 if !ctx.Config().CFIDisabledForPath(ctx.ModuleDir()) {
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700200 s.Cfi = boolPtr(true)
201 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700202 }
203
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700204 // Global integer_overflow builds do not support static libraries.
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700205 if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700206 if !ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) && !ctx.static() {
Ivan Lozano5f595532017-07-13 14:46:05 -0700207 s.Integer_overflow = boolPtr(true)
208 }
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700209 }
210
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700211 if found, globalSanitizers = removeFromList("scudo", globalSanitizers); found && s.Scudo == nil {
212 s.Scudo = boolPtr(true)
213 }
214
Evgenii Stepanov05bafd32016-07-07 17:38:41 +0000215 if len(globalSanitizers) > 0 {
216 ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0])
217 }
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700218
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700219 // Global integer_overflow builds do not support static library diagnostics.
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700220 if found, globalSanitizersDiag = removeFromList("integer_overflow", globalSanitizersDiag); found &&
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700221 s.Diag.Integer_overflow == nil && Bool(s.Integer_overflow) && !ctx.static() {
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700222 s.Diag.Integer_overflow = boolPtr(true)
223 }
224
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700225 if found, globalSanitizersDiag = removeFromList("cfi", globalSanitizersDiag); found &&
226 s.Diag.Cfi == nil && Bool(s.Cfi) {
227 s.Diag.Cfi = boolPtr(true)
228 }
229
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700230 if len(globalSanitizersDiag) > 0 {
231 ctx.ModuleErrorf("unknown global sanitizer diagnostics option %s", globalSanitizersDiag[0])
232 }
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700233 }
Colin Cross3c344ef2016-07-18 15:44:56 -0700234
Vishwath Mohan1c54f662018-05-24 18:36:18 -0700235 // Enable CFI for all components in the include paths (for Aarch64 only)
236 if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
Vishwath Mohan3af8ee02018-03-30 02:55:23 +0000237 s.Cfi = boolPtr(true)
238 if inList("cfi", ctx.Config().SanitizeDeviceDiag()) {
239 s.Diag.Cfi = boolPtr(true)
Vishwath Mohan1fa3ac52017-10-31 02:26:14 -0700240 }
241 }
242
Evgenii Stepanova83fdac2017-01-31 18:37:30 -0800243 // CFI needs gold linker, and mips toolchain does not have one.
Colin Cross6510f912017-11-29 00:27:14 -0800244 if !ctx.Config().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 {
Vishwath Mohan1b017a72017-01-19 13:54:55 -0800245 s.Cfi = nil
246 s.Diag.Cfi = nil
247 }
248
Vishwath Mohan6d67e6e2017-02-07 20:31:41 -0800249 // Also disable CFI for arm32 until b/35157333 is fixed.
250 if ctx.Arch().ArchType == android.Arm {
251 s.Cfi = nil
252 s.Diag.Cfi = nil
253 }
254
Vishwath Mohan8f4fdd82017-04-20 07:42:52 -0700255 // Also disable CFI if ASAN is enabled.
256 if Bool(s.Address) {
257 s.Cfi = nil
258 s.Diag.Cfi = nil
259 }
260
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700261 // Disable sanitizers that depend on the UBSan runtime for host builds.
Vishwath Mohane7128792017-11-17 11:08:10 -0800262 if ctx.Host() {
263 s.Cfi = nil
264 s.Diag.Cfi = nil
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700265 s.Misc_undefined = nil
266 s.Undefined = nil
267 s.All_undefined = nil
268 s.Integer_overflow = nil
Vishwath Mohane7128792017-11-17 11:08:10 -0800269 }
270
Vishwath Mohan9ccbba02018-05-28 13:54:48 -0700271 // Also disable CFI for VNDK variants of components
272 if ctx.isVndk() && ctx.useVndk() {
Vishwath Mohan7589c822018-05-23 19:29:55 -0700273 s.Cfi = nil
274 s.Diag.Cfi = nil
275 }
276
Colin Cross3c344ef2016-07-18 15:44:56 -0700277 if ctx.staticBinary() {
278 s.Address = nil
Colin Cross91169fe2016-08-11 15:54:20 -0700279 s.Coverage = nil
Colin Cross3c344ef2016-07-18 15:44:56 -0700280 s.Thread = nil
Colin Cross16b23492016-01-06 14:41:07 -0800281 }
282
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700283 if Bool(s.All_undefined) {
284 s.Undefined = nil
285 }
286
Evgenii Stepanov0a8a0d02016-05-12 13:54:53 -0700287 if !ctx.toolchain().Is64Bit() {
288 // TSAN and SafeStack are not supported on 32-bit architectures
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700289 s.Thread = nil
290 s.Safestack = nil
Colin Cross16b23492016-01-06 14:41:07 -0800291 // TODO(ccross): error for compile_multilib = "32"?
292 }
293
Evgenii Stepanov76cee232017-01-27 15:44:44 -0800294 if ctx.Os() != android.Windows && (Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || Bool(s.Thread) ||
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700295 Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) || Bool(s.Integer_overflow) || len(s.Misc_undefined) > 0 ||
296 Bool(s.Scudo)) {
Colin Cross3c344ef2016-07-18 15:44:56 -0700297 sanitize.Properties.SanitizerEnabled = true
298 }
299
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700300 // Disable Scudo if ASan or TSan is enabled.
301 if Bool(s.Address) || Bool(s.Thread) {
302 s.Scudo = nil
303 }
304
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700305 if Bool(s.Coverage) {
306 if !Bool(s.Address) {
Colin Cross16b23492016-01-06 14:41:07 -0800307 ctx.ModuleErrorf(`Use of "coverage" also requires "address"`)
308 }
309 }
310}
311
312func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
313 if !sanitize.Properties.SanitizerEnabled { // || c.static() {
314 return deps
315 }
316
317 if ctx.Device() {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700318 if Bool(sanitize.Properties.Sanitize.Address) {
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700319 deps.StaticLibs = append(deps.StaticLibs, asanLibs...)
Colin Cross16b23492016-01-06 14:41:07 -0800320 }
321 }
322
323 return deps
324}
325
326func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
Ivan Lozano59fdea22018-05-10 14:17:22 -0700327 minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
328 minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib
Ivan Lozano30c5db22018-02-21 15:49:20 -0800329
330 if ctx.Device() && sanitize.Properties.MinimalRuntimeDep {
331 flags.LdFlags = append(flags.LdFlags, minimalRuntimePath)
Ivan Lozano59fdea22018-05-10 14:17:22 -0700332 flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
Ivan Lozano30c5db22018-02-21 15:49:20 -0800333 }
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700334 if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep {
Colin Cross16b23492016-01-06 14:41:07 -0800335 return flags
336 }
337
338 if !ctx.clang() {
339 ctx.ModuleErrorf("Use of sanitizers requires clang")
340 }
341
342 var sanitizers []string
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700343 var diagSanitizers []string
Colin Cross16b23492016-01-06 14:41:07 -0800344
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700345 if Bool(sanitize.Properties.Sanitize.All_undefined) {
Colin Cross16b23492016-01-06 14:41:07 -0800346 sanitizers = append(sanitizers, "undefined")
Colin Cross16b23492016-01-06 14:41:07 -0800347 } else {
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700348 if Bool(sanitize.Properties.Sanitize.Undefined) {
Colin Cross16b23492016-01-06 14:41:07 -0800349 sanitizers = append(sanitizers,
350 "bool",
351 "integer-divide-by-zero",
352 "return",
353 "returns-nonnull-attribute",
354 "shift-exponent",
355 "unreachable",
356 "vla-bound",
357 // TODO(danalbert): The following checks currently have compiler performance issues.
358 //"alignment",
359 //"bounds",
360 //"enum",
361 //"float-cast-overflow",
362 //"float-divide-by-zero",
363 //"nonnull-attribute",
364 //"null",
365 //"shift-base",
366 //"signed-integer-overflow",
367 // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
368 // https://llvm.org/PR19302
369 // http://reviews.llvm.org/D6974
370 // "object-size",
371 )
372 }
373 sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...)
374 }
375
Ivan Lozano651275b2017-06-13 10:24:34 -0700376 if Bool(sanitize.Properties.Sanitize.Diag.Undefined) {
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700377 diagSanitizers = append(diagSanitizers, "undefined")
378 }
379
Ivan Lozano651275b2017-06-13 10:24:34 -0700380 diagSanitizers = append(diagSanitizers, sanitize.Properties.Sanitize.Diag.Misc_undefined...)
381
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700382 if Bool(sanitize.Properties.Sanitize.Address) {
Colin Cross635c3b02016-05-18 15:37:25 -0700383 if ctx.Arch().ArchType == android.Arm {
Colin Cross16b23492016-01-06 14:41:07 -0800384 // Frame pointer based unwinder in ASan requires ARM frame setup.
385 // TODO: put in flags?
386 flags.RequiredInstructionSet = "arm"
387 }
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700388 flags.CFlags = append(flags.CFlags, asanCflags...)
389 flags.LdFlags = append(flags.LdFlags, asanLdflags...)
Colin Cross16b23492016-01-06 14:41:07 -0800390
Colin Cross16b23492016-01-06 14:41:07 -0800391 if ctx.Host() {
392 // -nodefaultlibs (provided with libc++) prevents the driver from linking
393 // libraries needed with -fsanitize=address. http://b/18650275 (WAI)
Colin Cross16b23492016-01-06 14:41:07 -0800394 flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
395 } else {
396 flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
397 flags.DynamicLinker = "/system/bin/linker_asan"
398 if flags.Toolchain.Is64Bit() {
399 flags.DynamicLinker += "64"
400 }
401 }
402 sanitizers = append(sanitizers, "address")
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700403 diagSanitizers = append(diagSanitizers, "address")
Colin Cross16b23492016-01-06 14:41:07 -0800404 }
405
Yabin Cui6be405e2017-10-19 15:52:11 -0700406 if Bool(sanitize.Properties.Sanitize.Thread) {
407 sanitizers = append(sanitizers, "thread")
408 }
409
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700410 if Bool(sanitize.Properties.Sanitize.Coverage) {
Zach Riggle06bbd892017-08-21 17:12:32 -0400411 flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp")
Colin Cross16b23492016-01-06 14:41:07 -0800412 }
413
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700414 if Bool(sanitize.Properties.Sanitize.Safestack) {
Evgenii Stepanov0a8a0d02016-05-12 13:54:53 -0700415 sanitizers = append(sanitizers, "safe-stack")
416 }
417
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700418 if Bool(sanitize.Properties.Sanitize.Cfi) {
Evgenii Stepanov7ebf9fa2017-01-20 14:13:06 -0800419 if ctx.Arch().ArchType == android.Arm {
420 // __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp). LLVM is not set up
421 // to do this on a function basis, so force Thumb on the entire module.
422 flags.RequiredInstructionSet = "thumb"
423 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700424 sanitizers = append(sanitizers, "cfi")
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000425
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700426 flags.CFlags = append(flags.CFlags, cfiCflags...)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000427 // Only append the default visibility flag if -fvisibility has not already been set
428 // to hidden.
429 if !inList("-fvisibility=hidden", flags.CFlags) {
430 flags.CFlags = append(flags.CFlags, "-fvisibility=default")
431 }
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700432 flags.LdFlags = append(flags.LdFlags, cfiLdflags...)
Zhizhou Yang51be6322018-02-08 18:32:11 -0800433 flags.ArGoldPlugin = true
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700434 if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
435 diagSanitizers = append(diagSanitizers, "cfi")
436 }
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000437
438 if ctx.staticBinary() {
439 _, flags.CFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.CFlags)
440 _, flags.LdFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.LdFlags)
441 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700442 }
443
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700444 if Bool(sanitize.Properties.Sanitize.Integer_overflow) {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700445 sanitizers = append(sanitizers, "unsigned-integer-overflow")
446 sanitizers = append(sanitizers, "signed-integer-overflow")
447 flags.CFlags = append(flags.CFlags, intOverflowCflags...)
448 if Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) {
449 diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow")
450 diagSanitizers = append(diagSanitizers, "signed-integer-overflow")
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700451 }
452 }
453
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700454 if Bool(sanitize.Properties.Sanitize.Scudo) {
455 sanitizers = append(sanitizers, "scudo")
456 }
457
Colin Cross16b23492016-01-06 14:41:07 -0800458 if len(sanitizers) > 0 {
459 sanitizeArg := "-fsanitize=" + strings.Join(sanitizers, ",")
Ivan Lozano30c5db22018-02-21 15:49:20 -0800460
Colin Cross16b23492016-01-06 14:41:07 -0800461 flags.CFlags = append(flags.CFlags, sanitizeArg)
462 if ctx.Host() {
463 flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all")
464 flags.LdFlags = append(flags.LdFlags, sanitizeArg)
Evgenii Stepanov76cee232017-01-27 15:44:44 -0800465 // Host sanitizers only link symbols in the final executable, so
466 // there will always be undefined symbols in intermediate libraries.
467 _, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags)
Colin Cross16b23492016-01-06 14:41:07 -0800468 } else {
Colin Cross263abbd2016-07-15 13:10:48 -0700469 flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
Ivan Lozano30c5db22018-02-21 15:49:20 -0800470
471 if enableMinimalRuntime(sanitize) {
472 flags.CFlags = append(flags.CFlags, strings.Join(minimalRuntimeFlags, " "))
473 flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...)
Ivan Lozano59fdea22018-05-10 14:17:22 -0700474 flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
Ivan Lozano30c5db22018-02-21 15:49:20 -0800475 }
Colin Cross16b23492016-01-06 14:41:07 -0800476 }
477 }
478
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700479 if len(diagSanitizers) > 0 {
Ivan Lozanob7d0f522018-01-20 01:44:38 +0000480 flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap="+strings.Join(diagSanitizers, ","))
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700481 }
482 // FIXME: enable RTTI if diag + (cfi or vptr)
483
Andreas Gampe97071162017-05-08 13:15:23 -0700484 if sanitize.Properties.Sanitize.Recover != nil {
485 flags.CFlags = append(flags.CFlags, "-fsanitize-recover="+
486 strings.Join(sanitize.Properties.Sanitize.Recover, ","))
487 }
488
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700489 // Link a runtime library if needed.
490 runtimeLibrary := ""
491 if Bool(sanitize.Properties.Sanitize.Address) {
492 runtimeLibrary = config.AddressSanitizerRuntimeLibrary(ctx.toolchain())
Yabin Cui6be405e2017-10-19 15:52:11 -0700493 } else if Bool(sanitize.Properties.Sanitize.Thread) {
494 runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain())
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700495 } else if Bool(sanitize.Properties.Sanitize.Scudo) {
496 runtimeLibrary = config.ScudoRuntimeLibrary(ctx.toolchain())
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700497 } else if len(diagSanitizers) > 0 || sanitize.Properties.UbsanRuntimeDep {
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700498 runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain())
499 }
500
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700501 if runtimeLibrary != "" {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700502 runtimeLibraryPath := "${config.ClangAsanLibDir}/" + runtimeLibrary
503 if !ctx.static() {
504 runtimeLibraryPath = runtimeLibraryPath + ctx.toolchain().ShlibSuffix()
505 } else {
506 runtimeLibraryPath = runtimeLibraryPath + ".a"
507 }
508
Jiyong Park27b188b2017-07-18 13:23:39 +0900509 // ASan runtime library must be the first in the link order.
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700510 flags.libFlags = append([]string{runtimeLibraryPath}, flags.libFlags...)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700511 sanitize.runtimeLibrary = runtimeLibrary
Jiyong Park27b188b2017-07-18 13:23:39 +0900512
513 // When linking against VNDK, use the vendor variant of the runtime lib
514 sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700515 if ctx.useVndk() {
Jiyong Park27b188b2017-07-18 13:23:39 +0900516 sanitize.androidMkRuntimeLibrary = sanitize.runtimeLibrary + vendorSuffix
517 }
Evgenii Stepanov1e405e12016-08-16 15:39:54 -0700518 }
519
Colin Cross635c3b02016-05-18 15:37:25 -0700520 blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist)
Colin Cross16b23492016-01-06 14:41:07 -0800521 if blacklist.Valid() {
522 flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String())
523 flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path())
524 }
525
526 return flags
527}
528
Colin Cross8ff9ef42017-05-08 13:44:11 -0700529func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
Colin Cross27a4b052017-08-10 16:32:23 -0700530 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
Jiyong Park27b188b2017-07-18 13:23:39 +0900531 if sanitize.androidMkRuntimeLibrary != "" {
532 fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700533 }
Colin Cross8ff9ef42017-05-08 13:44:11 -0700534 })
Vishwath Mohane7128792017-11-17 11:08:10 -0800535
536 // Add a suffix for CFI-enabled static libraries to allow surfacing both to make without a
537 // name conflict.
538 if ret.Class == "STATIC_LIBRARIES" && Bool(sanitize.Properties.Sanitize.Cfi) {
539 ret.SubName += ".cfi"
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000540 }
Colin Cross8ff9ef42017-05-08 13:44:11 -0700541}
542
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700543func (sanitize *sanitize) inSanitizerDir() bool {
544 return sanitize.Properties.InSanitizerDir
Colin Cross30d5f512016-05-03 18:02:42 -0700545}
546
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000547func (sanitize *sanitize) getSanitizerBoolPtr(t sanitizerType) *bool {
Vishwath Mohan95229302017-08-11 00:53:16 +0000548 switch t {
549 case asan:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000550 return sanitize.Properties.Sanitize.Address
Vishwath Mohan95229302017-08-11 00:53:16 +0000551 case tsan:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000552 return sanitize.Properties.Sanitize.Thread
Vishwath Mohan95229302017-08-11 00:53:16 +0000553 case intOverflow:
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000554 return sanitize.Properties.Sanitize.Integer_overflow
555 case cfi:
556 return sanitize.Properties.Sanitize.Cfi
Vishwath Mohan95229302017-08-11 00:53:16 +0000557 default:
558 panic(fmt.Errorf("unknown sanitizerType %d", t))
559 }
560}
561
Dan Albert7d1eecf2018-01-19 12:30:45 -0800562func (sanitize *sanitize) isUnsanitizedVariant() bool {
563 return !sanitize.isSanitizerEnabled(asan) &&
564 !sanitize.isSanitizerEnabled(tsan) &&
565 !sanitize.isSanitizerEnabled(cfi)
566}
567
Jayant Chowdharyb7e08ca2018-05-10 15:29:24 -0700568func (sanitize *sanitize) isVariantOnProductionDevice() bool {
569 return !sanitize.isSanitizerEnabled(asan) &&
570 !sanitize.isSanitizerEnabled(tsan)
571}
572
Colin Cross16b23492016-01-06 14:41:07 -0800573func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) {
574 switch t {
575 case asan:
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700576 sanitize.Properties.Sanitize.Address = boolPtr(b)
Colin Cross91169fe2016-08-11 15:54:20 -0700577 if !b {
578 sanitize.Properties.Sanitize.Coverage = nil
579 }
Colin Cross16b23492016-01-06 14:41:07 -0800580 case tsan:
Evgenii Stepanovfcfe56d2016-07-07 10:54:07 -0700581 sanitize.Properties.Sanitize.Thread = boolPtr(b)
Ivan Lozano0c3a1ef2017-06-28 09:10:48 -0700582 case intOverflow:
583 sanitize.Properties.Sanitize.Integer_overflow = boolPtr(b)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000584 case cfi:
585 sanitize.Properties.Sanitize.Cfi = boolPtr(b)
Colin Cross16b23492016-01-06 14:41:07 -0800586 default:
587 panic(fmt.Errorf("unknown sanitizerType %d", t))
588 }
589 if b {
590 sanitize.Properties.SanitizerEnabled = true
591 }
592}
593
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000594// Check if the sanitizer is explicitly disabled (as opposed to nil by
595// virtue of not being set).
596func (sanitize *sanitize) isSanitizerExplicitlyDisabled(t sanitizerType) bool {
597 if sanitize == nil {
598 return false
599 }
600
601 sanitizerVal := sanitize.getSanitizerBoolPtr(t)
602 return sanitizerVal != nil && *sanitizerVal == false
603}
604
605// There isn't an analog of the method above (ie:isSanitizerExplicitlyEnabled)
606// because enabling a sanitizer either directly (via the blueprint) or
607// indirectly (via a mutator) sets the bool ptr to true, and you can't
608// distinguish between the cases. It isn't needed though - both cases can be
609// treated identically.
610func (sanitize *sanitize) isSanitizerEnabled(t sanitizerType) bool {
611 if sanitize == nil {
612 return false
613 }
614
615 sanitizerVal := sanitize.getSanitizerBoolPtr(t)
616 return sanitizerVal != nil && *sanitizerVal == true
617}
618
Colin Cross16b23492016-01-06 14:41:07 -0800619// Propagate asan requirements down from binaries
Colin Cross635c3b02016-05-18 15:37:25 -0700620func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
621 return func(mctx android.TopDownMutatorContext) {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000622 if c, ok := mctx.Module().(*Module); ok && c.sanitize.isSanitizerEnabled(t) {
Colin Crossd11fcda2017-10-23 17:59:01 -0700623 mctx.VisitDepsDepthFirst(func(module android.Module) {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000624 if d, ok := module.(*Module); ok && d.sanitize != nil &&
Nan Zhang0007d812017-11-07 10:57:05 -0800625 !Bool(d.sanitize.Properties.Sanitize.Never) &&
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000626 !d.sanitize.isSanitizerExplicitlyDisabled(t) {
627 if (t == cfi && d.static()) || t != cfi {
628 d.sanitize.Properties.SanitizeDep = true
629 }
Colin Cross16b23492016-01-06 14:41:07 -0800630 }
631 })
632 }
633 }
634}
635
Ivan Lozano30c5db22018-02-21 15:49:20 -0800636// Propagate the ubsan minimal runtime dependency when there are integer overflow sanitized static dependencies.
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700637func sanitizerRuntimeDepsMutator() func(android.TopDownMutatorContext) {
Ivan Lozano30c5db22018-02-21 15:49:20 -0800638 return func(mctx android.TopDownMutatorContext) {
639 if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
640 mctx.VisitDepsDepthFirst(func(module android.Module) {
641 if d, ok := module.(*Module); ok && d.static() && d.sanitize != nil {
642
Ivan Lozano30c5db22018-02-21 15:49:20 -0800643 if enableMinimalRuntime(d.sanitize) {
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700644 // If a static dependency is built with the minimal runtime,
645 // make sure we include the ubsan minimal runtime.
Ivan Lozano30c5db22018-02-21 15:49:20 -0800646 c.sanitize.Properties.MinimalRuntimeDep = true
Ivan Lozanoa9255a82018-03-13 10:41:07 -0700647 } else if Bool(d.sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
648 len(d.sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0 {
649 // If a static dependency runs with full ubsan diagnostics,
650 // make sure we include the ubsan runtime.
651 c.sanitize.Properties.UbsanRuntimeDep = true
Ivan Lozano30c5db22018-02-21 15:49:20 -0800652 }
653 }
654 })
655 }
656 }
657}
658
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000659// Create sanitized variants for modules that need them
Colin Cross635c3b02016-05-18 15:37:25 -0700660func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
661 return func(mctx android.BottomUpMutatorContext) {
Vishwath Mohane6153452017-08-11 00:52:44 +0000662 if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000663 if c.isDependencyRoot() && c.sanitize.isSanitizerEnabled(t) {
Colin Cross30d5f512016-05-03 18:02:42 -0700664 modules := mctx.CreateVariations(t.String())
665 modules[0].(*Module).sanitize.SetSanitizer(t, true)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000666 } else if c.sanitize.isSanitizerEnabled(t) || c.sanitize.Properties.SanitizeDep {
667 // Save original sanitizer status before we assign values to variant
668 // 0 as that overwrites the original.
669 isSanitizerEnabled := c.sanitize.isSanitizerEnabled(t)
670
Colin Crossb0f28952016-09-19 16:46:53 -0700671 modules := mctx.CreateVariations("", t.String())
672 modules[0].(*Module).sanitize.SetSanitizer(t, false)
673 modules[1].(*Module).sanitize.SetSanitizer(t, true)
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000674
Colin Crossb0f28952016-09-19 16:46:53 -0700675 modules[0].(*Module).sanitize.Properties.SanitizeDep = false
676 modules[1].(*Module).sanitize.Properties.SanitizeDep = false
Vishwath Mohane7128792017-11-17 11:08:10 -0800677
678 // We don't need both variants active for anything but CFI-enabled
679 // target static libraries, so suppress the appropriate variant in
680 // all other cases.
681 if t == cfi {
682 if c.static() {
683 if !mctx.Device() {
684 if isSanitizerEnabled {
685 modules[0].(*Module).Properties.PreventInstall = true
686 modules[0].(*Module).Properties.HideFromMake = true
687 } else {
688 modules[1].(*Module).Properties.PreventInstall = true
689 modules[1].(*Module).Properties.HideFromMake = true
690 }
691 } else {
Colin Cross6510f912017-11-29 00:27:14 -0800692 cfiStaticLibs := cfiStaticLibs(mctx.Config())
Vishwath Mohane7128792017-11-17 11:08:10 -0800693
694 cfiStaticLibsMutex.Lock()
695 *cfiStaticLibs = append(*cfiStaticLibs, c.Name())
696 cfiStaticLibsMutex.Unlock()
697 }
698 } else {
699 modules[0].(*Module).Properties.PreventInstall = true
700 modules[0].(*Module).Properties.HideFromMake = true
701 }
702 } else if t == asan {
703 if mctx.Device() {
704 // CFI and ASAN are currently mutually exclusive so disable
705 // CFI if this is an ASAN variant.
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000706 modules[1].(*Module).sanitize.Properties.InSanitizerDir = true
707 modules[1].(*Module).sanitize.SetSanitizer(cfi, false)
708 }
Vishwath Mohane21fe422017-11-01 19:42:45 -0700709 if isSanitizerEnabled {
710 modules[0].(*Module).Properties.PreventInstall = true
Vishwath Mohane7128792017-11-17 11:08:10 -0800711 modules[0].(*Module).Properties.HideFromMake = true
Vishwath Mohane21fe422017-11-01 19:42:45 -0700712 } else {
713 modules[1].(*Module).Properties.PreventInstall = true
Vishwath Mohane7128792017-11-17 11:08:10 -0800714 modules[1].(*Module).Properties.HideFromMake = true
Vishwath Mohane21fe422017-11-01 19:42:45 -0700715 }
716 }
Colin Cross16b23492016-01-06 14:41:07 -0800717 }
718 c.sanitize.Properties.SanitizeDep = false
719 }
720 }
721}
Vishwath Mohane7128792017-11-17 11:08:10 -0800722
723func cfiStaticLibs(config android.Config) *[]string {
724 return config.Once("cfiStaticLibs", func() interface{} {
725 return &[]string{}
726 }).(*[]string)
727}
728
Ivan Lozano30c5db22018-02-21 15:49:20 -0800729func enableMinimalRuntime(sanitize *sanitize) bool {
730 if !Bool(sanitize.Properties.Sanitize.Address) &&
Kostya Kortchinskyd18ae5c2018-06-12 14:46:54 -0700731 !Bool(sanitize.Properties.Sanitize.Scudo) &&
Ivan Lozano30c5db22018-02-21 15:49:20 -0800732 (Bool(sanitize.Properties.Sanitize.Integer_overflow) ||
733 len(sanitize.Properties.Sanitize.Misc_undefined) > 0) &&
734 !(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
735 Bool(sanitize.Properties.Sanitize.Diag.Cfi) ||
736 len(sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0) {
737 return true
738 }
739 return false
740}
741
Vishwath Mohane7128792017-11-17 11:08:10 -0800742func cfiMakeVarsProvider(ctx android.MakeVarsContext) {
743 cfiStaticLibs := cfiStaticLibs(ctx.Config())
Jeff Gaston72765392017-11-28 16:37:53 -0800744 sort.Strings(*cfiStaticLibs)
Vishwath Mohane7128792017-11-17 11:08:10 -0800745 ctx.Strict("SOONG_CFI_STATIC_LIBRARIES", strings.Join(*cfiStaticLibs, " "))
746}