| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [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 ( | 
| Martin Stjernholm | 14ee832 | 2020-09-21 21:45:49 +0100 | [diff] [blame] | 18 | 	"path/filepath" | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 0d99045 | 2021-08-11 16:46:13 +0000 | [diff] [blame] | 19 |  | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 20 | 	"github.com/google/blueprint/proptools" | 
 | 21 |  | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 0d99045 | 2021-08-11 16:46:13 +0000 | [diff] [blame] | 22 | 	"android/soong/android" | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 23 | ) | 
 | 24 |  | 
 | 25 | func init() { | 
| Paul Duffin | 59986b2 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 26 | 	RegisterPrebuiltBuildComponents(android.InitRegistrationContext) | 
 | 27 | } | 
 | 28 |  | 
 | 29 | func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) { | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 30 | 	ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory) | 
| Paul Duffin | 59986b2 | 2019-12-19 14:38:36 +0000 | [diff] [blame] | 31 | 	ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory) | 
 | 32 | 	ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory) | 
| Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 33 | 	ctx.RegisterModuleType("cc_prebuilt_test_library_shared", PrebuiltSharedTestLibraryFactory) | 
| Colin Cross | c5075e9 | 2022-12-05 16:46:39 -0800 | [diff] [blame] | 34 | 	ctx.RegisterModuleType("cc_prebuilt_object", PrebuiltObjectFactory) | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | b12ff59 | 2022-09-01 15:04:04 +0000 | [diff] [blame] | 35 | 	ctx.RegisterModuleType("cc_prebuilt_binary", PrebuiltBinaryFactory) | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 36 | } | 
 | 37 |  | 
 | 38 | type prebuiltLinkerInterface interface { | 
 | 39 | 	Name(string) string | 
 | 40 | 	prebuilt() *android.Prebuilt | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 41 | 	sourceModuleName() string | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 42 | } | 
 | 43 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 44 | type prebuiltLinkerProperties struct { | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 45 | 	// Name of the source soong module that gets shadowed by this prebuilt | 
 | 46 | 	// If unspecified, follows the naming convention that the source module of | 
 | 47 | 	// the prebuilt is Name() without "prebuilt_" prefix | 
 | 48 | 	Source_module_name *string | 
 | 49 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 50 | 	// a prebuilt library or binary. Can reference a genrule module that generates an executable file. | 
 | 51 | 	Srcs []string `android:"path,arch_variant"` | 
 | 52 |  | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 53 | 	Sanitized Sanitized `android:"arch_variant"` | 
 | 54 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 55 | 	// Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined | 
 | 56 | 	// symbols, etc), default true. | 
 | 57 | 	Check_elf_files *bool | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 58 |  | 
| Pierre-Clément Tosi | 6f630ae | 2022-08-10 09:25:54 +0100 | [diff] [blame] | 59 | 	// if set, add an extra objcopy --prefix-symbols= step | 
 | 60 | 	Prefix_symbols *string | 
 | 61 |  | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 62 | 	// Optionally provide an import library if this is a Windows PE DLL prebuilt. | 
 | 63 | 	// This is needed only if this library is linked by other modules in build time. | 
 | 64 | 	// Only makes sense for the Windows target. | 
 | 65 | 	Windows_import_lib *string `android:"path,arch_variant"` | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 66 | } | 
 | 67 |  | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 68 | type prebuiltLinker struct { | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 69 | 	android.Prebuilt | 
| Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 70 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 71 | 	properties prebuiltLinkerProperties | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 72 | } | 
 | 73 |  | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 74 | func (p *prebuiltLinker) prebuilt() *android.Prebuilt { | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 75 | 	return &p.Prebuilt | 
 | 76 | } | 
 | 77 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 78 | func (p *prebuiltLinker) PrebuiltSrcs() []string { | 
 | 79 | 	return p.properties.Srcs | 
 | 80 | } | 
 | 81 |  | 
| Colin Cross | 33b2fb7 | 2019-05-14 14:07:01 -0700 | [diff] [blame] | 82 | type prebuiltLibraryInterface interface { | 
 | 83 | 	libraryInterface | 
 | 84 | 	prebuiltLinkerInterface | 
 | 85 | 	disablePrebuilt() | 
 | 86 | } | 
 | 87 |  | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 88 | type prebuiltLibraryLinker struct { | 
 | 89 | 	*libraryDecorator | 
 | 90 | 	prebuiltLinker | 
 | 91 | } | 
 | 92 |  | 
 | 93 | var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil) | 
| Colin Cross | 33b2fb7 | 2019-05-14 14:07:01 -0700 | [diff] [blame] | 94 | var _ prebuiltLibraryInterface = (*prebuiltLibraryLinker)(nil) | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 95 |  | 
| Yi Kong | 0098166 | 2018-08-13 16:02:49 -0700 | [diff] [blame] | 96 | func (p *prebuiltLibraryLinker) linkerInit(ctx BaseModuleContext) {} | 
 | 97 |  | 
 | 98 | func (p *prebuiltLibraryLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { | 
| Logan Chien | c7f797e | 2019-01-14 15:35:08 +0800 | [diff] [blame] | 99 | 	return p.libraryDecorator.linkerDeps(ctx, deps) | 
| Yi Kong | 0098166 | 2018-08-13 16:02:49 -0700 | [diff] [blame] | 100 | } | 
 | 101 |  | 
 | 102 | func (p *prebuiltLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { | 
| Colin Cross | 1ab10a7 | 2018-09-04 11:02:37 -0700 | [diff] [blame] | 103 | 	return flags | 
| Yi Kong | 0098166 | 2018-08-13 16:02:49 -0700 | [diff] [blame] | 104 | } | 
 | 105 |  | 
 | 106 | func (p *prebuiltLibraryLinker) linkerProps() []interface{} { | 
 | 107 | 	return p.libraryDecorator.linkerProps() | 
 | 108 | } | 
 | 109 |  | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 110 | func (p *prebuiltLibraryLinker) link(ctx ModuleContext, | 
| Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 111 | 	flags Flags, deps PathDeps, objs Objects) android.Path { | 
| Paul Duffin | f5ea9e1 | 2020-02-21 10:57:00 +0000 | [diff] [blame] | 112 |  | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 113 | 	p.libraryDecorator.flagExporter.exportIncludes(ctx) | 
 | 114 | 	p.libraryDecorator.flagExporter.reexportDirs(deps.ReexportedDirs...) | 
 | 115 | 	p.libraryDecorator.flagExporter.reexportSystemDirs(deps.ReexportedSystemDirs...) | 
 | 116 | 	p.libraryDecorator.flagExporter.reexportFlags(deps.ReexportedFlags...) | 
 | 117 | 	p.libraryDecorator.flagExporter.reexportDeps(deps.ReexportedDeps...) | 
 | 118 | 	p.libraryDecorator.flagExporter.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...) | 
 | 119 |  | 
 | 120 | 	p.libraryDecorator.flagExporter.setProvider(ctx) | 
| Paul Duffin | f5ea9e1 | 2020-02-21 10:57:00 +0000 | [diff] [blame] | 121 |  | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 122 | 	// TODO(ccross): verify shared library dependencies | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 123 | 	srcs := p.prebuiltSrcs(ctx) | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 124 | 	if len(srcs) > 0 { | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 125 | 		if len(srcs) > 1 { | 
 | 126 | 			ctx.PropertyErrorf("srcs", "multiple prebuilt source files") | 
 | 127 | 			return nil | 
 | 128 | 		} | 
 | 129 |  | 
| Jiyong Park | 892a98f | 2020-12-14 09:20:00 +0900 | [diff] [blame] | 130 | 		p.libraryDecorator.exportVersioningMacroIfNeeded(ctx) | 
 | 131 |  | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 132 | 		in := android.PathForModuleSrc(ctx, srcs[0]) | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 133 |  | 
| Pierre-Clément Tosi | 6f630ae | 2022-08-10 09:25:54 +0100 | [diff] [blame] | 134 | 		if String(p.prebuiltLinker.properties.Prefix_symbols) != "" { | 
 | 135 | 			prefixed := android.PathForModuleOut(ctx, "prefixed", srcs[0]) | 
 | 136 | 			transformBinaryPrefixSymbols(ctx, String(p.prebuiltLinker.properties.Prefix_symbols), | 
 | 137 | 				in, flagsToBuilderFlags(flags), prefixed) | 
 | 138 | 			in = prefixed | 
 | 139 | 		} | 
 | 140 |  | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 141 | 		if p.static() { | 
| Colin Cross | c85750b | 2022-04-21 12:50:51 -0700 | [diff] [blame] | 142 | 			depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build() | 
| Colin Cross | 4021302 | 2023-12-13 15:19:49 -0800 | [diff] [blame] | 143 | 			android.SetProvider(ctx, StaticLibraryInfoProvider, StaticLibraryInfo{ | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 144 | 				StaticLibrary: in, | 
 | 145 |  | 
 | 146 | 				TransitiveStaticLibrariesForOrdering: depSet, | 
 | 147 | 			}) | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 148 | 			return in | 
 | 149 | 		} | 
 | 150 |  | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 151 | 		if p.shared() { | 
| Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 152 | 			p.unstrippedOutputFile = in | 
| Colin Cross | 0fd6a41 | 2019-08-16 14:22:10 -0700 | [diff] [blame] | 153 | 			libName := p.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix() | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 154 | 			outputFile := android.PathForModuleOut(ctx, libName) | 
 | 155 | 			var implicits android.Paths | 
 | 156 |  | 
| Thiébaud Weksteen | d458745 | 2020-08-19 14:53:01 +0200 | [diff] [blame] | 157 | 			if p.stripper.NeedsStrip(ctx) { | 
 | 158 | 				stripFlags := flagsToStripFlags(flags) | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 159 | 				stripped := android.PathForModuleOut(ctx, "stripped", libName) | 
| Thiébaud Weksteen | d458745 | 2020-08-19 14:53:01 +0200 | [diff] [blame] | 160 | 				p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, stripFlags) | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 161 | 				in = stripped | 
 | 162 | 			} | 
 | 163 |  | 
| Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 164 | 			// Optimize out relinking against shared libraries whose interface hasn't changed by | 
 | 165 | 			// depending on a table of contents file instead of the library itself. | 
 | 166 | 			tocFile := android.PathForModuleOut(ctx, libName+".toc") | 
 | 167 | 			p.tocFile = android.OptionalPathForPath(tocFile) | 
| Ivan Lozano | 7b0781d | 2021-11-03 15:30:18 -0400 | [diff] [blame] | 168 | 			TransformSharedObjectToToc(ctx, outputFile, tocFile) | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 169 |  | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 170 | 			if ctx.Windows() && p.properties.Windows_import_lib != nil { | 
 | 171 | 				// Consumers of this library actually links to the import library in build | 
 | 172 | 				// time and dynamically links to the DLL in run time. i.e. | 
 | 173 | 				// a.exe <-- static link --> foo.lib <-- dynamic link --> foo.dll | 
 | 174 | 				importLibSrc := android.PathForModuleSrc(ctx, String(p.properties.Windows_import_lib)) | 
 | 175 | 				importLibName := p.libraryDecorator.getLibName(ctx) + ".lib" | 
 | 176 | 				importLibOutputFile := android.PathForModuleOut(ctx, importLibName) | 
 | 177 | 				implicits = append(implicits, importLibOutputFile) | 
 | 178 |  | 
 | 179 | 				ctx.Build(pctx, android.BuildParams{ | 
 | 180 | 					Rule:        android.Cp, | 
 | 181 | 					Description: "prebuilt import library", | 
 | 182 | 					Input:       importLibSrc, | 
 | 183 | 					Output:      importLibOutputFile, | 
 | 184 | 					Args: map[string]string{ | 
 | 185 | 						"cpFlags": "-L", | 
 | 186 | 					}, | 
 | 187 | 				}) | 
 | 188 | 			} | 
 | 189 |  | 
 | 190 | 			ctx.Build(pctx, android.BuildParams{ | 
 | 191 | 				Rule:        android.Cp, | 
 | 192 | 				Description: "prebuilt shared library", | 
 | 193 | 				Implicits:   implicits, | 
 | 194 | 				Input:       in, | 
 | 195 | 				Output:      outputFile, | 
 | 196 | 				Args: map[string]string{ | 
 | 197 | 					"cpFlags": "-L", | 
 | 198 | 				}, | 
 | 199 | 			}) | 
 | 200 |  | 
| Colin Cross | 4021302 | 2023-12-13 15:19:49 -0800 | [diff] [blame] | 201 | 			android.SetProvider(ctx, SharedLibraryInfoProvider, SharedLibraryInfo{ | 
| Liz Kammer | ef6dfea | 2021-06-08 15:37:09 -0400 | [diff] [blame] | 202 | 				SharedLibrary: outputFile, | 
 | 203 | 				Target:        ctx.Target(), | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 204 |  | 
 | 205 | 				TableOfContents: p.tocFile, | 
 | 206 | 			}) | 
 | 207 |  | 
| Martin Stjernholm | 5bdf2d5 | 2022-02-06 22:07:45 +0000 | [diff] [blame] | 208 | 			// TODO(b/220898484): Mainline module sdk prebuilts of stub libraries use a stub | 
| Jooyung Han | e5f063e | 2023-03-23 14:31:19 +0900 | [diff] [blame] | 209 | 			// library as their source and must not be installed, but other prebuilts like | 
 | 210 | 			// libclang_rt.* libraries set `stubs` property because they are LLNDK libraries, | 
 | 211 | 			// but use an implementation library as their source and need to be installed. | 
 | 212 | 			// This discrepancy should be resolved without the prefix hack below. | 
 | 213 | 			isModuleSdkPrebuilts := android.HasAnyPrefix(ctx.ModuleDir(), []string{ | 
 | 214 | 				"prebuilts/runtime/mainline/", "prebuilts/module_sdk/"}) | 
 | 215 | 			if p.hasStubsVariants() && !p.buildStubs() && !ctx.Host() && isModuleSdkPrebuilts { | 
| Jingwen Chen | 8ac7d7d | 2023-03-20 11:05:16 +0000 | [diff] [blame] | 216 | 				ctx.Module().MakeUninstallable() | 
| Martin Stjernholm | 5bdf2d5 | 2022-02-06 22:07:45 +0000 | [diff] [blame] | 217 | 			} | 
 | 218 |  | 
| Yo Chiang | a3ad9b2 | 2020-03-18 14:19:07 +0800 | [diff] [blame] | 219 | 			return outputFile | 
 | 220 | 		} | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 221 | 	} | 
 | 222 |  | 
| Colin Cross | 649d817 | 2020-12-10 12:30:21 -0800 | [diff] [blame] | 223 | 	if p.header() { | 
| Colin Cross | 4021302 | 2023-12-13 15:19:49 -0800 | [diff] [blame] | 224 | 		android.SetProvider(ctx, HeaderLibraryInfoProvider, HeaderLibraryInfo{}) | 
| Colin Cross | 649d817 | 2020-12-10 12:30:21 -0800 | [diff] [blame] | 225 |  | 
| Martin Stjernholm | d51cb5c | 2021-11-30 18:49:03 +0000 | [diff] [blame] | 226 | 		// Need to return an output path so that the AndroidMk logic doesn't skip | 
 | 227 | 		// the prebuilt header. For compatibility, in case Android.mk files use a | 
 | 228 | 		// header lib in LOCAL_STATIC_LIBRARIES, create an empty ar file as | 
 | 229 | 		// placeholder, just like non-prebuilt header modules do in linkStatic(). | 
 | 230 | 		ph := android.PathForModuleOut(ctx, ctx.ModuleName()+staticLibraryExtension) | 
 | 231 | 		transformObjToStaticLib(ctx, nil, nil, builderFlags{}, ph, nil, nil) | 
 | 232 | 		return ph | 
| Colin Cross | 649d817 | 2020-12-10 12:30:21 -0800 | [diff] [blame] | 233 | 	} | 
 | 234 |  | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 235 | 	return nil | 
 | 236 | } | 
 | 237 |  | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 238 | func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string { | 
 | 239 | 	sanitize := ctx.Module().(*Module).sanitize | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 240 | 	srcs := p.properties.Srcs | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 241 | 	srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...) | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 242 | 	if p.static() { | 
 | 243 | 		srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...) | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 244 | 		srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...) | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 245 | 	} | 
 | 246 | 	if p.shared() { | 
 | 247 | 		srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...) | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 248 | 		srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...) | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 249 | 	} | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 250 | 	return srcs | 
 | 251 | } | 
 | 252 |  | 
| Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 253 | func (p *prebuiltLibraryLinker) shared() bool { | 
 | 254 | 	return p.libraryDecorator.shared() | 
 | 255 | } | 
 | 256 |  | 
| Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 257 | func (p *prebuiltLibraryLinker) nativeCoverage() bool { | 
 | 258 | 	return false | 
 | 259 | } | 
 | 260 |  | 
| Colin Cross | 33b2fb7 | 2019-05-14 14:07:01 -0700 | [diff] [blame] | 261 | func (p *prebuiltLibraryLinker) disablePrebuilt() { | 
 | 262 | 	p.properties.Srcs = nil | 
| Ryan Prichard | 21e2c10 | 2024-02-28 18:59:30 -0800 | [diff] [blame] | 263 | 	p.properties.Sanitized.None.Srcs = nil | 
 | 264 | 	p.properties.Sanitized.Address.Srcs = nil | 
 | 265 | 	p.properties.Sanitized.Hwaddress.Srcs = nil | 
| Colin Cross | 33b2fb7 | 2019-05-14 14:07:01 -0700 | [diff] [blame] | 266 | } | 
 | 267 |  | 
| Jiyong Park | 892a98f | 2020-12-14 09:20:00 +0900 | [diff] [blame] | 268 | // Implements versionedInterface | 
 | 269 | func (p *prebuiltLibraryLinker) implementationModuleName(name string) string { | 
| Paul Duffin | 9804da0 | 2021-10-26 10:42:42 +0100 | [diff] [blame] | 270 | 	return android.RemoveOptionalPrebuiltPrefix(name) | 
| Jiyong Park | 892a98f | 2020-12-14 09:20:00 +0900 | [diff] [blame] | 271 | } | 
 | 272 |  | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 273 | func NewPrebuiltLibrary(hod android.HostOrDeviceSupported, srcsProperty string) (*Module, *libraryDecorator) { | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 274 | 	module, library := NewLibrary(hod) | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 275 | 	module.compiler = nil | 
 | 276 |  | 
 | 277 | 	prebuilt := &prebuiltLibraryLinker{ | 
 | 278 | 		libraryDecorator: library, | 
 | 279 | 	} | 
 | 280 | 	module.linker = prebuilt | 
| Colin Cross | 31076b3 | 2020-10-23 17:22:06 -0700 | [diff] [blame] | 281 | 	module.library = prebuilt | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 282 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 283 | 	module.AddProperties(&prebuilt.properties) | 
 | 284 |  | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 285 | 	if srcsProperty == "" { | 
 | 286 | 		android.InitPrebuiltModuleWithoutSrcs(module) | 
 | 287 | 	} else { | 
 | 288 | 		srcsSupplier := func(ctx android.BaseModuleContext, _ android.Module) []string { | 
 | 289 | 			return prebuilt.prebuiltSrcs(ctx) | 
 | 290 | 		} | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 291 |  | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 292 | 		android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, srcsProperty) | 
 | 293 | 	} | 
| Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 294 |  | 
| Paul Duffin | ac6e608 | 2019-12-11 15:22:32 +0000 | [diff] [blame] | 295 | 	return module, library | 
 | 296 | } | 
 | 297 |  | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 298 | // cc_prebuilt_library installs a precompiled shared library that are | 
 | 299 | // listed in the srcs property in the device's directory. | 
 | 300 | func PrebuiltLibraryFactory() android.Module { | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 301 | 	module, _ := NewPrebuiltLibrary(android.HostAndDeviceSupported, "srcs") | 
| Paul Duffin | bce90da | 2020-03-12 20:17:14 +0000 | [diff] [blame] | 302 |  | 
 | 303 | 	// Prebuilt shared libraries can be included in APEXes | 
 | 304 | 	android.InitApexModule(module) | 
 | 305 |  | 
 | 306 | 	return module.Init() | 
 | 307 | } | 
 | 308 |  | 
| Paul Duffin | ac6e608 | 2019-12-11 15:22:32 +0000 | [diff] [blame] | 309 | // cc_prebuilt_library_shared installs a precompiled shared library that are | 
 | 310 | // listed in the srcs property in the device's directory. | 
 | 311 | func PrebuiltSharedLibraryFactory() android.Module { | 
 | 312 | 	module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported) | 
 | 313 | 	return module.Init() | 
 | 314 | } | 
 | 315 |  | 
| Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 316 | // cc_prebuilt_test_library_shared installs a precompiled shared library | 
 | 317 | // to be used as a data dependency of a test-related module (such as cc_test, or | 
 | 318 | // cc_test_library). | 
 | 319 | func PrebuiltSharedTestLibraryFactory() android.Module { | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 320 | 	module, library := NewPrebuiltLibrary(android.HostAndDeviceSupported, "srcs") | 
| Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 321 | 	library.BuildOnlyShared() | 
 | 322 | 	library.baseInstaller = NewTestInstaller() | 
 | 323 | 	return module.Init() | 
 | 324 | } | 
 | 325 |  | 
| Paul Duffin | ac6e608 | 2019-12-11 15:22:32 +0000 | [diff] [blame] | 326 | func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 327 | 	module, library := NewPrebuiltLibrary(hod, "srcs") | 
| Paul Duffin | ac6e608 | 2019-12-11 15:22:32 +0000 | [diff] [blame] | 328 | 	library.BuildOnlyShared() | 
 | 329 |  | 
 | 330 | 	// Prebuilt shared libraries can be included in APEXes | 
 | 331 | 	android.InitApexModule(module) | 
| Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 332 |  | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 333 | 	return module, library | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 334 | } | 
 | 335 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 336 | // cc_prebuilt_library_static installs a precompiled static library that are | 
 | 337 | // listed in the srcs property in the device's directory. | 
| Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 338 | func PrebuiltStaticLibraryFactory() android.Module { | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 339 | 	module, _ := NewPrebuiltStaticLibrary(android.HostAndDeviceSupported) | 
 | 340 | 	return module.Init() | 
 | 341 | } | 
 | 342 |  | 
 | 343 | func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { | 
| Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 344 | 	module, library := NewPrebuiltLibrary(hod, "srcs") | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 345 | 	library.BuildOnlyStatic() | 
| Trevor Radcliffe | 5d6fa4d | 2022-05-17 21:59:36 +0000 | [diff] [blame] | 346 |  | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 347 | 	return module, library | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 348 | } | 
 | 349 |  | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 350 | type prebuiltObjectProperties struct { | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 351 | 	// Name of the source soong module that gets shadowed by this prebuilt | 
 | 352 | 	// If unspecified, follows the naming convention that the source module of | 
 | 353 | 	// the prebuilt is Name() without "prebuilt_" prefix | 
 | 354 | 	Source_module_name *string | 
 | 355 | 	Srcs               []string `android:"path,arch_variant"` | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 356 | } | 
 | 357 |  | 
 | 358 | type prebuiltObjectLinker struct { | 
 | 359 | 	android.Prebuilt | 
 | 360 | 	objectLinker | 
 | 361 |  | 
 | 362 | 	properties prebuiltObjectProperties | 
 | 363 | } | 
 | 364 |  | 
 | 365 | func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt { | 
 | 366 | 	return &p.Prebuilt | 
 | 367 | } | 
 | 368 |  | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 369 | func (p *prebuiltObjectLinker) sourceModuleName() string { | 
 | 370 | 	return proptools.String(p.properties.Source_module_name) | 
 | 371 | } | 
 | 372 |  | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 373 | var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil) | 
 | 374 |  | 
 | 375 | func (p *prebuiltObjectLinker) link(ctx ModuleContext, | 
 | 376 | 	flags Flags, deps PathDeps, objs Objects) android.Path { | 
 | 377 | 	if len(p.properties.Srcs) > 0 { | 
| Colin Cross | ee02aed | 2022-04-15 15:16:02 -0700 | [diff] [blame] | 378 | 		// Copy objects to a name matching the final installed name | 
 | 379 | 		in := p.Prebuilt.SingleSourcePath(ctx) | 
 | 380 | 		outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".o") | 
 | 381 | 		ctx.Build(pctx, android.BuildParams{ | 
 | 382 | 			Rule:        android.CpExecutable, | 
 | 383 | 			Description: "prebuilt", | 
 | 384 | 			Output:      outputFile, | 
 | 385 | 			Input:       in, | 
 | 386 | 		}) | 
 | 387 | 		return outputFile | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 388 | 	} | 
 | 389 | 	return nil | 
 | 390 | } | 
 | 391 |  | 
| Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 392 | func (p *prebuiltObjectLinker) object() bool { | 
 | 393 | 	return true | 
 | 394 | } | 
 | 395 |  | 
| Colin Cross | 7cabd42 | 2021-06-25 14:21:04 -0700 | [diff] [blame] | 396 | func NewPrebuiltObject(hod android.HostOrDeviceSupported) *Module { | 
 | 397 | 	module := newObject(hod) | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 398 | 	prebuilt := &prebuiltObjectLinker{ | 
 | 399 | 		objectLinker: objectLinker{ | 
 | 400 | 			baseLinker: NewBaseLinker(nil), | 
 | 401 | 		}, | 
 | 402 | 	} | 
 | 403 | 	module.linker = prebuilt | 
 | 404 | 	module.AddProperties(&prebuilt.properties) | 
 | 405 | 	android.InitPrebuiltModule(module, &prebuilt.properties.Srcs) | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 406 | 	return module | 
 | 407 | } | 
 | 408 |  | 
| Colin Cross | c5075e9 | 2022-12-05 16:46:39 -0800 | [diff] [blame] | 409 | func PrebuiltObjectFactory() android.Module { | 
| Colin Cross | 7cabd42 | 2021-06-25 14:21:04 -0700 | [diff] [blame] | 410 | 	module := NewPrebuiltObject(android.HostAndDeviceSupported) | 
| Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 411 | 	return module.Init() | 
 | 412 | } | 
 | 413 |  | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 414 | type prebuiltBinaryLinker struct { | 
 | 415 | 	*binaryDecorator | 
 | 416 | 	prebuiltLinker | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 417 |  | 
 | 418 | 	toolPath android.OptionalPath | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 419 | } | 
 | 420 |  | 
 | 421 | var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil) | 
 | 422 |  | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 423 | func (p *prebuiltBinaryLinker) hostToolPath() android.OptionalPath { | 
 | 424 | 	return p.toolPath | 
 | 425 | } | 
 | 426 |  | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 427 | func (p *prebuiltBinaryLinker) link(ctx ModuleContext, | 
 | 428 | 	flags Flags, deps PathDeps, objs Objects) android.Path { | 
 | 429 | 	// TODO(ccross): verify shared library dependencies | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 430 | 	if len(p.properties.Srcs) > 0 { | 
| Colin Cross | 88f6fef | 2018-09-05 14:20:03 -0700 | [diff] [blame] | 431 | 		fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix() | 
 | 432 | 		in := p.Prebuilt.SingleSourcePath(ctx) | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 433 | 		outputFile := android.PathForModuleOut(ctx, fileName) | 
| Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 434 | 		p.unstrippedOutputFile = in | 
 | 435 |  | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 436 | 		if ctx.Host() { | 
 | 437 | 			// Host binaries are symlinked to their prebuilt source locations. That | 
 | 438 | 			// way they are executed directly from there so the linker resolves their | 
 | 439 | 			// shared library dependencies relative to that location (using | 
 | 440 | 			// $ORIGIN/../lib(64):$ORIGIN/lib(64) as RUNPATH). This way the prebuilt | 
 | 441 | 			// repository can supply the expected versions of the shared libraries | 
 | 442 | 			// without interference from what is in the out tree. | 
| Colin Cross | 94921e7 | 2017-08-08 16:20:15 -0700 | [diff] [blame] | 443 |  | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 444 | 			// These shared lib paths may point to copies of the libs in | 
 | 445 | 			// .intermediates, which isn't where the binary will load them from, but | 
 | 446 | 			// it's fine for dependency tracking. If a library dependency is updated, | 
 | 447 | 			// the symlink will get a new timestamp, along with any installed symlinks | 
 | 448 | 			// handled in make. | 
 | 449 | 			sharedLibPaths := deps.EarlySharedLibs | 
 | 450 | 			sharedLibPaths = append(sharedLibPaths, deps.SharedLibs...) | 
 | 451 | 			sharedLibPaths = append(sharedLibPaths, deps.LateSharedLibs...) | 
 | 452 |  | 
| Martin Stjernholm | 14ee832 | 2020-09-21 21:45:49 +0100 | [diff] [blame] | 453 | 			var fromPath = in.String() | 
 | 454 | 			if !filepath.IsAbs(fromPath) { | 
 | 455 | 				fromPath = "$$PWD/" + fromPath | 
 | 456 | 			} | 
 | 457 |  | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 458 | 			ctx.Build(pctx, android.BuildParams{ | 
 | 459 | 				Rule:      android.Symlink, | 
 | 460 | 				Output:    outputFile, | 
 | 461 | 				Input:     in, | 
 | 462 | 				Implicits: sharedLibPaths, | 
 | 463 | 				Args: map[string]string{ | 
| Martin Stjernholm | 14ee832 | 2020-09-21 21:45:49 +0100 | [diff] [blame] | 464 | 					"fromPath": fromPath, | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 465 | 				}, | 
 | 466 | 			}) | 
 | 467 |  | 
 | 468 | 			p.toolPath = android.OptionalPathForPath(outputFile) | 
 | 469 | 		} else { | 
 | 470 | 			if p.stripper.NeedsStrip(ctx) { | 
 | 471 | 				stripped := android.PathForModuleOut(ctx, "stripped", fileName) | 
 | 472 | 				p.stripper.StripExecutableOrSharedLib(ctx, in, stripped, flagsToStripFlags(flags)) | 
 | 473 | 				in = stripped | 
 | 474 | 			} | 
 | 475 |  | 
 | 476 | 			// Copy binaries to a name matching the final installed name | 
 | 477 | 			ctx.Build(pctx, android.BuildParams{ | 
 | 478 | 				Rule:        android.CpExecutable, | 
 | 479 | 				Description: "prebuilt", | 
 | 480 | 				Output:      outputFile, | 
 | 481 | 				Input:       in, | 
 | 482 | 			}) | 
 | 483 | 		} | 
| Colin Cross | 94921e7 | 2017-08-08 16:20:15 -0700 | [diff] [blame] | 484 |  | 
 | 485 | 		return outputFile | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 486 | 	} | 
 | 487 |  | 
 | 488 | 	return nil | 
 | 489 | } | 
 | 490 |  | 
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 491 | func (p *prebuiltBinaryLinker) binary() bool { | 
 | 492 | 	return true | 
 | 493 | } | 
 | 494 |  | 
| Patrice Arruda | 3554a98 | 2019-03-27 19:09:10 -0700 | [diff] [blame] | 495 | // cc_prebuilt_binary installs a precompiled executable in srcs property in the | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | b12ff59 | 2022-09-01 15:04:04 +0000 | [diff] [blame] | 496 | // device's directory, for both the host and device | 
 | 497 | func PrebuiltBinaryFactory() android.Module { | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 498 | 	module, _ := NewPrebuiltBinary(android.HostAndDeviceSupported) | 
 | 499 | 	return module.Init() | 
 | 500 | } | 
 | 501 |  | 
 | 502 | func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { | 
| Colin Cross | 8ff1058 | 2023-12-07 13:10:56 -0800 | [diff] [blame] | 503 | 	module, binary := newBinary(hod) | 
| Colin Cross | de89fb8 | 2017-03-17 13:28:06 -0700 | [diff] [blame] | 504 | 	module.compiler = nil | 
 | 505 |  | 
 | 506 | 	prebuilt := &prebuiltBinaryLinker{ | 
 | 507 | 		binaryDecorator: binary, | 
 | 508 | 	} | 
 | 509 | 	module.linker = prebuilt | 
| Martin Stjernholm | 837ee1a | 2020-08-20 02:54:52 +0100 | [diff] [blame] | 510 | 	module.installer = prebuilt | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 511 |  | 
| Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 512 | 	module.AddProperties(&prebuilt.properties) | 
 | 513 |  | 
 | 514 | 	android.InitPrebuiltModule(module, &prebuilt.properties.Srcs) | 
| Leo Li | 74f7b97 | 2017-05-17 11:30:45 -0700 | [diff] [blame] | 515 | 	return module, binary | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 516 | } | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 517 |  | 
 | 518 | type Sanitized struct { | 
 | 519 | 	None struct { | 
 | 520 | 		Srcs []string `android:"path,arch_variant"` | 
 | 521 | 	} `android:"arch_variant"` | 
 | 522 | 	Address struct { | 
 | 523 | 		Srcs []string `android:"path,arch_variant"` | 
 | 524 | 	} `android:"arch_variant"` | 
 | 525 | 	Hwaddress struct { | 
 | 526 | 		Srcs []string `android:"path,arch_variant"` | 
 | 527 | 	} `android:"arch_variant"` | 
 | 528 | } | 
 | 529 |  | 
 | 530 | func srcsForSanitizer(sanitize *sanitize, sanitized Sanitized) []string { | 
 | 531 | 	if sanitize == nil { | 
 | 532 | 		return nil | 
 | 533 | 	} | 
| Liz Kammer | 2c1d6aa | 2022-10-03 15:07:37 -0400 | [diff] [blame] | 534 | 	if sanitize.isSanitizerEnabled(Asan) && sanitized.Address.Srcs != nil { | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 535 | 		return sanitized.Address.Srcs | 
 | 536 | 	} | 
| Liz Kammer | 2c1d6aa | 2022-10-03 15:07:37 -0400 | [diff] [blame] | 537 | 	if sanitize.isSanitizerEnabled(Hwasan) && sanitized.Hwaddress.Srcs != nil { | 
| Evgenii Stepanov | 2080bfe | 2020-07-24 15:35:40 -0700 | [diff] [blame] | 538 | 		return sanitized.Hwaddress.Srcs | 
 | 539 | 	} | 
 | 540 | 	return sanitized.None.Srcs | 
 | 541 | } | 
| Spandan Das | 2b6dfb5 | 2024-01-19 00:22:22 +0000 | [diff] [blame] | 542 |  | 
 | 543 | func (p *prebuiltLinker) sourceModuleName() string { | 
 | 544 | 	return proptools.String(p.properties.Source_module_name) | 
 | 545 | } |