Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions go.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type CompileOpts struct {
OutputTpl string
Ldflags string
Gcflags string
Cc string
Cxx string
Asmflags string
Tags string
Cgo bool
Expand All @@ -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" {
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down