Merge "Revert "Revert "Revert "Revert "Enable lld for windows""""" am: a1738e2c00

am: 1697e781bb

Change-Id: I6ceaffde7b71606ca5a6d086502fcc6e52e24266
This commit is contained in:
Josh Gao 2019-06-10 19:00:22 -07:00 committed by android-build-merger
commit 8563a453d6
4 changed files with 29 additions and 18 deletions

View File

@ -384,7 +384,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs,
deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true,
builderFlags, outputFile)
builderFlags, outputFile, nil)
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)

View File

@ -26,6 +26,7 @@ import (
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"android/soong/android"
"android/soong/cc/config"
@ -611,7 +612,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
// and shared libraries, to a shared library (.so) or dynamic executable
func TransformObjToDynamicBinary(ctx android.ModuleContext,
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) {
crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath, implicitOutputs android.WritablePaths) {
ldCmd := "${config.ClangBin}/clang++"
@ -648,7 +649,11 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
}
for _, lib := range sharedLibs {
libFlagsList = append(libFlagsList, lib.String())
libFile := lib.String()
if ctx.Windows() {
libFile = pathtools.ReplaceExtension(libFile, "lib")
}
libFlagsList = append(libFlagsList, libFile)
}
deps = append(deps, staticLibs...)
@ -659,11 +664,12 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
}
ctx.Build(pctx, android.BuildParams{
Rule: ld,
Description: "link " + outputFile.Base(),
Output: outputFile,
Inputs: objFiles,
Implicits: deps,
Rule: ld,
Description: "link " + outputFile.Base(),
Output: outputFile,
ImplicitOutputs: implicitOutputs,
Inputs: objFiles,
Implicits: deps,
Args: map[string]string{
"ldCmd": ldCmd,
"crtBegin": crtBegin.String(),

View File

@ -360,9 +360,10 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
)
}
} else {
f = append(f,
"-shared",
"-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
f = append(f, "-shared")
if !ctx.Windows() {
f = append(f, "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
}
}
flags.LdFlags = append(f, flags.LdFlags...)
@ -696,6 +697,14 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile
var implicitOutputs android.WritablePaths
if ctx.Windows() {
importLibraryPath := android.PathForModuleOut(ctx, pathtools.ReplaceExtension(fileName, "lib"))
flags.LdFlags = append(flags.LdFlags, "-Wl,--out-implib="+importLibraryPath.String())
implicitOutputs = append(implicitOutputs, importLibraryPath)
}
builderFlags := flagsToBuilderFlags(flags)
// Optimize out relinking against shared libraries whose interface hasn't changed by
@ -747,7 +756,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile, implicitOutputs)
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)

View File

@ -295,10 +295,6 @@ func (linker *baseLinker) useClangLld(ctx ModuleContext) bool {
if ctx.Darwin() {
return false
}
// http://b/110800681 - lld cannot link Android's Windows modules yet.
if ctx.Windows() {
return false
}
if linker.Properties.Use_clang_lld != nil {
return Bool(linker.Properties.Use_clang_lld)
}
@ -352,7 +348,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
// darwin defaults to treating undefined symbols as errors
flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
}
} else if !ctx.Darwin() {
} else if !ctx.Darwin() && !ctx.Windows() {
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined")
}
@ -389,7 +385,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...)
if ctx.Host() {
if ctx.Host() && !ctx.Windows() {
rpath_prefix := `\$$ORIGIN/`
if ctx.Darwin() {
rpath_prefix = "@loader_path/"