Change STL for Windows to libc++.
- Stop including libstdc++ headers. - '-pthread' and 'static-libgcc' are unused when we pass -nodefaultlibs. We didn't pass -nodefaultlibs for libstdc++. - Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj exception model for 32-bit. - Disable visibility annotations for libcxx and libcxxabi since we are only going to support these as static libraries. - Use Win32 threads. MinGW pthreads throws an error when building libcxx since it's pthread_mutex_initializer is not constant (needs a cast). - Link libgcc_eh, which needs pthread, which in turn depends on kernel32. Wrap the libraries with --start-group and --end-group and remove duplicates. Test: Build and test Windows binaries under Wine. Change-Id: I8be51b004585e11ef51b7d5012f2a51330d1260f
This commit is contained in:
parent
38441856ca
commit
a403cc7254
2 changed files with 25 additions and 20 deletions
|
@ -47,18 +47,11 @@ var (
|
|||
"-isystem ${WindowsGccRoot}/${WindowsGccTriple}/include",
|
||||
}
|
||||
|
||||
windowsClangCppflags = []string{
|
||||
"-isystem ${WindowsGccRoot}/${WindowsGccTriple}/include/c++/4.8.3",
|
||||
"-isystem ${WindowsGccRoot}/${WindowsGccTriple}/include/c++/4.8.3/backward",
|
||||
}
|
||||
windowsClangCppflags = []string{}
|
||||
|
||||
windowsX86ClangCppflags = []string{
|
||||
"-isystem ${WindowsGccRoot}/${WindowsGccTriple}/include/c++/4.8.3/${WindowsGccTriple}/32",
|
||||
}
|
||||
windowsX86ClangCppflags = []string{}
|
||||
|
||||
windowsX8664ClangCppflags = []string{
|
||||
"-isystem ${WindowsGccRoot}/${WindowsGccTriple}/include/c++/4.8.3/${WindowsGccTriple}",
|
||||
}
|
||||
windowsX8664ClangCppflags = []string{}
|
||||
|
||||
windowsLdflags = []string{
|
||||
"--enable-stdcall-fixup",
|
||||
|
@ -80,14 +73,13 @@ var (
|
|||
"-m32",
|
||||
"-Wl,--large-address-aware",
|
||||
"-L${WindowsGccRoot}/${WindowsGccTriple}/lib32",
|
||||
"-static-libgcc",
|
||||
}
|
||||
windowsX86ClangLdflags = append(ClangFilterUnknownCflags(windowsX86Ldflags), []string{
|
||||
"-B${WindowsGccRoot}/${WindowsGccTriple}/bin",
|
||||
"-B${WindowsGccRoot}/lib/gcc/${WindowsGccTriple}/4.8.3/32",
|
||||
"-L${WindowsGccRoot}/lib/gcc/${WindowsGccTriple}/4.8.3/32",
|
||||
"-B${WindowsGccRoot}/${WindowsGccTriple}/lib32",
|
||||
"-pthread",
|
||||
|
||||
// Bug: http://b/109759970 - WAR until issue with ld.bfd's
|
||||
// inability to handle Clang-generated section names is fixed.
|
||||
"-Wl,--allow-multiple-definition",
|
||||
|
@ -97,7 +89,6 @@ var (
|
|||
windowsX8664Ldflags = []string{
|
||||
"-m64",
|
||||
"-L${WindowsGccRoot}/${WindowsGccTriple}/lib64",
|
||||
"-static-libgcc",
|
||||
"-Wl,--high-entropy-va",
|
||||
}
|
||||
windowsX8664ClangLdflags = append(ClangFilterUnknownCflags(windowsX8664Ldflags), []string{
|
||||
|
@ -105,7 +96,6 @@ var (
|
|||
"-B${WindowsGccRoot}/lib/gcc/${WindowsGccTriple}/4.8.3",
|
||||
"-L${WindowsGccRoot}/lib/gcc/${WindowsGccTriple}/4.8.3",
|
||||
"-B${WindowsGccRoot}/${WindowsGccTriple}/lib64",
|
||||
"-pthread",
|
||||
}...)
|
||||
windowsX8664ClangLldflags = ClangFilterUnknownLldflags(windowsX8664ClangLdflags)
|
||||
|
||||
|
|
27
cc/stl.go
27
cc/stl.go
|
@ -81,9 +81,9 @@ func (stl *stl) begin(ctx BaseModuleContext) {
|
|||
}
|
||||
} else if ctx.Windows() {
|
||||
switch s {
|
||||
case "libc++", "libc++_static", "libstdc++", "":
|
||||
// libc++ is not supported on mingw
|
||||
return "libstdc++"
|
||||
case "libc++", "libc++_static", "":
|
||||
// Only use static libc++ for Windows.
|
||||
return "libc++_static"
|
||||
case "none":
|
||||
return ""
|
||||
default:
|
||||
|
@ -177,6 +177,20 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
|
|||
} else {
|
||||
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.Os()]...)
|
||||
}
|
||||
if ctx.Windows() {
|
||||
// Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj
|
||||
// exception model for 32-bit.
|
||||
if ctx.Arch().ArchType == android.X86 {
|
||||
flags.CppFlags = append(flags.CppFlags, "-fsjlj-exceptions")
|
||||
}
|
||||
flags.CppFlags = append(flags.CppFlags,
|
||||
// Disable visiblity annotations since we're using static
|
||||
// libc++.
|
||||
"-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
|
||||
"-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
|
||||
// Use Win32 threads in libc++.
|
||||
"-D_LIBCPP_HAS_THREAD_API_WIN32")
|
||||
}
|
||||
} else {
|
||||
if ctx.Arch().ArchType == android.Arm {
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a")
|
||||
|
@ -213,9 +227,10 @@ func init() {
|
|||
hostDynamicGccLibs = map[android.OsType][]string{
|
||||
android.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"},
|
||||
android.Darwin: []string{"-lc", "-lSystem"},
|
||||
android.Windows: []string{"-lmingw32", "-lgcc", "-lmoldname", "-lmingwex", "-lmsvcr110",
|
||||
"-lmsvcrt", "-ladvapi32", "-lshell32", "-luser32", "-lkernel32", "-lmingw32",
|
||||
"-lgcc", "-lmoldname", "-lmingwex", "-lmsvcrt"},
|
||||
android.Windows: []string{"-Wl,--start-group", "-lmingw32", "-lgcc", "-lgcc_eh",
|
||||
"-lmoldname", "-lmingwex", "-lmsvcr110", "-lmsvcrt", "-lpthread",
|
||||
"-ladvapi32", "-lshell32", "-luser32", "-lkernel32", "-lpsapi",
|
||||
"-Wl,--end-group"},
|
||||
}
|
||||
hostStaticGccLibs = map[android.OsType][]string{
|
||||
android.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"},
|
||||
|
|
Loading…
Reference in a new issue