blob: 4a173a5d78b7969b9857594291abfc68bf4fbf94 [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
326 // generated header dependencies. Re-exported shared library include
327 // flags are not in this set since shared library dependencies will
328 // themselves be included in the vndk. -isystem headers are not included
329 // since for bionic libraries, abi-filtering is taken care of by version
330 // scripts.
331 var exportedIncludes []string
332 for _, flag := range flags {
333 if strings.HasPrefix(flag, "-I") {
334 exportedIncludes = append(exportedIncludes, flag)
335 }
336 }
337 return exportedIncludes
338}
339
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700340func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
Colin Cross5950f382016-12-13 12:50:57 -0800341 if !library.buildShared() && !library.buildStatic() {
342 if len(library.baseCompiler.Properties.Srcs) > 0 {
343 ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
344 }
345 if len(library.Properties.Static.Srcs) > 0 {
346 ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
347 }
348 if len(library.Properties.Shared.Srcs) > 0 {
349 ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
350 }
351 return Objects{}
352 }
Jayant Chowdhary2a966402017-08-07 14:09:45 -0700353 if ctx.createVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800354 exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
355 var SourceAbiFlags []string
356 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700357 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800358 }
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700359 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
360 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
361 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800362 flags.SAbiFlags = SourceAbiFlags
363 total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
364 len(library.Properties.Static.Srcs)
365 if total_length > 0 {
366 flags.SAbiDump = true
367 }
368 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700369 objs := library.baseCompiler.compile(ctx, flags, deps)
370 library.reuseObjects = objs
Colin Cross2f336352016-10-26 10:03:47 -0700371 buildFlags := flagsToBuilderFlags(flags)
Colin Crossb916a382016-07-29 17:28:03 -0700372
Colin Cross4d9c2d12016-07-29 12:48:20 -0700373 if library.static() {
Colin Cross2f336352016-10-26 10:03:47 -0700374 srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700375 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
376 srcs, library.baseCompiler.deps))
Colin Crossa48ab5b2017-02-14 15:28:44 -0800377 } else if library.shared() {
Colin Cross2f336352016-10-26 10:03:47 -0700378 srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700379 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
380 srcs, library.baseCompiler.deps))
Colin Crossb916a382016-07-29 17:28:03 -0700381 }
382
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700383 return objs
Colin Crossb916a382016-07-29 17:28:03 -0700384}
385
386type libraryInterface interface {
387 getWholeStaticMissingDeps() []string
388 static() bool
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700389 objs() Objects
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700390 reuseObjs() (Objects, []string, android.Paths)
Colin Cross26c34ed2016-09-30 17:10:16 -0700391 toc() android.OptionalPath
Colin Crossb916a382016-07-29 17:28:03 -0700392
393 // Returns true if the build options for the module have selected a static or shared build
394 buildStatic() bool
395 buildShared() bool
396
397 // Sets whether a specific variant is static or shared
Colin Crossa48ab5b2017-02-14 15:28:44 -0800398 setStatic()
399 setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700400}
401
402func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
403 name := library.libName
404 if name == "" {
Colin Crossce75d2c2016-10-06 16:12:58 -0700405 name = ctx.baseModuleName()
Colin Crossb916a382016-07-29 17:28:03 -0700406 }
407
408 if ctx.Host() && Bool(library.Properties.Unique_host_soname) {
409 if !strings.HasSuffix(name, "-host") {
410 name = name + "-host"
411 }
412 }
413
Colin Crossa48ab5b2017-02-14 15:28:44 -0800414 return name + library.MutatedProperties.VariantName
Colin Crossb916a382016-07-29 17:28:03 -0700415}
416
417func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
418 location := InstallInSystem
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700419 if library.sanitize.inSanitizerDir() {
420 location = InstallInSanitizerDir
Colin Crossb916a382016-07-29 17:28:03 -0700421 }
422 library.baseInstaller.location = location
423
424 library.baseLinker.linkerInit(ctx)
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700425
426 library.relocationPacker.packingInit(ctx)
Colin Crossb916a382016-07-29 17:28:03 -0700427}
428
Colin Cross37047f12016-12-13 17:06:13 -0800429func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
Colin Crossb916a382016-07-29 17:28:03 -0700430 deps = library.baseLinker.linkerDeps(ctx, deps)
431
432 if library.static() {
433 deps.WholeStaticLibs = append(deps.WholeStaticLibs,
434 library.Properties.Static.Whole_static_libs...)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700435 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...)
436 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...)
Colin Crossa48ab5b2017-02-14 15:28:44 -0800437 } else if library.shared() {
Dan Willemsen2e47b342016-11-17 01:02:25 -0800438 if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700439 if !ctx.sdk() {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700440 deps.CrtBegin = "crtbegin_so"
441 deps.CrtEnd = "crtend_so"
442 } else {
Dan Albertebedf672016-11-08 15:06:22 -0800443 // TODO(danalbert): Add generation of crt objects.
444 // For `sdk_version: "current"`, we don't actually have a
445 // freshly generated set of CRT objects. Use the last stable
446 // version.
447 version := ctx.sdkVersion()
448 if version == "current" {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -0700449 version = getCurrentNdkPrebuiltVersion(ctx)
Dan Albertebedf672016-11-08 15:06:22 -0800450 }
451 deps.CrtBegin = "ndk_crtbegin_so." + version
452 deps.CrtEnd = "ndk_crtend_so." + version
Colin Cross4d9c2d12016-07-29 12:48:20 -0700453 }
454 }
455 deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...)
456 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Shared.Static_libs...)
457 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Shared.Shared_libs...)
458 }
459
460 return deps
461}
462
Colin Crossb916a382016-07-29 17:28:03 -0700463func (library *libraryDecorator) linkStatic(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700464 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700465
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700466 library.objects = deps.WholeStaticLibObjs.Copy()
467 library.objects = library.objects.Append(objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700468
469 outputFile := android.PathForModuleOut(ctx,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800470 ctx.ModuleName()+library.MutatedProperties.VariantName+staticLibraryExtension)
Dan Willemsen581341d2017-02-09 16:16:31 -0800471 builderFlags := flagsToBuilderFlags(flags)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700472
Dan Willemsen581341d2017-02-09 16:16:31 -0800473 TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
474
475 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags,
Colin Crossa48ab5b2017-02-14 15:28:44 -0800476 ctx.ModuleName()+library.MutatedProperties.VariantName)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700477
478 library.wholeStaticMissingDeps = ctx.GetMissingDependencies()
479
480 ctx.CheckbuildFile(outputFile)
481
482 return outputFile
483}
484
Colin Crossb916a382016-07-29 17:28:03 -0700485func (library *libraryDecorator) linkShared(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700486 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700487
488 var linkerDeps android.Paths
489
490 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
491 unexportedSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
492 forceNotWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
493 forceWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
494 if !ctx.Darwin() {
495 if versionScript.Valid() {
496 flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
497 linkerDeps = append(linkerDeps, versionScript.Path())
498 }
499 if unexportedSymbols.Valid() {
500 ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin")
501 }
502 if forceNotWeakSymbols.Valid() {
503 ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin")
504 }
505 if forceWeakSymbols.Valid() {
506 ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin")
507 }
508 } else {
509 if versionScript.Valid() {
510 ctx.PropertyErrorf("version_script", "Not supported on Darwin")
511 }
512 if unexportedSymbols.Valid() {
513 flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String())
514 linkerDeps = append(linkerDeps, unexportedSymbols.Path())
515 }
516 if forceNotWeakSymbols.Valid() {
517 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String())
518 linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path())
519 }
520 if forceWeakSymbols.Valid() {
521 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String())
522 linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
523 }
524 }
525
526 fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
527 outputFile := android.PathForModuleOut(ctx, fileName)
528 ret := outputFile
529
530 builderFlags := flagsToBuilderFlags(flags)
531
Colin Crossd8f8d072017-04-04 13:00:15 -0700532 if !ctx.Darwin() && !ctx.Windows() {
Colin Cross89562dc2016-10-03 17:47:19 -0700533 // Optimize out relinking against shared libraries whose interface hasn't changed by
534 // depending on a table of contents file instead of the library itself.
535 tocPath := outputFile.RelPathString()
536 tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
537 tocFile := android.PathForOutput(ctx, tocPath)
538 library.tocFile = android.OptionalPathForPath(tocFile)
539 TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
540 }
541
Dan Willemsen394e9dc2016-09-14 15:04:48 -0700542 if library.relocationPacker.needsPacking(ctx) {
543 packedOutputFile := outputFile
544 outputFile = android.PathForModuleOut(ctx, "unpacked", fileName)
545 library.relocationPacker.pack(ctx, outputFile, packedOutputFile, builderFlags)
546 }
547
Colin Cross4d9c2d12016-07-29 12:48:20 -0700548 if library.stripper.needsStrip(ctx) {
549 strippedOutputFile := outputFile
550 outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
551 library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
552 }
553
554 sharedLibs := deps.SharedLibs
555 sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
556
Dan Albertd015c4a2016-08-10 14:34:08 -0700557 // TODO(danalbert): Clean this up when soong supports prebuilts.
558 if strings.HasPrefix(ctx.selectedStl(), "ndk_libc++") {
559 libDir := getNdkStlLibDir(ctx, flags.Toolchain, "libc++")
560
561 if strings.HasSuffix(ctx.selectedStl(), "_shared") {
562 deps.StaticLibs = append(deps.StaticLibs,
563 libDir.Join(ctx, "libandroid_support.a"))
564 } else {
565 deps.StaticLibs = append(deps.StaticLibs,
566 libDir.Join(ctx, "libc++abi.a"),
567 libDir.Join(ctx, "libandroid_support.a"))
568 }
569
570 if ctx.Arch().ArchType == android.Arm {
571 deps.StaticLibs = append(deps.StaticLibs,
572 libDir.Join(ctx, "libunwind.a"))
573 }
574 }
575
Colin Cross26c34ed2016-09-30 17:10:16 -0700576 linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
577 linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700578 linkerDeps = append(linkerDeps, objs.tidyFiles...)
Colin Cross26c34ed2016-09-30 17:10:16 -0700579
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700580 TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700581 deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
582 linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
583
Dan Willemsen581341d2017-02-09 16:16:31 -0800584 objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
585 objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800586
587 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
588 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
589
Dan Willemsen581341d2017-02-09 16:16:31 -0800590 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx))
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700591 library.linkSAbiDumpFiles(ctx, objs, fileName, ret)
Dan Willemsen581341d2017-02-09 16:16:31 -0800592
Colin Cross4d9c2d12016-07-29 12:48:20 -0700593 return ret
594}
595
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700596func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800597 //Also take into account object re-use.
Justin Yun8effde42017-06-23 19:24:43 +0900598 if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800599 refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true)
600 versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
601 var symbolFile android.OptionalPath
602 if versionScript.Valid() {
603 symbolFile = versionScript
604 }
605 exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
606 var SourceAbiFlags []string
607 for _, dir := range exportIncludeDirs.Strings() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700608 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
609 }
610 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
611 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800612 }
613 exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
Jayant Chowdhary6ab3d842017-06-26 12:52:58 -0700614 library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, symbolFile, "current", fileName, exportedHeaderFlags)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800615 if refSourceDumpFile.Valid() {
Jayant Chowdhary715cac32017-04-20 06:53:59 -0700616 unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName)
617 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), unzippedRefDump, fileName)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800618 }
619 }
620}
621
622func vndkVsNdk(ctx ModuleContext) bool {
Jiyong Parkab0fd5f2017-08-03 21:22:50 +0900623 if inList(ctx.baseModuleName(), llndkLibraries) {
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800624 return false
625 }
626 return true
627}
628
Colin Crossb916a382016-07-29 17:28:03 -0700629func (library *libraryDecorator) link(ctx ModuleContext,
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700630 flags Flags, deps PathDeps, objs Objects) android.Path {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700631
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700632 objs = objs.Append(deps.Objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700633
634 var out android.Path
Colin Crossa48ab5b2017-02-14 15:28:44 -0800635 if library.static() || library.header() {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700636 out = library.linkStatic(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700637 } else {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700638 out = library.linkShared(ctx, flags, deps, objs)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700639 }
640
641 library.exportIncludes(ctx, "-I")
642 library.reexportFlags(deps.ReexportedFlags)
Dan Willemsen847dcc72016-09-29 12:13:36 -0700643 library.reexportDeps(deps.ReexportedFlagsDeps)
Colin Cross4d9c2d12016-07-29 12:48:20 -0700644
Dan Willemsene1240db2016-11-03 14:28:51 -0700645 if library.Properties.Aidl.Export_aidl_headers {
646 if library.baseCompiler.hasSrcExt(".aidl") {
Colin Cross10d22312017-05-03 11:01:58 -0700647 flags := []string{
Dan Willemsene1240db2016-11-03 14:28:51 -0700648 "-I" + android.PathForModuleGen(ctx, "aidl").String(),
Colin Cross10d22312017-05-03 11:01:58 -0700649 }
650 library.reexportFlags(flags)
651 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700652 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700653 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Dan Willemsene1240db2016-11-03 14:28:51 -0700654 }
655 }
656
657 if library.Properties.Proto.Export_proto_headers {
658 if library.baseCompiler.hasSrcExt(".proto") {
Colin Cross10d22312017-05-03 11:01:58 -0700659 flags := []string{
Colin Cross0c461f12016-10-20 16:11:43 -0700660 "-I" + protoSubDir(ctx).String(),
661 "-I" + protoDir(ctx).String(),
Colin Cross10d22312017-05-03 11:01:58 -0700662 }
663 library.reexportFlags(flags)
664 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
Colin Cross0c461f12016-10-20 16:11:43 -0700665 library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700666 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
Colin Cross0c461f12016-10-20 16:11:43 -0700667 }
668 }
669
Colin Cross4d9c2d12016-07-29 12:48:20 -0700670 return out
671}
672
Colin Crossb916a382016-07-29 17:28:03 -0700673func (library *libraryDecorator) buildStatic() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800674 return library.MutatedProperties.BuildStatic &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700675 (library.Properties.Static.Enabled == nil || *library.Properties.Static.Enabled)
676}
677
Colin Crossb916a382016-07-29 17:28:03 -0700678func (library *libraryDecorator) buildShared() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800679 return library.MutatedProperties.BuildShared &&
Colin Cross4d9c2d12016-07-29 12:48:20 -0700680 (library.Properties.Shared.Enabled == nil || *library.Properties.Shared.Enabled)
681}
682
Colin Crossb916a382016-07-29 17:28:03 -0700683func (library *libraryDecorator) getWholeStaticMissingDeps() []string {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700684 return library.wholeStaticMissingDeps
685}
686
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700687func (library *libraryDecorator) objs() Objects {
688 return library.objects
Colin Cross4d9c2d12016-07-29 12:48:20 -0700689}
690
Colin Crossbbc9f4d2017-05-03 16:24:55 -0700691func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
692 return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
Colin Cross4d9c2d12016-07-29 12:48:20 -0700693}
694
Colin Cross26c34ed2016-09-30 17:10:16 -0700695func (library *libraryDecorator) toc() android.OptionalPath {
696 return library.tocFile
697}
698
Colin Crossb916a382016-07-29 17:28:03 -0700699func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
Colin Crossc43ae772017-04-14 15:42:53 -0700700 if library.shared() {
Justin Yun8effde42017-06-23 19:24:43 +0900701 if ctx.Device() {
702 if ctx.vndk() {
703 if ctx.isVndkSp() {
704 library.baseInstaller.subDir = "vndk-sp"
705 } else if ctx.isVndk() {
706 library.baseInstaller.subDir = "vndk"
707 }
708 }
709 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700710 library.baseInstaller.install(ctx, file)
711 }
712}
713
Colin Crossb916a382016-07-29 17:28:03 -0700714func (library *libraryDecorator) static() bool {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800715 return library.MutatedProperties.VariantIsStatic
Colin Cross4d9c2d12016-07-29 12:48:20 -0700716}
717
Colin Crossa48ab5b2017-02-14 15:28:44 -0800718func (library *libraryDecorator) shared() bool {
719 return library.MutatedProperties.VariantIsShared
720}
721
722func (library *libraryDecorator) header() bool {
723 return !library.static() && !library.shared()
724}
725
726func (library *libraryDecorator) setStatic() {
727 library.MutatedProperties.VariantIsStatic = true
728 library.MutatedProperties.VariantIsShared = false
729}
730
731func (library *libraryDecorator) setShared() {
732 library.MutatedProperties.VariantIsStatic = false
733 library.MutatedProperties.VariantIsShared = true
Colin Crossb916a382016-07-29 17:28:03 -0700734}
735
Colin Crossab3b7322016-12-09 14:46:15 -0800736func (library *libraryDecorator) BuildOnlyStatic() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800737 library.MutatedProperties.BuildShared = false
Colin Crossab3b7322016-12-09 14:46:15 -0800738}
739
740func (library *libraryDecorator) BuildOnlyShared() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800741 library.MutatedProperties.BuildStatic = false
Colin Crossab3b7322016-12-09 14:46:15 -0800742}
743
Colin Cross5950f382016-12-13 12:50:57 -0800744func (library *libraryDecorator) HeaderOnly() {
Colin Crossa48ab5b2017-02-14 15:28:44 -0800745 library.MutatedProperties.BuildShared = false
746 library.MutatedProperties.BuildStatic = false
Colin Cross5950f382016-12-13 12:50:57 -0800747}
748
Colin Crossab3b7322016-12-09 14:46:15 -0800749func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
Colin Cross4d9c2d12016-07-29 12:48:20 -0700750 module := newModule(hod, android.MultilibBoth)
751
Colin Crossb916a382016-07-29 17:28:03 -0700752 library := &libraryDecorator{
Colin Crossa48ab5b2017-02-14 15:28:44 -0800753 MutatedProperties: LibraryMutatedProperties{
Colin Crossab3b7322016-12-09 14:46:15 -0800754 BuildShared: true,
755 BuildStatic: true,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700756 },
Colin Crossb916a382016-07-29 17:28:03 -0700757 baseCompiler: NewBaseCompiler(),
758 baseLinker: NewBaseLinker(),
759 baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem),
760 sanitize: module.sanitize,
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800761 sabi: module.sabi,
Colin Cross4d9c2d12016-07-29 12:48:20 -0700762 }
763
Colin Crossb916a382016-07-29 17:28:03 -0700764 module.compiler = library
765 module.linker = library
766 module.installer = library
767
768 return module, library
769}
770
Colin Cross10d22312017-05-03 11:01:58 -0700771// connects a shared library to a static library in order to reuse its .o files to avoid
772// compiling source files twice.
773func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) {
774 if staticCompiler, ok := static.compiler.(*libraryDecorator); ok {
775 sharedCompiler := shared.compiler.(*libraryDecorator)
776 if len(staticCompiler.Properties.Static.Cflags) == 0 &&
777 len(sharedCompiler.Properties.Shared.Cflags) == 0 {
778
779 mctx.AddInterVariantDependency(reuseObjTag, shared, static)
780 sharedCompiler.baseCompiler.Properties.OriginalSrcs =
781 sharedCompiler.baseCompiler.Properties.Srcs
782 sharedCompiler.baseCompiler.Properties.Srcs = nil
783 sharedCompiler.baseCompiler.Properties.Generated_sources = nil
784 }
785 }
786}
787
Colin Crossb916a382016-07-29 17:28:03 -0700788func linkageMutator(mctx android.BottomUpMutatorContext) {
789 if m, ok := mctx.Module().(*Module); ok && m.linker != nil {
790 if library, ok := m.linker.(libraryInterface); ok {
791 var modules []blueprint.Module
792 if library.buildStatic() && library.buildShared() {
793 modules = mctx.CreateLocalVariations("static", "shared")
794 static := modules[0].(*Module)
795 shared := modules[1].(*Module)
796
Colin Crossa48ab5b2017-02-14 15:28:44 -0800797 static.linker.(libraryInterface).setStatic()
798 shared.linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700799
Colin Cross10d22312017-05-03 11:01:58 -0700800 reuseStaticLibrary(mctx, static, shared)
801
Colin Crossb916a382016-07-29 17:28:03 -0700802 } else if library.buildStatic() {
803 modules = mctx.CreateLocalVariations("static")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800804 modules[0].(*Module).linker.(libraryInterface).setStatic()
Colin Crossb916a382016-07-29 17:28:03 -0700805 } else if library.buildShared() {
806 modules = mctx.CreateLocalVariations("shared")
Colin Crossa48ab5b2017-02-14 15:28:44 -0800807 modules[0].(*Module).linker.(libraryInterface).setShared()
Colin Crossb916a382016-07-29 17:28:03 -0700808 }
809 }
810 }
Colin Cross4d9c2d12016-07-29 12:48:20 -0700811}