Enable lld for windows
Bug: http://b/110800681 The following flags that the binutils linkers support are not available in lld for Windows: -soname --no-undefined -rpath Windows also uses "import libraries", which are stub libraries used only for linking. The binutils linkers accepted a DLL and treated them as an import library. But lld issues the following error: lld-link: error: ...DLL: bad file type. Did you specify a DLL instead of an import library? To resolve this, pass '-out-implib=libFoo.a' to lld when linking libFoo.dll. Add libFoo.a as an implicit output to the 'ld' build rule. Rewrite the shared libraries for a library/binary to use the import library instead of the DLL. As a side-effect, this also (correctly) uses the AdbWinApi.a that's alongside development/host/windows/prebuilt/usb/AdbWinApi.dll Test: Run Windows tests (go/android-llvm-windows-testing) and check absence of regressions. Change-Id: I15a178589aa6882caa6e7e38650cc6ef48109764
This commit is contained in:
@@ -290,10 +290,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)
|
||||
}
|
||||
@@ -347,7 +343,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")
|
||||
}
|
||||
|
||||
@@ -384,7 +380,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/"
|
||||
|
Reference in New Issue
Block a user