Merge "Revert "Revert "Enable lld for windows""" am: cd9a1e2e73
am: 93b008e5b8
Change-Id: I7efda949709415f333db20b78eca6a358ebe30e6
This commit is contained in:
commit
6f8716cf42
|
@ -384,7 +384,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
|
||||||
|
|
||||||
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs,
|
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs,
|
||||||
deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true,
|
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.StaticLibObjs.coverageFiles...)
|
||||||
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
|
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/pathtools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc/config"
|
"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
|
// and shared libraries, to a shared library (.so) or dynamic executable
|
||||||
func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
||||||
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
|
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++"
|
ldCmd := "${config.ClangBin}/clang++"
|
||||||
|
|
||||||
|
@ -633,7 +634,11 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lib := range sharedLibs {
|
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...)
|
deps = append(deps, staticLibs...)
|
||||||
|
@ -644,11 +649,12 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: ld,
|
Rule: ld,
|
||||||
Description: "link " + outputFile.Base(),
|
Description: "link " + outputFile.Base(),
|
||||||
Output: outputFile,
|
Output: outputFile,
|
||||||
Inputs: objFiles,
|
ImplicitOutputs: implicitOutputs,
|
||||||
Implicits: deps,
|
Inputs: objFiles,
|
||||||
|
Implicits: deps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"ldCmd": ldCmd,
|
"ldCmd": ldCmd,
|
||||||
"crtBegin": crtBegin.String(),
|
"crtBegin": crtBegin.String(),
|
||||||
|
|
|
@ -357,9 +357,10 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
f = append(f,
|
f = append(f, "-shared")
|
||||||
"-shared",
|
if !ctx.Windows() {
|
||||||
"-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
|
f = append(f, "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flags.LdFlags = append(f, flags.LdFlags...)
|
flags.LdFlags = append(f, flags.LdFlags...)
|
||||||
|
@ -683,6 +684,14 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
||||||
outputFile := android.PathForModuleOut(ctx, fileName)
|
outputFile := android.PathForModuleOut(ctx, fileName)
|
||||||
ret := outputFile
|
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)
|
builderFlags := flagsToBuilderFlags(flags)
|
||||||
|
|
||||||
// Optimize out relinking against shared libraries whose interface hasn't changed by
|
// 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,
|
TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
|
||||||
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
|
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.StaticLibObjs.coverageFiles...)
|
||||||
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
|
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
|
||||||
|
|
|
@ -301,10 +301,6 @@ func (linker *baseLinker) useClangLld(ctx ModuleContext) bool {
|
||||||
if ctx.Darwin() {
|
if ctx.Darwin() {
|
||||||
return false
|
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 {
|
if linker.Properties.Use_clang_lld != nil {
|
||||||
return Bool(linker.Properties.Use_clang_lld)
|
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
|
// darwin defaults to treating undefined symbols as errors
|
||||||
flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup")
|
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")
|
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)...)
|
flags.LdFlags = append(flags.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...)
|
||||||
|
|
||||||
if ctx.Host() {
|
if ctx.Host() && !ctx.Windows() {
|
||||||
rpath_prefix := `\$$ORIGIN/`
|
rpath_prefix := `\$$ORIGIN/`
|
||||||
if ctx.Darwin() {
|
if ctx.Darwin() {
|
||||||
rpath_prefix = "@loader_path/"
|
rpath_prefix = "@loader_path/"
|
||||||
|
|
Loading…
Reference in New Issue