Support cross-compiling Windows binaries on Linux
This defines another mutator between HostOrDevice and Arch that will
expand host modules into a module for each host type
(Darwin/Linux/Windows) that is currently being built.
Change-Id: I4c8ac6b616c229f6bd45ad8a35902652fb6a4fff
diff --git a/cc/builder.go b/cc/builder.go
index e3b9983..64437d2 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -33,7 +33,6 @@
const (
objectExtension = ".o"
- sharedLibraryExtension = ".so"
staticLibraryExtension = ".a"
)
@@ -310,7 +309,7 @@
var libFlagsList []string
if len(wholeStaticLibs) > 0 {
- if ctx.Host() && runtime.GOOS == "darwin" {
+ if ctx.Host() && ctx.Darwin() {
libFlagsList = append(libFlagsList, common.JoinWithPrefix(wholeStaticLibs, "-force_load "))
} else {
libFlagsList = append(libFlagsList, "-Wl,--whole-archive ")
@@ -334,11 +333,11 @@
if !strings.HasPrefix(file, "lib") {
panic("shared library " + lib + " does not start with lib")
}
- if !strings.HasSuffix(file, sharedLibraryExtension) {
- panic("shared library " + lib + " does not end with " + sharedLibraryExtension)
+ if !strings.HasSuffix(file, flags.toolchain.ShlibSuffix()) {
+ panic("shared library " + lib + " does not end with " + flags.toolchain.ShlibSuffix())
}
libFlagsList = append(libFlagsList,
- "-l"+strings.TrimSuffix(strings.TrimPrefix(file, "lib"), sharedLibraryExtension))
+ "-l"+strings.TrimSuffix(strings.TrimPrefix(file, "lib"), flags.toolchain.ShlibSuffix()))
ldDirs = append(ldDirs, dir)
}