diff --git a/go.go b/go.go index 37edb36..053cb91 100644 --- a/go.go +++ b/go.go @@ -26,6 +26,8 @@ type CompileOpts struct { OutputTpl string Ldflags string Gcflags string + Cc string + Cxx string Asmflags string Tags string Cgo bool @@ -39,6 +41,13 @@ func GoCrossCompile(opts *CompileOpts) error { "GOOS="+opts.Platform.OS, "GOARCH="+opts.Platform.Arch) + if opts.Cc != "" { + env = append(env, "CC="+opts.Cc) + } + if opts.Cxx != "" { + env = append(env, "CXX="+opts.Cxx) + } + // If we're building for our own platform, then enable cgo always. We // respect the CGO_ENABLED flag if that is explicitly set on the platform. if !opts.Cgo && os.Getenv("CGO_ENABLED") != "0" { diff --git a/main.go b/main.go index d8098c9..07f91e2 100644 --- a/main.go +++ b/main.go @@ -143,6 +143,8 @@ func realMain() int { envOverride(&opts.Ldflags, platform, "LDFLAGS") envOverride(&opts.Gcflags, platform, "GCFLAGS") envOverride(&opts.Asmflags, platform, "ASMFLAGS") + envOverride(&opts.Cc, platform, "CC") + envOverride(&opts.Cxx, platform, "CXX") if err := GoCrossCompile(opts); err != nil { errorLock.Lock()