diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-12-04 14:59:08 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-12-04 15:12:42 -0800 |
commit | 93c2831af1798870245ee516e51c29a49a395c21 (patch) | |
tree | 0d787cfc3fa992fa89bf4b3314c9308120da9bbc | |
parent | 4bd49c2ce1d578a514f7c16ff395aa64a364b7ac (diff) | |
download | build_soong-93c2831af1798870245ee516e51c29a49a395c21.tar.gz build_soong-93c2831af1798870245ee516e51c29a49a395c21.tar.bz2 build_soong-93c2831af1798870245ee516e51c29a49a395c21.zip |
Add Darwin-specific linker file flags
Darwin's ld does not support --version-script, but it does support
-unexported_symbols_list, -force_symbols_not_weak_list, and
-force_symbols_weak_list that all take files as arguments.
Instead of expecting these to be added to the ldflags manually, add
properties for them so that the dependencies are handled appropriately.
Also sanity checks the darwin vs non-darwin usages early, so that the
error message is faster and more obvious.
Change-Id: I42526cc4367b6ea9adfdbb58753e12824e8c321c
-rw-r--r-- | cc/cc.go | 44 |
1 files changed, 40 insertions, 4 deletions
@@ -1068,6 +1068,12 @@ type CCLibraryProperties struct { // local file name to pass to the linker as --version_script Version_script string `android:"arch_variant"` + // local file name to pass to the linker as -unexported_symbols_list + Unexported_symbols_list string `android:"arch_variant"` + // local file name to pass to the linker as -force_symbols_not_weak_list + Force_symbols_not_weak_list string `android:"arch_variant"` + // local file name to pass to the linker as -force_symbols_weak_list + Force_symbols_weak_list string `android:"arch_variant"` } type CCLibrary struct { @@ -1260,10 +1266,40 @@ func (c *CCLibrary) compileSharedLibrary(ctx common.AndroidModuleContext, var linkerDeps []string - if c.LibraryProperties.Version_script != "" { - versionScript := filepath.Join(common.ModuleSrcDir(ctx), c.LibraryProperties.Version_script) - sharedFlags.LdFlags = append(sharedFlags.LdFlags, "-Wl,--version-script,"+versionScript) - linkerDeps = append(linkerDeps, versionScript) + if !ctx.Darwin() { + if c.LibraryProperties.Version_script != "" { + versionScript := filepath.Join(common.ModuleSrcDir(ctx), c.LibraryProperties.Version_script) + sharedFlags.LdFlags = append(sharedFlags.LdFlags, "-Wl,--version-script,"+versionScript) + linkerDeps = append(linkerDeps, versionScript) + } + if c.LibraryProperties.Unexported_symbols_list != "" { + ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin") + } + if c.LibraryProperties.Force_symbols_not_weak_list != "" { + ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin") + } + if c.LibraryProperties.Force_symbols_weak_list != "" { + ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin") + } + } else { + if c.LibraryProperties.Version_script != "" { + ctx.PropertyErrorf("version_script", "Not supported on Darwin") + } + if c.LibraryProperties.Unexported_symbols_list != "" { + localFile := filepath.Join(common.ModuleSrcDir(ctx), c.LibraryProperties.Unexported_symbols_list) + sharedFlags.LdFlags = append(sharedFlags.LdFlags, "-Wl,-unexported_symbols_list,"+localFile) + linkerDeps = append(linkerDeps, localFile) + } + if c.LibraryProperties.Force_symbols_not_weak_list != "" { + localFile := filepath.Join(common.ModuleSrcDir(ctx), c.LibraryProperties.Force_symbols_not_weak_list) + sharedFlags.LdFlags = append(sharedFlags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+localFile) + linkerDeps = append(linkerDeps, localFile) + } + if c.LibraryProperties.Force_symbols_weak_list != "" { + localFile := filepath.Join(common.ModuleSrcDir(ctx), c.LibraryProperties.Force_symbols_weak_list) + sharedFlags.LdFlags = append(sharedFlags.LdFlags, "-Wl,-force_symbols_weak_list,"+localFile) + linkerDeps = append(linkerDeps, localFile) + } } TransformObjToDynamicBinary(ctx, objFiles, deps.SharedLibs, deps.StaticLibs, |