blob: 15eafc864d4e3f647ed3bffae8131ad42b48ca68 [file] [log] [blame]
Mitch Phillipsda9a4632019-07-15 09:34:09 -07001// 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 (
Kris Alderf979ee32019-10-22 10:52:01 -070018 "encoding/json"
Mitch Phillips4de896e2019-08-28 16:04:36 -070019 "path/filepath"
Mitch Phillipse1ee1a12019-10-17 19:20:41 -070020 "sort"
Mitch Phillipsa0a5e192019-09-27 14:00:06 -070021 "strings"
Mitch Phillips4de896e2019-08-28 16:04:36 -070022
Mitch Phillipsda9a4632019-07-15 09:34:09 -070023 "android/soong/android"
24 "android/soong/cc/config"
25)
26
Kris Alderf979ee32019-10-22 10:52:01 -070027type FuzzConfig struct {
28 // Email address of people to CC on bugs or contact about this fuzz target.
29 Cc []string `json:"cc,omitempty"`
30 // Boolean specifying whether to disable the fuzz target from running
31 // automatically in continuous fuzzing infrastructure.
32 Disable *bool `json:"disable,omitempty"`
33 // Component in Google's bug tracking system that bugs should be filed to.
34 Componentid *int64 `json:"componentid,omitempty"`
35 // Hotlists in Google's bug tracking system that bugs should be marked with.
36 Hotlists []string `json:"hotlists,omitempty"`
37}
38
39func (f *FuzzConfig) String() string {
40 b, err := json.Marshal(f)
41 if err != nil {
42 panic(err)
43 }
44
45 return string(b)
46}
47
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -070048type FuzzProperties struct {
49 // Optional list of seed files to be installed to the fuzz target's output
50 // directory.
51 Corpus []string `android:"path"`
52 // Optional dictionary to be installed to the fuzz target's output directory.
53 Dictionary *string `android:"path"`
Kris Alderf979ee32019-10-22 10:52:01 -070054 // Config for running the target on fuzzing infrastructure.
55 Fuzz_config *FuzzConfig
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -070056}
57
Mitch Phillipsda9a4632019-07-15 09:34:09 -070058func init() {
59 android.RegisterModuleType("cc_fuzz", FuzzFactory)
Mitch Phillipsd3254b42019-09-24 13:03:28 -070060 android.RegisterSingletonType("cc_fuzz_packaging", fuzzPackagingFactory)
Mitch Phillipsda9a4632019-07-15 09:34:09 -070061}
62
63// cc_fuzz creates a host/device fuzzer binary. Host binaries can be found at
64// $ANDROID_HOST_OUT/fuzz/, and device binaries can be found at /data/fuzz on
65// your device, or $ANDROID_PRODUCT_OUT/data/fuzz in your build tree.
66func FuzzFactory() android.Module {
67 module := NewFuzz(android.HostAndDeviceSupported)
68 return module.Init()
69}
70
71func NewFuzzInstaller() *baseInstaller {
72 return NewBaseInstaller("fuzz", "fuzz", InstallInData)
73}
74
75type fuzzBinary struct {
76 *binaryDecorator
77 *baseCompiler
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -070078
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -070079 Properties FuzzProperties
80 dictionary android.Path
81 corpus android.Paths
82 corpusIntermediateDir android.Path
Kris Alderf979ee32019-10-22 10:52:01 -070083 config android.Path
Mitch Phillipse1ee1a12019-10-17 19:20:41 -070084 installedSharedDeps []string
Mitch Phillipsda9a4632019-07-15 09:34:09 -070085}
86
87func (fuzz *fuzzBinary) linkerProps() []interface{} {
88 props := fuzz.binaryDecorator.linkerProps()
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -070089 props = append(props, &fuzz.Properties)
Mitch Phillipsda9a4632019-07-15 09:34:09 -070090 return props
91}
92
93func (fuzz *fuzzBinary) linkerInit(ctx BaseModuleContext) {
Mitch Phillipsda9a4632019-07-15 09:34:09 -070094 fuzz.binaryDecorator.linkerInit(ctx)
95}
96
97func (fuzz *fuzzBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
98 deps.StaticLibs = append(deps.StaticLibs,
99 config.LibFuzzerRuntimeLibrary(ctx.toolchain()))
100 deps = fuzz.binaryDecorator.linkerDeps(ctx, deps)
101 return deps
102}
103
104func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
105 flags = fuzz.binaryDecorator.linkerFlags(ctx, flags)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700106 // RunPaths on devices isn't instantiated by the base linker.
107 flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../lib`)
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700108 return flags
109}
110
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700111// This function performs a breadth-first search over the provided module's
112// dependencies using `visitDirectDeps` to enumerate all shared library
113// dependencies. We require breadth-first expansion, as otherwise we may
114// incorrectly use the core libraries (sanitizer runtimes, libc, libdl, etc.)
115// from a dependency. This may cause issues when dependencies have explicit
116// sanitizer tags, as we may get a dependency on an unsanitized libc, etc.
117func collectAllSharedDependencies(
118 module android.Module,
119 sharedDeps map[string]android.Path,
120 ctx android.SingletonContext) {
121 var fringe []android.Module
122
123 // Enumerate the first level of dependencies, as we discard all non-library
124 // modules in the BFS loop below.
125 ctx.VisitDirectDeps(module, func(dep android.Module) {
Mitch Phillipsf50bddb2019-11-12 14:03:31 -0800126 if isValidSharedDependency(dep, sharedDeps) {
127 fringe = append(fringe, dep)
128 }
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700129 })
130
131 for i := 0; i < len(fringe); i++ {
132 module := fringe[i]
Mitch Phillipsf50bddb2019-11-12 14:03:31 -0800133 if _, exists := sharedDeps[module.Name()]; exists {
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700134 continue
135 }
136
137 ccModule := module.(*Module)
138 sharedDeps[ccModule.Name()] = ccModule.UnstrippedOutputFile()
139 ctx.VisitDirectDeps(module, func(dep android.Module) {
Mitch Phillipsf50bddb2019-11-12 14:03:31 -0800140 if isValidSharedDependency(dep, sharedDeps) {
141 fringe = append(fringe, dep)
142 }
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700143 })
144 }
145}
146
147// This function takes a module and determines if it is a unique shared library
148// that should be installed in the fuzz target output directories. This function
149// returns true, unless:
150// - The module already exists in `sharedDeps`, or
151// - The module is not a shared library, or
152// - The module is a header, stub, or vendor-linked library.
153func isValidSharedDependency(
154 dependency android.Module,
155 sharedDeps map[string]android.Path) bool {
156 // TODO(b/144090547): We should be parsing these modules using
157 // ModuleDependencyTag instead of the current brute-force checking.
158
159 if linkable, ok := dependency.(LinkableInterface); !ok || // Discard non-linkables.
160 !linkable.CcLibraryInterface() || !linkable.Shared() || // Discard static libs.
161 linkable.UseVndk() || // Discard vendor linked libraries.
Mitch Phillipsf50bddb2019-11-12 14:03:31 -0800162 // Discard stubs libs (only CCLibrary variants). Prebuilt libraries should not
163 // be excluded on the basis of they're not CCLibrary()'s.
164 (linkable.CcLibrary() && linkable.BuildStubs()) {
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700165 return false
166 }
167
Mitch Phillipsf50bddb2019-11-12 14:03:31 -0800168 // We discarded module stubs libraries above, but the LLNDK prebuilts stubs
169 // libraries must be handled differently - by looking for the stubDecorator.
170 // Discard LLNDK prebuilts stubs as well.
171 if ccLibrary, isCcLibrary := dependency.(*Module); isCcLibrary {
172 if _, isLLndkStubLibrary := ccLibrary.linker.(*stubDecorator); isLLndkStubLibrary {
173 return false
174 }
175 }
176
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700177 // If this library has already been traversed, we don't need to do any more work.
178 if _, exists := sharedDeps[dependency.Name()]; exists {
179 return false
180 }
181 return true
182}
183
184func sharedLibraryInstallLocation(
185 libraryPath android.Path, isHost bool, archString string) string {
186 installLocation := "$(PRODUCT_OUT)/data"
187 if isHost {
188 installLocation = "$(HOST_OUT)"
189 }
190 installLocation = filepath.Join(
191 installLocation, "fuzz", archString, "lib", libraryPath.Base())
192 return installLocation
193}
194
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700195func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700196 fuzz.binaryDecorator.baseInstaller.dir = filepath.Join(
197 "fuzz", ctx.Target().Arch.ArchType.String(), ctx.ModuleName())
198 fuzz.binaryDecorator.baseInstaller.dir64 = filepath.Join(
199 "fuzz", ctx.Target().Arch.ArchType.String(), ctx.ModuleName())
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700200 fuzz.binaryDecorator.baseInstaller.install(ctx, file)
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700201
202 fuzz.corpus = android.PathsForModuleSrc(ctx, fuzz.Properties.Corpus)
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700203 builder := android.NewRuleBuilder()
204 intermediateDir := android.PathForModuleOut(ctx, "corpus")
205 for _, entry := range fuzz.corpus {
206 builder.Command().Text("cp").
207 Input(entry).
208 Output(intermediateDir.Join(ctx, entry.Base()))
209 }
210 builder.Build(pctx, ctx, "copy_corpus", "copy corpus")
211 fuzz.corpusIntermediateDir = intermediateDir
212
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700213 if fuzz.Properties.Dictionary != nil {
214 fuzz.dictionary = android.PathForModuleSrc(ctx, *fuzz.Properties.Dictionary)
215 if fuzz.dictionary.Ext() != ".dict" {
216 ctx.PropertyErrorf("dictionary",
217 "Fuzzer dictionary %q does not have '.dict' extension",
218 fuzz.dictionary.String())
219 }
220 }
Kris Alderf979ee32019-10-22 10:52:01 -0700221
222 if fuzz.Properties.Fuzz_config != nil {
Kris Alderdb97af42019-10-30 10:17:04 -0700223 configPath := android.PathForModuleOut(ctx, "config").Join(ctx, "config.json")
Kris Alderf979ee32019-10-22 10:52:01 -0700224 ctx.Build(pctx, android.BuildParams{
225 Rule: android.WriteFile,
226 Description: "fuzzer infrastructure configuration",
227 Output: configPath,
228 Args: map[string]string{
229 "content": fuzz.Properties.Fuzz_config.String(),
230 },
231 })
232 fuzz.config = configPath
233 }
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700234
235 // Grab the list of required shared libraries.
236 sharedLibraries := make(map[string]android.Path)
237 ctx.WalkDeps(func(child, parent android.Module) bool {
238 if isValidSharedDependency(child, sharedLibraries) {
239 sharedLibraries[child.Name()] = child.(*Module).UnstrippedOutputFile()
240 return true
241 }
242 return false
243 })
244
245 for _, lib := range sharedLibraries {
246 fuzz.installedSharedDeps = append(fuzz.installedSharedDeps,
247 sharedLibraryInstallLocation(
248 lib, ctx.Host(), ctx.Arch().ArchType.String()))
249 }
Mitch Phillips0553ba32019-11-11 07:03:42 -0800250
251 sort.Strings(fuzz.installedSharedDeps)
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700252}
253
254func NewFuzz(hod android.HostOrDeviceSupported) *Module {
255 module, binary := NewBinary(hod)
256
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700257 binary.baseInstaller = NewFuzzInstaller()
258 module.sanitize.SetSanitizer(fuzzer, true)
259
260 fuzz := &fuzzBinary{
261 binaryDecorator: binary,
262 baseCompiler: NewBaseCompiler(),
263 }
264 module.compiler = fuzz
265 module.linker = fuzz
266 module.installer = fuzz
Colin Crosseec9b282019-07-18 16:20:52 -0700267
268 // The fuzzer runtime is not present for darwin host modules, disable cc_fuzz modules when targeting darwin.
269 android.AddLoadHook(module, func(ctx android.LoadHookContext) {
Alex Light71123ec2019-07-24 13:34:19 -0700270 disableDarwinAndLinuxBionic := struct {
Colin Crosseec9b282019-07-18 16:20:52 -0700271 Target struct {
272 Darwin struct {
273 Enabled *bool
274 }
Alex Light71123ec2019-07-24 13:34:19 -0700275 Linux_bionic struct {
276 Enabled *bool
277 }
Colin Crosseec9b282019-07-18 16:20:52 -0700278 }
279 }{}
Alex Light71123ec2019-07-24 13:34:19 -0700280 disableDarwinAndLinuxBionic.Target.Darwin.Enabled = BoolPtr(false)
281 disableDarwinAndLinuxBionic.Target.Linux_bionic.Enabled = BoolPtr(false)
282 ctx.AppendProperties(&disableDarwinAndLinuxBionic)
Colin Crosseec9b282019-07-18 16:20:52 -0700283 })
284
Mitch Phillipsda9a4632019-07-15 09:34:09 -0700285 return module
286}
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700287
288// Responsible for generating GNU Make rules that package fuzz targets into
289// their architecture & target/host specific zip file.
290type fuzzPackager struct {
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700291 packages android.Paths
292 sharedLibInstallStrings []string
293 fuzzTargets map[string]bool
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700294}
295
296func fuzzPackagingFactory() android.Singleton {
297 return &fuzzPackager{}
298}
299
300type fileToZip struct {
301 SourceFilePath android.Path
302 DestinationPathPrefix string
303}
304
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700305type archAndLibraryKey struct {
306 ArchDir android.OutputPath
307 Library android.Path
308}
309
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700310func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
311 // Map between each architecture + host/device combination, and the files that
312 // need to be packaged (in the tuple of {source file, destination folder in
313 // archive}).
314 archDirs := make(map[android.OutputPath][]fileToZip)
315
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700316 // List of shared library dependencies for each architecture + host/device combo.
317 archSharedLibraryDeps := make(map[archAndLibraryKey]bool)
318
319 // List of individual fuzz targets, so that 'make fuzz' also installs the targets
320 // to the correct output directories as well.
321 s.fuzzTargets = make(map[string]bool)
322
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700323 ctx.VisitAllModules(func(module android.Module) {
324 // Discard non-fuzz targets.
325 ccModule, ok := module.(*Module)
326 if !ok {
327 return
328 }
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700329
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700330 fuzzModule, ok := ccModule.compiler.(*fuzzBinary)
331 if !ok {
332 return
333 }
334
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800335 // Discard vendor-NDK-linked + recovery modules, they're duplicates of
336 // fuzz targets we're going to package anyway.
337 if !ccModule.Enabled() || ccModule.Properties.PreventInstall ||
338 ccModule.UseVndk() || ccModule.InRecovery() {
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700339 return
340 }
341
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700342 s.fuzzTargets[module.Name()] = true
343
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700344 hostOrTargetString := "target"
345 if ccModule.Host() {
346 hostOrTargetString = "host"
347 }
348
349 archString := ccModule.Arch().ArchType.String()
350 archDir := android.PathForIntermediates(ctx, "fuzz", hostOrTargetString, archString)
351
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700352 // Grab the list of required shared libraries.
353 sharedLibraries := make(map[string]android.Path)
354 collectAllSharedDependencies(module, sharedLibraries, ctx)
355
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800356 var files []fileToZip
357 builder := android.NewRuleBuilder()
358
359 // Package the corpora into a zipfile.
360 if fuzzModule.corpus != nil {
361 corpusZip := archDir.Join(ctx, module.Name()+"_seed_corpus.zip")
362 command := builder.Command().BuiltTool(ctx, "soong_zip").
363 Flag("-j").
364 FlagWithOutput("-o ", corpusZip)
365 command.FlagWithRspFileInputList("-l ", fuzzModule.corpus)
366 files = append(files, fileToZip{corpusZip, ""})
367 }
368
369 // Find and mark all the transiently-dependent shared libraries for
370 // packaging.
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700371 for _, library := range sharedLibraries {
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800372 files = append(files, fileToZip{library, "lib"})
Mitch Phillips13ed3f52019-11-12 11:12:10 -0800373
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700374 if _, exists := archSharedLibraryDeps[archAndLibraryKey{archDir, library}]; exists {
375 continue
376 }
377
378 // For each architecture-specific shared library dependency, we need to
379 // install it to the output directory. Setup the install destination here,
380 // which will be used by $(copy-many-files) in the Make backend.
381 archSharedLibraryDeps[archAndLibraryKey{archDir, library}] = true
382 installDestination := sharedLibraryInstallLocation(
383 library, ccModule.Host(), archString)
384 // Escape all the variables, as the install destination here will be called
385 // via. $(eval) in Make.
386 installDestination = strings.ReplaceAll(
387 installDestination, "$", "$$")
388 s.sharedLibInstallStrings = append(s.sharedLibInstallStrings,
389 library.String()+":"+installDestination)
390 }
391
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700392 // The executable.
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800393 files = append(files, fileToZip{ccModule.UnstrippedOutputFile(), ""})
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700394
395 // The dictionary.
396 if fuzzModule.dictionary != nil {
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800397 files = append(files, fileToZip{fuzzModule.dictionary, ""})
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700398 }
Kris Alderf979ee32019-10-22 10:52:01 -0700399
400 // Additional fuzz config.
401 if fuzzModule.config != nil {
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800402 files = append(files, fileToZip{fuzzModule.config, ""})
Kris Alderf979ee32019-10-22 10:52:01 -0700403 }
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800404
405 fuzzZip := archDir.Join(ctx, module.Name()+".zip")
406 command := builder.Command().BuiltTool(ctx, "soong_zip").
407 Flag("-j").
408 FlagWithOutput("-o ", fuzzZip)
409 for _, file := range files {
410 if file.DestinationPathPrefix != "" {
411 command.FlagWithArg("-P ", file.DestinationPathPrefix)
412 } else {
413 command.Flag("-P ''")
414 }
415 command.FlagWithInput("-f ", file.SourceFilePath)
416 }
417
418 builder.Build(pctx, ctx, "create-"+fuzzZip.String(),
419 "Package "+module.Name()+" for "+archString+"-"+hostOrTargetString)
420
421 archDirs[archDir] = append(archDirs[archDir], fileToZip{fuzzZip, ""})
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700422 })
423
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700424 for archDir, filesToZip := range archDirs {
425 arch := archDir.Base()
426 hostOrTarget := filepath.Base(filepath.Dir(archDir.String()))
427 builder := android.NewRuleBuilder()
428 outputFile := android.PathForOutput(ctx, "fuzz-"+hostOrTarget+"-"+arch+".zip")
Mitch Phillipsa0a5e192019-09-27 14:00:06 -0700429 s.packages = append(s.packages, outputFile)
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700430
431 command := builder.Command().BuiltTool(ctx, "soong_zip").
432 Flag("-j").
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800433 FlagWithOutput("-o ", outputFile).
434 Flag("-L 0") // No need to try and re-compress the zipfiles.
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700435
436 for _, fileToZip := range filesToZip {
Mitch Phillips2edbe8e2019-11-13 08:36:07 -0800437 if fileToZip.DestinationPathPrefix != "" {
438 command.FlagWithArg("-P ", fileToZip.DestinationPathPrefix)
439 } else {
440 command.Flag("-P ''")
441 }
442 command.FlagWithInput("-f ", fileToZip.SourceFilePath)
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700443 }
444
445 builder.Build(pctx, ctx, "create-fuzz-package-"+arch+"-"+hostOrTarget,
446 "Create fuzz target packages for "+arch+"-"+hostOrTarget)
447 }
Mitch Phillipsa0a5e192019-09-27 14:00:06 -0700448}
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700449
Mitch Phillipsa0a5e192019-09-27 14:00:06 -0700450func (s *fuzzPackager) MakeVars(ctx android.MakeVarsContext) {
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700451 packages := s.packages.Strings()
452 sort.Strings(packages)
453 sort.Strings(s.sharedLibInstallStrings)
Mitch Phillipsa0a5e192019-09-27 14:00:06 -0700454 // TODO(mitchp): Migrate this to use MakeVarsContext::DistForGoal() when it's
455 // ready to handle phony targets created in Soong. In the meantime, this
456 // exports the phony 'fuzz' target and dependencies on packages to
457 // core/main.mk so that we can use dist-for-goals.
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700458 ctx.Strict("SOONG_FUZZ_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
459 ctx.Strict("FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS",
460 strings.Join(s.sharedLibInstallStrings, " "))
461
462 // Preallocate the slice of fuzz targets to minimise memory allocations.
463 fuzzTargets := make([]string, 0, len(s.fuzzTargets))
464 for target, _ := range s.fuzzTargets {
465 fuzzTargets = append(fuzzTargets, target)
466 }
467 sort.Strings(fuzzTargets)
468 ctx.Strict("ALL_FUZZ_TARGETS", strings.Join(fuzzTargets, " "))
Mitch Phillipsd3254b42019-09-24 13:03:28 -0700469}