blob: 2a866dc978100a31e95a26ac2bae04150f450e98 [file] [log] [blame]
Colin Cross4d9c2d12016-07-29 12:48:20 -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 (
18 "strings"
19
20 "github.com/google/blueprint"
Colin Cross26c34ed2016-09-30 17:10:16 -070021 "github.com/google/blueprint/pathtools"
Colin Cross4d9c2d12016-07-29 12:48:20 -070022
Colin Cross4d9c2d12016-07-29 12:48:20 -070023 "android/soong/android"
24)
25
Colin Crossb916a382016-07-29 17:28:03 -070026type LibraryProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070027 Static struct {
Colin Cross2f336352016-10-26 10:03:47 -070028 Srcs []string `android:"arch_variant"`
29 Cflags []string `android:"arch_variant"`
Colin Cross4d9c2d12016-07-29 12:48:20 -070030
Colin Cross4d9c2d12016-07-29 12:48:20 -070031 Enabled *bool `android:"arch_variant"`
32 Whole_static_libs []string `android:"arch_variant"`
33 Static_libs []string `android:"arch_variant"`
34 Shared_libs []string `android:"arch_variant"`
35 } `android:"arch_variant"`
36 Shared struct {
Colin Cross2f336352016-10-26 10:03:47 -070037 Srcs []string `android:"arch_variant"`
38 Cflags []string `android:"arch_variant"`
Colin Crossb916a382016-07-29 17:28:03 -070039
Colin Cross4d9c2d12016-07-29 12:48:20 -070040 Enabled *bool `android:"arch_variant"`
41 Whole_static_libs []string `android:"arch_variant"`
42 Static_libs []string `android:"arch_variant"`
43 Shared_libs []string `android:"arch_variant"`
44 } `android:"arch_variant"`
45
46 // local file name to pass to the linker as --version_script
47 Version_script *string `android:"arch_variant"`
48 // local file name to pass to the linker as -unexported_symbols_list
49 Unexported_symbols_list *string `android:"arch_variant"`
50 // local file name to pass to the linker as -force_symbols_not_weak_list
51 Force_symbols_not_weak_list *string `android:"arch_variant"`
52 // local file name to pass to the linker as -force_symbols_weak_list
53 Force_symbols_weak_list *string `android:"arch_variant"`
54
55 // rename host libraries to prevent overlap with system installed libraries
56 Unique_host_soname *bool
57
Dan Willemsene1240db2016-11-03 14:28:51 -070058 Aidl struct {
59 // export headers generated from .aidl sources
60 Export_aidl_headers bool
61 }
62
Colin Cross0c461f12016-10-20 16:11:43 -070063 Proto struct {
64 // export headers generated from .proto sources
65 Export_proto_headers bool
66 }
Colin Crossa48ab5b2017-02-14 15:28:44 -080067}
Colin Cross0c461f12016-10-20 16:11:43 -070068
Colin Crossa48ab5b2017-02-14 15:28:44 -080069type LibraryMutatedProperties struct {
Colin Cross4d9c2d12016-07-29 12:48:20 -070070 VariantName string `blueprint:"mutated"`
Colin Crossb916a382016-07-29 17:28:03 -070071
72 // Build a static variant
73 BuildStatic bool `blueprint:"mutated"`
74 // Build a shared variant
75 BuildShared bool `blueprint:"mutated"`
76 // This variant is shared
77 VariantIsShared bool `blueprint:"mutated"`
78 // This variant is static
79 VariantIsStatic bool `blueprint:"mutated"`
80}
81
82type FlagExporterProperties struct {
83 // list of directories relative to the Blueprints file that will
Dan Willemsen273af7f2016-11-03 15:53:42 -070084 // be added to the include path (using -I) for this module and any module that links
85 // against this module
Colin Crossb916a382016-07-29 17:28:03 -070086 Export_include_dirs []string `android:"arch_variant"`
Dan Willemsen4416e5d2017-04-06 12:43:22 -070087
88 Target struct {
89 Vendor struct {
90 // list of exported include directories, like
91 // export_include_dirs, that will be applied to the
92 // vendor variant of this library. This will overwrite
93 // any other declarations.
94 Export_include_dirs []string
95 }
96 }
Colin Cross4d9c2d12016-07-29 12:48:20 -070097}
98
99func init() {
Colin Cross798bfce2016-10-12 14:28:16 -0700100 android.RegisterModuleType("cc_library_static", libraryStaticFactory)
101 android.RegisterModuleType("cc_library_shared", librarySharedFactory)
102 android.RegisterModuleType("cc_library", libraryFactory)
103 android.RegisterModuleType("cc_library_host_static", libraryHostStaticFactory)
104 android.RegisterModuleType("cc_library_host_shared", libraryHostSharedFactory)
Colin Cross5950f382016-12-13 12:50:57 -0800105 android.RegisterModuleType("cc_library_headers", libraryHeaderFactory)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700106}
107
108// Module factory for combined static + shared libraries, device by default but with possible host
109// support
Colin Cross36242852017-06-23 15:06:31 -0700110func libraryFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800111 module, _ := NewLibrary(android.HostAndDeviceSupported)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700112 return module.Init()
113}
114
115// Module factory for static libraries
Colin Cross36242852017-06-23 15:06:31 -0700116func libraryStaticFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800117 module, library := NewLibrary(android.HostAndDeviceSupported)
118 library.BuildOnlyStatic()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700119 return module.Init()
120}
121
122// Module factory for shared libraries
Colin Cross36242852017-06-23 15:06:31 -0700123func librarySharedFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800124 module, library := NewLibrary(android.HostAndDeviceSupported)
125 library.BuildOnlyShared()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700126 return module.Init()
127}
128
129// Module factory for host static libraries
Colin Cross36242852017-06-23 15:06:31 -0700130func libraryHostStaticFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800131 module, library := NewLibrary(android.HostSupported)
132 library.BuildOnlyStatic()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700133 return module.Init()
134}
135
136// Module factory for host shared libraries
Colin Cross36242852017-06-23 15:06:31 -0700137func libraryHostSharedFactory() android.Module {
Colin Crossab3b7322016-12-09 14:46:15 -0800138 module, library := NewLibrary(android.HostSupported)
139 library.BuildOnlyShared()
Colin Cross4d9c2d12016-07-29 12:48:20 -0700140 return module.Init()
141}
142
Colin Cross5950f382016-12-13 12:50:57 -0800143// Module factory for header-only libraries
Colin Cross36242852017-06-23 15:06:31 -0700144func libraryHeaderFactory() android.Module {
Colin Cross5950f382016-12-13 12:50:57 -0800145 module, library := NewLibrary(android.HostAndDeviceSupported)
146 library.HeaderOnly()
147 return module.Init()
148}
149
Colin Cross4d9c2d12016-07-29 12:48:20 -0700150type flagExporter struct {
151 Properties FlagExporterProperties
152
Dan Willemsen847dcc72016-09-29 12:13:36 -0700153 flags []string
154 flagsDeps android.Paths
Colin Cross4d9c2d12016-07-29 12:48:20 -0700155}
156
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700157func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
Justin Yun8effde42017-06-23 19:24:43 +0900158 if ctx.vndk() && f.Properties.Target.Vendor.Export_include_dirs != nil {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700159 return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Export_include_dirs)
160 } else {
161 return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
162 }
163}
164
Colin Cross4d9c2d12016-07-29 12:48:20 -0700165func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700166 includeDirs := f.exportedIncludes(ctx)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700167 for _, dir := range includeDirs.Strings() {
168 f.flags = append(f.flags, inc+dir)
169 }
170}
171
172func (f *flagExporter) reexportFlags(flags []string) {
173 f.flags = append(f.flags, flags...)
174}
175
Dan Willemsen847dcc72016-09-29 12:13:36 -0700176func (f *flagExporter) reexportDeps(deps android.Paths) {
177 f.flagsDeps = append(f.flagsDeps, deps...)
178}
179
Colin Cross4d9c2d12016-07-29 12:48:20 -0700180func (f *flagExporter) exportedFlags() []string {
181 return f.flags
182}
183
Dan Willemsen847dcc72016-09-29 12:13:36 -0700184func (f *flagExporter) exportedFlagsDeps() android.Paths {
185 return f.flagsDeps
186}
187
Colin Cross4d9c2d12016-07-29 12:48:20 -0700188type exportedFlagsProducer interface {
189 exportedFlags() []string
Dan Willemsen847dcc72016-09-29 12:13:36 -0700190 exportedFlagsDeps() android.Paths
Colin Cross4d9c2d12016-07-29 12:48:20 -0700191}
192
193var _ exportedFlagsProducer = (*flagExporter)(nil)
194
Colin Crossb916a382016-07-29 17:28:03 -0700195// libraryDecorator wraps baseCompiler, baseLinker and baseInstaller to provide library-specific
196// functionality: static vs. shared linkage, reusing object files for shared libraries
197type libraryDecorator struct {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800198 Properties LibraryProperties
199 MutatedProperties LibraryMutatedProperties
Colin Cross4d9c2d12016-07-29 12:48:20 -0700200
201 // For reusing static library objects for shared library
Colin Cross10d22312017-05-03 11:01:58 -0700202 reuseObjects Objects
203 reuseExportedFlags []string
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700204 reuseExportedDeps android.Paths
Colin Cross10d22312017-05-03 11:01:58 -0700205
Colin Cross26c34ed2016-09-30 17:10:16 -0700206 // table-of-contents file to optimize out relinking when possible
207 tocFile android.OptionalPath
Colin Cross4d9c2d12016-07-29 12:48:20 -0700208
Colin Cross4d9c2d12016-07-29 12:48:20 -0700209 flagExporter
210 stripper
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700211 relocationPacker
Colin Cross4d9c2d12016-07-29 12:48:20 -0700212
Colin Cross4d9c2d12016-07-29 12:48:20 -0700213 // If we're used as a whole_static_lib, our missing dependencies need
214 // to be given
215 wholeStaticMissingDeps []string
216
217 // For whole_static_libs
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700218 objects Objects
Colin Cross4d9c2d12016-07-29 12:48:20 -0700219
220 // Uses the module's name if empty, but can be overridden. Does not include
221 // shlib suffix.
222 libName string
Colin Crossb916a382016-07-29 17:28:03 -0700223
224 sanitize *sanitize
225
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800226 sabi *sabi
227
Dan Willemsen581341d2017-02-09 16:16:31 -0800228 // Output archive of gcno coverage information files
229 coverageOutputFile android.OptionalPath
230
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800231 // linked Source Abi Dump
232 sAbiOutputFile android.OptionalPath
233
234 // Source Abi Diff
235 sAbiDiff android.OptionalPath
236
Colin Crossb916a382016-07-29 17:28:03 -0700237 // Decorated interafaces
238 *baseCompiler
239 *baseLinker
240 *baseInstaller
Colin Cross4d9c2d12016-07-29 12:48:20 -0700241}
242
Colin Crossb916a382016-07-29 17:28:03 -0700243func (library *libraryDecorator) linkerProps() []interface{} {
244 var props []interface{}
245 props = append(props, library.baseLinker.linkerProps()...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700246 return append(props,
247 &library.Properties,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800248 &library.MutatedProperties,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700249 &library.flagExporter.Properties,
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700250 &library.stripper.StripProperties,
251 &library.relocationPacker.Properties)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700252}
253
Colin Crossb916a382016-07-29 17:28:03 -0700254func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
Colin Cross42742b82016-08-01 13:20:05 -0700255 flags = library.baseLinker.linkerFlags(ctx, flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700256
Colin Crossb916a382016-07-29 17:28:03 -0700257 // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
258 // all code is position independent, and then those warnings get promoted to
259 // errors.
Colin Cross3edeee12017-04-04 12:59:48 -0700260 if !ctx.Windows() {
Colin Crossb916a382016-07-29 17:28:03 -0700261 flags.CFlags = append(flags.CFlags, "-fPIC")
262 }
263
264 if library.static() {
265 flags.CFlags = append(flags.CFlags, library.Properties.Static.Cflags...)
Colin Crossa48ab5b2017-02-14 15:28:44 -0800266 } else if library.shared() {
Colin Crossb916a382016-07-29 17:28:03 -0700267 flags.CFlags = append(flags.CFlags, library.Properties.Shared.Cflags...)
268 }
269
Colin Crossa48ab5b2017-02-14 15:28:44 -0800270 if library.shared() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700271 libName := library.getLibName(ctx)
272 // GCC for Android assumes that -shared means -Bsymbolic, use -Wl,-shared instead
273 sharedFlag := "-Wl,-shared"
274 if flags.Clang || ctx.Host() {
275 sharedFlag = "-shared"
276 }
277 var f []string
Dan Willemsen01a405a2016-06-13 17:19:03 -0700278 if ctx.toolchain().Bionic() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700279 f = append(f,
280 "-nostdlib",
281 "-Wl,--gc-sections",
282 )
283 }
284
285 if ctx.Darwin() {
286 f = append(f,
287 "-dynamiclib",
288 "-single_module",
Colin Cross4d9c2d12016-07-29 12:48:20 -0700289 "-install_name @rpath/"+libName+flags.Toolchain.ShlibSuffix(),
290 )
Colin Cross7863cf52016-10-20 10:47:21 -0700291 if ctx.Arch().ArchType == android.X86 {
292 f = append(f,
293 "-read_only_relocs suppress",
294 )
295 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700296 } else {
297 f = append(f,
298 sharedFlag,
299 "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
300 }
301
302 flags.LdFlags = append(f, flags.LdFlags...)
303 }
304
305 return flags
306}
307
Dan Willemsen273af7f2016-11-03 15:53:42 -0700308func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700309 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Dan Willemsen273af7f2016-11-03 15:53:42 -0700310 if len(exportIncludeDirs) > 0 {
Colin Crossdad8c952017-04-26 14:55:27 -0700311 f := includeDirsToFlags(exportIncludeDirs)
312 flags.GlobalFlags = append(flags.GlobalFlags, f)
313 flags.YasmFlags = append(flags.YasmFlags, f)
Dan Willemsen273af7f2016-11-03 15:53:42 -0700314 }
315
316 return library.baseCompiler.compilerFlags(ctx, flags)
317}
318
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700319func extractExportIncludesFromFlags(flags []string) []string {
320 // This method is used in the generation of rules which produce
321 // abi-dumps for source files. Exported headers are needed to infer the
322 // abi exported by a library and filter out the rest of the abi dumped
323 // from a source. We extract the include flags exported by a library.
324 // This includes the flags exported which are re-exported from static
325 // library dependencies, exported header library dependencies and
Jayant Chowdharyaf6eb712017-08-23 16:08:29 -0700326 // generated header dependencies. -isystem headers are not included
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700327 // since for bionic libraries, abi-filtering is taken care of by version
328 // scripts.
329 var exportedIncludes []string
330 for _, flag := range flags {
331 if strings.HasPrefix(flag, "-I") {
332 exportedIncludes = append(exportedIncludes, flag)
333 }
334 }
335 return exportedIncludes
336}
337
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700338func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
Colin Cross5950f382016-12-13 12:50:57 -0800339 if !library.buildShared() && !library.buildStatic() {
340 if len(library.baseCompiler.Properties.Srcs) > 0 {
341 ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
342 }
343 if len(library.Properties.Static.Srcs) > 0 {
344 ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
345 }
346 if len(library.Properties.Shared.Srcs) > 0 {
347 ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
348 }
349 return Objects{}
350 }
Jayant Chowdhary2a966402017-08-07 14:09:45 -0700351 if ctx.createVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps {
Jayant Chowdharya4fce192017-09-06 13:10:03 -0700352 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800353 var SourceAbiFlags []string
354 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700355 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800356 }
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700357 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
358 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
359 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800360 flags.SAbiFlags = SourceAbiFlags
361 total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
362 len(library.Properties.Static.Srcs)
363 if total_length > 0 {
364 flags.SAbiDump = true
365 }
366 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700367 objs := library.baseCompiler.compile(ctx, flags, deps)
368 library.reuseObjects = objs
Colin Cross2f336352016-10-26 10:03:47 -0700369 buildFlags := flagsToBuilderFlags(flags)
Colin Crossb916a382016-07-29 17:28:03 -0700370
Colin Cross4d9c2d12016-07-29 12:48:20 -0700371 if library.static() {
Colin Cross2f336352016-10-26 10:03:47 -0700372 srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700373 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
374 srcs, library.baseCompiler.deps))
Colin Crossa48ab5b2017-02-14 15:28:44 -0800375 } else if library.shared() {
Colin Cross2f336352016-10-26 10:03:47 -0700376 srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700377 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
378 srcs, library.baseCompiler.deps))
Colin Crossb916a382016-07-29 17:28:03 -0700379 }
380
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700381 return objs
Colin Crossb916a382016-07-29 17:28:03 -0700382}
383
384type libraryInterface interface {
385 getWholeStaticMissingDeps() []string
386 static() bool
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700387 objs() Objects
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700388 reuseObjs() (Objects, []string, android.Paths)
Colin Cross26c34ed2016-09-30 17:10:16 -0700389 toc() android.OptionalPath
Colin Crossb916a382016-07-29 17:28:03 -0700390
391 // Returns true if the build options for the module have selected a static or shared build
392 buildStatic() bool
393 buildShared() bool
394
395 // Sets whether a specific variant is static or shared
Colin Crossa48ab5b2017-02-14 15:28:44 -0800396 setStatic()
397 setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700398}
399
400func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
401 name := library.libName
402 if name == "" {
Colin Crossce75d2c2016-10-06 16:12:58 -0700403 name = ctx.baseModuleName()
Colin Crossb916a382016-07-29 17:28:03 -0700404 }
405
406 if ctx.Host() && Bool(library.Properties.Unique_host_soname) {
407 if !strings.HasSuffix(name, "-host") {
408 name = name + "-host"
409 }
410 }
411
Colin Crossa48ab5b2017-02-14 15:28:44 -0800412 return name + library.MutatedProperties.VariantName
Colin Crossb916a382016-07-29 17:28:03 -0700413}
414
415func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
416 location := InstallInSystem
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700417 if library.sanitize.inSanitizerDir() {
418 location = InstallInSanitizerDir
Colin Crossb916a382016-07-29 17:28:03 -0700419 }
420 library.baseInstaller.location = location
421
422 library.baseLinker.linkerInit(ctx)
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700423
424 library.relocationPacker.packingInit(ctx)
Colin Crossb916a382016-07-29 17:28:03 -0700425}
426
Colin Cross37047f12016-12-13 17:06:13 -0800427func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700428 deps = library.baseLinker.linkerDeps(ctx, deps)
429
430 if library.static() {
431 deps.WholeStaticLibs = append(deps.WholeStaticLibs,
432 library.Properties.Static.Whole_static_libs...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700433 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...)
434 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
Colin Crossa48ab5b2017-02-14 15:28:44 -0800435 } else if library.shared() {
Dan Willemsen2e47b342016-11-17 01:02:25 -0800436 if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700437 if !ctx.sdk() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700438 deps.CrtBegin = "crtbegin_so"
439 deps.CrtEnd = "crtend_so"
440 } else {
Dan Albertebedf672016-11-08 15:06:22 -0800441 // TODO(danalbert): Add generation of crt objects.
442 // For `sdk_version: "current"`, we don't actually have a
443 // freshly generated set of CRT objects. Use the last stable
444 // version.
445 version := ctx.sdkVersion()
446 if version == "current" {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -0700447 version = getCurrentNdkPrebuiltVersion(ctx)
Dan Albertebedf672016-11-08 15:06:22 -0800448 }
449 deps.CrtBegin = "ndk_crtbegin_so." + version
450 deps.CrtEnd = "ndk_crtend_so." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700451 }
452 }
453 deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...)
454 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Shared.Static_libs...)
455 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Shared.Shared_libs...)
456 }
457
458 return deps
459}
460
Colin Crossb916a382016-07-29 17:28:03 -0700461func (library *libraryDecorator) linkStatic(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700462 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700463
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700464 library.objects = deps.WholeStaticLibObjs.Copy()
465 library.objects = library.objects.Append(objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700466
467 outputFile := android.PathForModuleOut(ctx,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800468 ctx.ModuleName()+library.MutatedProperties.VariantName+staticLibraryExtension)
Dan Willemsen581341d2017-02-09 16:16:31 -0800469 builderFlags := flagsToBuilderFlags(flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700470
Dan Willemsen581341d2017-02-09 16:16:31 -0800471 TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
472
473 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800474 ctx.ModuleName()+library.MutatedProperties.VariantName)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700475
476 library.wholeStaticMissingDeps = ctx.GetMissingDependencies()
477
478 ctx.CheckbuildFile(outputFile)
479
480 return outputFile
481}
482
Colin Crossb916a382016-07-29 17:28:03 -0700483func (library *libraryDecorator) linkShared(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700484 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700485
486 var linkerDeps android.Paths
487
488 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
489 unexportedSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
490 forceNotWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
491 forceWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
492 if !ctx.Darwin() {
493 if versionScript.Valid() {
494 flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
495 linkerDeps = append(linkerDeps, versionScript.Path())
496 }
497 if unexportedSymbols.Valid() {
498 ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
499 }
500 if forceNotWeakSymbols.Valid() {
501 ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin")
502 }
503 if forceWeakSymbols.Valid() {
504 ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
505 }
506 } else {
507 if versionScript.Valid() {
508 ctx.PropertyErrorf("version_script", "Not supported on Darwin")
509 }
510 if unexportedSymbols.Valid() {
511 flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
512 linkerDeps = append(linkerDeps, unexportedSymbols.Path())
513 }
514 if forceNotWeakSymbols.Valid() {
515 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String())
516 linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path())
517 }
518 if forceWeakSymbols.Valid() {
519 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String())
520 linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
521 }
522 }
523
524 fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
525 outputFile := android.PathForModuleOut(ctx, fileName)
526 ret := outputFile
527
528 builderFlags := flagsToBuilderFlags(flags)
529
Colin Crossd8f8d072017-04-04 13:00:15 -0700530 if !ctx.Darwin() && !ctx.Windows() {
Colin Cross89562dc2016-10-03 17:47:19 -0700531 // Optimize out relinking against shared libraries whose interface hasn't changed by
532 // depending on a table of contents file instead of the library itself.
533 tocPath := outputFile.RelPathString()
534 tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
535 tocFile := android.PathForOutput(ctx, tocPath)
536 library.tocFile = android.OptionalPathForPath(tocFile)
537 TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
538 }
539
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700540 if library.relocationPacker.needsPacking(ctx) {
541 packedOutputFile := outputFile
542 outputFile = android.PathForModuleOut(ctx, "unpacked", fileName)
543 library.relocationPacker.pack(ctx, outputFile, packedOutputFile, builderFlags)
544 }
545
Colin Cross4d9c2d12016-07-29 12:48:20 -0700546 if library.stripper.needsStrip(ctx) {
547 strippedOutputFile := outputFile
548 outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
549 library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
550 }
551
552 sharedLibs := deps.SharedLibs
553 sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
554
Dan Albertd015c4a2016-08-10 14:34:08 -0700555 // TODO(danalbert): Clean this up when soong supports prebuilts.
556 if strings.HasPrefix(ctx.selectedStl(), "ndk_libc++") {
557 libDir := getNdkStlLibDir(ctx, flags.Toolchain, "libc++")
558
559 if strings.HasSuffix(ctx.selectedStl(), "_shared") {
560 deps.StaticLibs = append(deps.StaticLibs,
561 libDir.Join(ctx, "libandroid_support.a"))
562 } else {
563 deps.StaticLibs = append(deps.StaticLibs,
564 libDir.Join(ctx, "libc++abi.a"),
565 libDir.Join(ctx, "libandroid_support.a"))
566 }
567
568 if ctx.Arch().ArchType == android.Arm {
569 deps.StaticLibs = append(deps.StaticLibs,
570 libDir.Join(ctx, "libunwind.a"))
571 }
572 }
573
Colin Cross26c34ed2016-09-30 17:10:16 -0700574 linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
575 linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700576 linkerDeps = append(linkerDeps, objs.tidyFiles...)
Colin Cross26c34ed2016-09-30 17:10:16 -0700577
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700578 TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700579 deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
580 linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
581
Dan Willemsen581341d2017-02-09 16:16:31 -0800582 objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
583 objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800584
585 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
586 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
587
Dan Willemsen581341d2017-02-09 16:16:31 -0800588 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx))
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700589 library.linkSAbiDumpFiles(ctx, objs, fileName, ret)
Dan Willemsen581341d2017-02-09 16:16:31 -0800590
Colin Cross4d9c2d12016-07-29 12:48:20 -0700591 return ret
592}
593
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700594func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800595 //Also take into account object re-use.
Justin Yun8effde42017-06-23 19:24:43 +0900596 if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800597 refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true)
598 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
599 var symbolFile android.OptionalPath
600 if versionScript.Valid() {
601 symbolFile = versionScript
602 }
Jayant Chowdharya4fce192017-09-06 13:10:03 -0700603 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800604 var SourceAbiFlags []string
605 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700606 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
607 }
608 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
609 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800610 }
611 exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700612 library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, symbolFile, "current", fileName, exportedHeaderFlags)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800613 if refSourceDumpFile.Valid() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700614 unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName)
615 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), unzippedRefDump, fileName)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800616 }
617 }
618}
619
620func vndkVsNdk(ctx ModuleContext) bool {
Jiyong Parkab0fd5f2017-08-03 21:22:50 +0900621 if inList(ctx.baseModuleName(), llndkLibraries) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800622 return false
623 }
624 return true
625}
626
Colin Crossb916a382016-07-29 17:28:03 -0700627func (library *libraryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700628 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700629
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700630 objs = objs.Append(deps.Objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700631
632 var out android.Path
Colin Crossa48ab5b2017-02-14 15:28:44 -0800633 if library.static() || library.header() {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700634 out = library.linkStatic(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700635 } else {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700636 out = library.linkShared(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700637 }
638
639 library.exportIncludes(ctx, "-I")
640 library.reexportFlags(deps.ReexportedFlags)
Dan Willemsen847dcc72016-09-29 12:13:36 -0700641 library.reexportDeps(deps.ReexportedFlagsDeps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700642
Dan Willemsene1240db2016-11-03 14:28:51 -0700643 if library.Properties.Aidl.Export_aidl_headers {
644 if library.baseCompiler.hasSrcExt(".aidl") {
Colin Cross10d22312017-05-03 11:01:58 -0700645 flags := []string{
Dan Willemsene1240db2016-11-03 14:28:51 -0700646 "-I" + android.PathForModuleGen(ctx, "aidl").String(),
Colin Cross10d22312017-05-03 11:01:58 -0700647 }
648 library.reexportFlags(flags)
649 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700650 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700651 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700652 }
653 }
654
655 if library.Properties.Proto.Export_proto_headers {
656 if library.baseCompiler.hasSrcExt(".proto") {
Colin Cross10d22312017-05-03 11:01:58 -0700657 flags := []string{
Colin Cross38f794e2017-09-07 10:53:07 -0700658 "-I" + android.ProtoSubDir(ctx).String(),
659 "-I" + android.ProtoDir(ctx).String(),
Colin Cross10d22312017-05-03 11:01:58 -0700660 }
661 library.reexportFlags(flags)
662 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Colin Cross0c461f12016-10-20 16:11:43 -0700663 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700664 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Colin Cross0c461f12016-10-20 16:11:43 -0700665 }
666 }
667
Colin Cross4d9c2d12016-07-29 12:48:20 -0700668 return out
669}
670
Colin Crossb916a382016-07-29 17:28:03 -0700671func (library *libraryDecorator) buildStatic() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800672 return library.MutatedProperties.BuildStatic &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700673 (library.Properties.Static.Enabled == nil || *library.Properties.Static.Enabled)
674}
675
Colin Crossb916a382016-07-29 17:28:03 -0700676func (library *libraryDecorator) buildShared() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800677 return library.MutatedProperties.BuildShared &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700678 (library.Properties.Shared.Enabled == nil || *library.Properties.Shared.Enabled)
679}
680
Colin Crossb916a382016-07-29 17:28:03 -0700681func (library *libraryDecorator) getWholeStaticMissingDeps() []string {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700682 return library.wholeStaticMissingDeps
683}
684
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700685func (library *libraryDecorator) objs() Objects {
686 return library.objects
Colin Cross4d9c2d12016-07-29 12:48:20 -0700687}
688
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700689func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
690 return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
Colin Cross4d9c2d12016-07-29 12:48:20 -0700691}
692
Colin Cross26c34ed2016-09-30 17:10:16 -0700693func (library *libraryDecorator) toc() android.OptionalPath {
694 return library.tocFile
695}
696
Colin Crossb916a382016-07-29 17:28:03 -0700697func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
Colin Crossc43ae772017-04-14 15:42:53 -0700698 if library.shared() {
Justin Yun8effde42017-06-23 19:24:43 +0900699 if ctx.Device() {
700 if ctx.vndk() {
701 if ctx.isVndkSp() {
702 library.baseInstaller.subDir = "vndk-sp"
703 } else if ctx.isVndk() {
704 library.baseInstaller.subDir = "vndk"
705 }
706 }
707 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700708 library.baseInstaller.install(ctx, file)
709 }
710}
711
Colin Crossb916a382016-07-29 17:28:03 -0700712func (library *libraryDecorator) static() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800713 return library.MutatedProperties.VariantIsStatic
Colin Cross4d9c2d12016-07-29 12:48:20 -0700714}
715
Colin Crossa48ab5b2017-02-14 15:28:44 -0800716func (library *libraryDecorator) shared() bool {
717 return library.MutatedProperties.VariantIsShared
718}
719
720func (library *libraryDecorator) header() bool {
721 return !library.static() && !library.shared()
722}
723
724func (library *libraryDecorator) setStatic() {
725 library.MutatedProperties.VariantIsStatic = true
726 library.MutatedProperties.VariantIsShared = false
727}
728
729func (library *libraryDecorator) setShared() {
730 library.MutatedProperties.VariantIsStatic = false
731 library.MutatedProperties.VariantIsShared = true
Colin Crossb916a382016-07-29 17:28:03 -0700732}
733
Colin Crossab3b7322016-12-09 14:46:15 -0800734func (library *libraryDecorator) BuildOnlyStatic() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800735 library.MutatedProperties.BuildShared = false
Colin Crossab3b7322016-12-09 14:46:15 -0800736}
737
738func (library *libraryDecorator) BuildOnlyShared() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800739 library.MutatedProperties.BuildStatic = false
Colin Crossab3b7322016-12-09 14:46:15 -0800740}
741
Colin Cross5950f382016-12-13 12:50:57 -0800742func (library *libraryDecorator) HeaderOnly() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800743 library.MutatedProperties.BuildShared = false
744 library.MutatedProperties.BuildStatic = false
Colin Cross5950f382016-12-13 12:50:57 -0800745}
746
Colin Crossab3b7322016-12-09 14:46:15 -0800747func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700748 module := newModule(hod, android.MultilibBoth)
749
Colin Crossb916a382016-07-29 17:28:03 -0700750 library := &libraryDecorator{
Colin Crossa48ab5b2017-02-14 15:28:44 -0800751 MutatedProperties: LibraryMutatedProperties{
Colin Crossab3b7322016-12-09 14:46:15 -0800752 BuildShared: true,
753 BuildStatic: true,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700754 },
Colin Crossb916a382016-07-29 17:28:03 -0700755 baseCompiler: NewBaseCompiler(),
756 baseLinker: NewBaseLinker(),
757 baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem),
758 sanitize: module.sanitize,
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800759 sabi: module.sabi,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700760 }
761
Colin Crossb916a382016-07-29 17:28:03 -0700762 module.compiler = library
763 module.linker = library
764 module.installer = library
765
766 return module, library
767}
768
Colin Cross10d22312017-05-03 11:01:58 -0700769// connects a shared library to a static library in order to reuse its .o files to avoid
770// compiling source files twice.
771func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) {
772 if staticCompiler, ok := static.compiler.(*libraryDecorator); ok {
773 sharedCompiler := shared.compiler.(*libraryDecorator)
774 if len(staticCompiler.Properties.Static.Cflags) == 0 &&
775 len(sharedCompiler.Properties.Shared.Cflags) == 0 {
776
777 mctx.AddInterVariantDependency(reuseObjTag, shared, static)
778 sharedCompiler.baseCompiler.Properties.OriginalSrcs =
779 sharedCompiler.baseCompiler.Properties.Srcs
780 sharedCompiler.baseCompiler.Properties.Srcs = nil
781 sharedCompiler.baseCompiler.Properties.Generated_sources = nil
782 }
783 }
784}
785
Colin Crossb916a382016-07-29 17:28:03 -0700786func linkageMutator(mctx android.BottomUpMutatorContext) {
787 if m, ok := mctx.Module().(*Module); ok && m.linker != nil {
788 if library, ok := m.linker.(libraryInterface); ok {
789 var modules []blueprint.Module
790 if library.buildStatic() && library.buildShared() {
791 modules = mctx.CreateLocalVariations("static", "shared")
792 static := modules[0].(*Module)
793 shared := modules[1].(*Module)
794
Colin Crossa48ab5b2017-02-14 15:28:44 -0800795 static.linker.(libraryInterface).setStatic()
796 shared.linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700797
Colin Cross10d22312017-05-03 11:01:58 -0700798 reuseStaticLibrary(mctx, static, shared)
799
Colin Crossb916a382016-07-29 17:28:03 -0700800 } else if library.buildStatic() {
801 modules = mctx.CreateLocalVariations("static")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800802 modules[0].(*Module).linker.(libraryInterface).setStatic()
Colin Crossb916a382016-07-29 17:28:03 -0700803 } else if library.buildShared() {
804 modules = mctx.CreateLocalVariations("shared")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800805 modules[0].(*Module).linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700806 }
807 }
808 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700809}