Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "strings" |
| 20 | |
| 21 | "github.com/google/blueprint" |
| 22 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 23 | "android/soong/android" |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | type sanitizerType int |
| 27 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 28 | func boolPtr(v bool) *bool { |
| 29 | if v { |
| 30 | return &v |
| 31 | } else { |
| 32 | return nil |
| 33 | } |
| 34 | } |
| 35 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 36 | const ( |
| 37 | asan sanitizerType = iota + 1 |
| 38 | tsan |
| 39 | ) |
| 40 | |
| 41 | func (t sanitizerType) String() string { |
| 42 | switch t { |
| 43 | case asan: |
| 44 | return "asan" |
| 45 | case tsan: |
| 46 | return "tsan" |
| 47 | default: |
| 48 | panic(fmt.Errorf("unknown sanitizerType %d", t)) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | type SanitizeProperties struct { |
| 53 | // enable AddressSanitizer, ThreadSanitizer, or UndefinedBehaviorSanitizer |
| 54 | Sanitize struct { |
| 55 | Never bool `android:"arch_variant"` |
| 56 | |
| 57 | // main sanitizers |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 58 | Address *bool `android:"arch_variant"` |
| 59 | Thread *bool `android:"arch_variant"` |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 60 | |
| 61 | // local sanitizers |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 62 | Undefined *bool `android:"arch_variant"` |
| 63 | All_undefined *bool `android:"arch_variant"` |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 64 | Misc_undefined []string `android:"arch_variant"` |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 65 | Coverage *bool `android:"arch_variant"` |
| 66 | Safestack *bool `android:"arch_variant"` |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 67 | |
| 68 | // value to pass to -fsantitize-recover= |
| 69 | Recover []string |
| 70 | |
| 71 | // value to pass to -fsanitize-blacklist |
| 72 | Blacklist *string |
| 73 | } `android:"arch_variant"` |
| 74 | |
| 75 | SanitizerEnabled bool `blueprint:"mutated"` |
| 76 | SanitizeDep bool `blueprint:"mutated"` |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 77 | InData bool `blueprint:"mutated"` |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | type sanitize struct { |
| 81 | Properties SanitizeProperties |
| 82 | } |
| 83 | |
| 84 | func (sanitize *sanitize) props() []interface{} { |
| 85 | return []interface{}{&sanitize.Properties} |
| 86 | } |
| 87 | |
| 88 | func (sanitize *sanitize) begin(ctx BaseModuleContext) { |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 89 | s := &sanitize.Properties.Sanitize |
| 90 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 91 | // Don't apply sanitizers to NDK code. |
| 92 | if ctx.sdk() { |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 93 | s.Never = true |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | // Never always wins. |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 97 | if s.Never { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 98 | return |
| 99 | } |
| 100 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 101 | var globalSanitizers []string |
| 102 | if ctx.clang() { |
| 103 | if ctx.Host() { |
| 104 | globalSanitizers = ctx.AConfig().SanitizeHost() |
| 105 | } else { |
| 106 | globalSanitizers = ctx.AConfig().SanitizeDevice() |
| 107 | } |
| 108 | } |
| 109 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 110 | if len(globalSanitizers) > 0 { |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 111 | var found bool |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 112 | if found, globalSanitizers = removeFromList("undefined", globalSanitizers); found && s.All_undefined == nil { |
| 113 | s.All_undefined = boolPtr(true) |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 114 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 115 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 116 | if found, globalSanitizers = removeFromList("default-ub", globalSanitizers); found && s.Undefined == nil { |
| 117 | s.Undefined = boolPtr(true) |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 120 | if found, globalSanitizers = removeFromList("address", globalSanitizers); found && s.Address == nil { |
| 121 | s.Address = boolPtr(true) |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 124 | if found, globalSanitizers = removeFromList("thread", globalSanitizers); found && s.Thread == nil { |
| 125 | s.Thread = boolPtr(true) |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 128 | if found, globalSanitizers = removeFromList("coverage", globalSanitizers); found && s.Coverage == nil { |
| 129 | s.Coverage = boolPtr(true) |
| 130 | } |
| 131 | |
| 132 | if found, globalSanitizers = removeFromList("safe-stack", globalSanitizers); found && s.Safestack == nil { |
| 133 | s.Safestack = boolPtr(true) |
Evgenii Stepanov | 05bafd3 | 2016-07-07 17:38:41 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | if len(globalSanitizers) > 0 { |
| 137 | ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0]) |
| 138 | } |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 139 | } |
Colin Cross | 3c344ef | 2016-07-18 15:44:56 -0700 | [diff] [blame] | 140 | |
| 141 | if ctx.staticBinary() { |
| 142 | s.Address = nil |
Colin Cross | 91169fe | 2016-08-11 15:54:20 -0700 | [diff] [blame^] | 143 | s.Coverage = nil |
Colin Cross | 3c344ef | 2016-07-18 15:44:56 -0700 | [diff] [blame] | 144 | s.Thread = nil |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 145 | } |
| 146 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 147 | if Bool(s.All_undefined) { |
| 148 | s.Undefined = nil |
| 149 | } |
| 150 | |
Evgenii Stepanov | 0a8a0d0 | 2016-05-12 13:54:53 -0700 | [diff] [blame] | 151 | if !ctx.toolchain().Is64Bit() { |
| 152 | // TSAN and SafeStack are not supported on 32-bit architectures |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 153 | s.Thread = nil |
| 154 | s.Safestack = nil |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 155 | // TODO(ccross): error for compile_multilib = "32"? |
| 156 | } |
| 157 | |
Colin Cross | 3c344ef | 2016-07-18 15:44:56 -0700 | [diff] [blame] | 158 | if Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || |
| 159 | Bool(s.Thread) || Bool(s.Coverage) || Bool(s.Safestack) { |
| 160 | sanitize.Properties.SanitizerEnabled = true |
| 161 | } |
| 162 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 163 | if Bool(s.Coverage) { |
| 164 | if !Bool(s.Address) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 165 | ctx.ModuleErrorf(`Use of "coverage" also requires "address"`) |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps { |
| 171 | if !sanitize.Properties.SanitizerEnabled { // || c.static() { |
| 172 | return deps |
| 173 | } |
| 174 | |
| 175 | if ctx.Device() { |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 176 | if Bool(sanitize.Properties.Sanitize.Address) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 177 | deps.StaticLibs = append(deps.StaticLibs, "libasan") |
| 178 | } |
Colin Cross | 263abbd | 2016-07-15 13:10:48 -0700 | [diff] [blame] | 179 | if Bool(sanitize.Properties.Sanitize.Address) || Bool(sanitize.Properties.Sanitize.Thread) { |
| 180 | deps.SharedLibs = append(deps.SharedLibs, "libdl") |
| 181 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | return deps |
| 185 | } |
| 186 | |
| 187 | func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { |
| 188 | if !sanitize.Properties.SanitizerEnabled { |
| 189 | return flags |
| 190 | } |
| 191 | |
| 192 | if !ctx.clang() { |
| 193 | ctx.ModuleErrorf("Use of sanitizers requires clang") |
| 194 | } |
| 195 | |
| 196 | var sanitizers []string |
| 197 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 198 | if Bool(sanitize.Properties.Sanitize.All_undefined) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 199 | sanitizers = append(sanitizers, "undefined") |
| 200 | if ctx.Device() { |
| 201 | ctx.ModuleErrorf("ubsan is not yet supported on the device") |
| 202 | } |
| 203 | } else { |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 204 | if Bool(sanitize.Properties.Sanitize.Undefined) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 205 | sanitizers = append(sanitizers, |
| 206 | "bool", |
| 207 | "integer-divide-by-zero", |
| 208 | "return", |
| 209 | "returns-nonnull-attribute", |
| 210 | "shift-exponent", |
| 211 | "unreachable", |
| 212 | "vla-bound", |
| 213 | // TODO(danalbert): The following checks currently have compiler performance issues. |
| 214 | //"alignment", |
| 215 | //"bounds", |
| 216 | //"enum", |
| 217 | //"float-cast-overflow", |
| 218 | //"float-divide-by-zero", |
| 219 | //"nonnull-attribute", |
| 220 | //"null", |
| 221 | //"shift-base", |
| 222 | //"signed-integer-overflow", |
| 223 | // TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. |
| 224 | // https://llvm.org/PR19302 |
| 225 | // http://reviews.llvm.org/D6974 |
| 226 | // "object-size", |
| 227 | ) |
| 228 | } |
| 229 | sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...) |
| 230 | } |
| 231 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 232 | if Bool(sanitize.Properties.Sanitize.Address) { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 233 | if ctx.Arch().ArchType == android.Arm { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 234 | // Frame pointer based unwinder in ASan requires ARM frame setup. |
| 235 | // TODO: put in flags? |
| 236 | flags.RequiredInstructionSet = "arm" |
| 237 | } |
| 238 | flags.CFlags = append(flags.CFlags, "-fno-omit-frame-pointer") |
| 239 | flags.LdFlags = append(flags.LdFlags, "-Wl,-u,__asan_preinit") |
| 240 | |
| 241 | // ASan runtime library must be the first in the link order. |
| 242 | runtimeLibrary := ctx.toolchain().AddressSanitizerRuntimeLibrary() |
| 243 | if runtimeLibrary != "" { |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 244 | flags.libFlags = append([]string{"${config.ClangAsanLibDir}/" + runtimeLibrary}, flags.libFlags...) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 245 | } |
| 246 | if ctx.Host() { |
| 247 | // -nodefaultlibs (provided with libc++) prevents the driver from linking |
| 248 | // libraries needed with -fsanitize=address. http://b/18650275 (WAI) |
| 249 | flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread") |
| 250 | flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed") |
| 251 | } else { |
| 252 | flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0") |
| 253 | flags.DynamicLinker = "/system/bin/linker_asan" |
| 254 | if flags.Toolchain.Is64Bit() { |
| 255 | flags.DynamicLinker += "64" |
| 256 | } |
| 257 | } |
| 258 | sanitizers = append(sanitizers, "address") |
| 259 | } |
| 260 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 261 | if Bool(sanitize.Properties.Sanitize.Coverage) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 262 | flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp") |
| 263 | } |
| 264 | |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 265 | if Bool(sanitize.Properties.Sanitize.Safestack) { |
Evgenii Stepanov | 0a8a0d0 | 2016-05-12 13:54:53 -0700 | [diff] [blame] | 266 | sanitizers = append(sanitizers, "safe-stack") |
| 267 | } |
| 268 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 269 | if sanitize.Properties.Sanitize.Recover != nil { |
| 270 | flags.CFlags = append(flags.CFlags, "-fsanitize-recover="+ |
| 271 | strings.Join(sanitize.Properties.Sanitize.Recover, ",")) |
| 272 | } |
| 273 | |
| 274 | if len(sanitizers) > 0 { |
| 275 | sanitizeArg := "-fsanitize=" + strings.Join(sanitizers, ",") |
| 276 | flags.CFlags = append(flags.CFlags, sanitizeArg) |
| 277 | if ctx.Host() { |
| 278 | flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all") |
| 279 | flags.LdFlags = append(flags.LdFlags, sanitizeArg) |
| 280 | flags.LdFlags = append(flags.LdFlags, "-lrt", "-ldl") |
| 281 | } else { |
Colin Cross | 263abbd | 2016-07-15 13:10:48 -0700 | [diff] [blame] | 282 | flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort") |
| 283 | if Bool(sanitize.Properties.Sanitize.Address) || Bool(sanitize.Properties.Sanitize.Thread) { |
| 284 | flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap=address,thread") |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 289 | blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 290 | if blacklist.Valid() { |
| 291 | flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String()) |
| 292 | flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path()) |
| 293 | } |
| 294 | |
| 295 | return flags |
| 296 | } |
| 297 | |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 298 | func (sanitize *sanitize) inData() bool { |
| 299 | return sanitize.Properties.InData |
| 300 | } |
| 301 | |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 302 | func (sanitize *sanitize) Sanitizer(t sanitizerType) bool { |
| 303 | if sanitize == nil { |
| 304 | return false |
| 305 | } |
| 306 | |
| 307 | switch t { |
| 308 | case asan: |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 309 | return Bool(sanitize.Properties.Sanitize.Address) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 310 | case tsan: |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 311 | return Bool(sanitize.Properties.Sanitize.Thread) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 312 | default: |
| 313 | panic(fmt.Errorf("unknown sanitizerType %d", t)) |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) { |
| 318 | switch t { |
| 319 | case asan: |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 320 | sanitize.Properties.Sanitize.Address = boolPtr(b) |
Colin Cross | 91169fe | 2016-08-11 15:54:20 -0700 | [diff] [blame^] | 321 | if !b { |
| 322 | sanitize.Properties.Sanitize.Coverage = nil |
| 323 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 324 | case tsan: |
Evgenii Stepanov | fcfe56d | 2016-07-07 10:54:07 -0700 | [diff] [blame] | 325 | sanitize.Properties.Sanitize.Thread = boolPtr(b) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 326 | default: |
| 327 | panic(fmt.Errorf("unknown sanitizerType %d", t)) |
| 328 | } |
| 329 | if b { |
| 330 | sanitize.Properties.SanitizerEnabled = true |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // Propagate asan requirements down from binaries |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 335 | func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) { |
| 336 | return func(mctx android.TopDownMutatorContext) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 337 | if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) { |
| 338 | mctx.VisitDepsDepthFirst(func(module blueprint.Module) { |
| 339 | if d, ok := mctx.Module().(*Module); ok && c.sanitize != nil && |
| 340 | !c.sanitize.Properties.Sanitize.Never { |
| 341 | d.sanitize.Properties.SanitizeDep = true |
| 342 | } |
| 343 | }) |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | // Create asan variants for modules that need them |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 349 | func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) { |
| 350 | return func(mctx android.BottomUpMutatorContext) { |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 351 | if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 352 | if c.isDependencyRoot() && c.sanitize.Sanitizer(t) { |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 353 | modules := mctx.CreateVariations(t.String()) |
| 354 | modules[0].(*Module).sanitize.SetSanitizer(t, true) |
Colin Cross | b36ab1a | 2016-05-25 12:35:53 -0700 | [diff] [blame] | 355 | if mctx.AConfig().EmbeddedInMake() && !c.Host() { |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 356 | modules[0].(*Module).sanitize.Properties.InData = true |
| 357 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 358 | } else if c.sanitize.Properties.SanitizeDep { |
Colin Cross | b36ab1a | 2016-05-25 12:35:53 -0700 | [diff] [blame] | 359 | if c.Host() { |
| 360 | modules := mctx.CreateVariations(t.String()) |
| 361 | modules[0].(*Module).sanitize.SetSanitizer(t, true) |
| 362 | modules[0].(*Module).sanitize.Properties.SanitizeDep = false |
| 363 | } else { |
| 364 | modules := mctx.CreateVariations("", t.String()) |
| 365 | modules[0].(*Module).sanitize.SetSanitizer(t, false) |
| 366 | modules[1].(*Module).sanitize.SetSanitizer(t, true) |
| 367 | modules[0].(*Module).sanitize.Properties.SanitizeDep = false |
| 368 | modules[1].(*Module).sanitize.Properties.SanitizeDep = false |
| 369 | modules[1].(*Module).sanitize.Properties.InData = true |
| 370 | if mctx.AConfig().EmbeddedInMake() { |
| 371 | modules[0].(*Module).Properties.HideFromMake = true |
| 372 | } |
Colin Cross | 30d5f51 | 2016-05-03 18:02:42 -0700 | [diff] [blame] | 373 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 374 | } |
| 375 | c.sanitize.Properties.SanitizeDep = false |
| 376 | } |
| 377 | } |
| 378 | } |