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

am: 93b008e5b8

Change-Id: I7efda949709415f333db20b78eca6a358ebe30e6
This commit is contained in:
Pirama Arumuga Nainar 2019-04-18 08:47:41 -07:00 committed by android-build-merger
commit 6f8716cf42
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"
@ -596,7 +597,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++"
@ -633,7 +634,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...)
@ -647,6 +652,7 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
Rule: ld,
Description: "link " + outputFile.Base(),
Output: outputFile,
ImplicitOutputs: implicitOutputs,
Inputs: objFiles,
Implicits: deps,
Args: map[string]string{

View File

@ -357,9 +357,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...)
@ -683,6 +684,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
@ -734,7 +743,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

@ -301,10 +301,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)
}
@ -358,7 +354,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")
}
@ -395,7 +391,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/"