Description of problem: Some time need build binaries for windows on linux host. It would be very convenient to do so could golang. Version-Release number of selected component (if applicable): golang-bin-1.5-0.11.rc1.el6.x86_64 golang-docs-1.5-0.11.rc1.el6.noarch golang-src-1.5-0.11.rc1.el6.noarch golang-1.5-0.11.rc1.el6.x86_64 golang-tests-1.5-0.11.rc1.el6.noarch golang-misc-1.5-0.11.rc1.el6.noarch How reproducible: GOOS=windows GOARCH=amd64 go build Steps to Reproduce: 1. install golang 2. GOOS=windows GOARCH=amd64 go build Expected results: The binaries for windows. diff --git a/golang.spec b/golang.spec index 8ea0170..2fdd3da 100644 --- a/golang.spec +++ b/golang.spec @@ -49,7 +49,7 @@ URL: http://golang.org/ Source0: https://storage.googleapis.com/golang/go%{go_version}.src.tar.gz # go1.5 bootstrapping. The compiler is written in golang. -BuildRequires: golang > 1.4 +BuildRequires: golang > 1.4 mingw64-gcc-c++ mingw64-gcc # use the arch dependent path in the bootstrap Patch212: ./golang-1.5-bootstrap-binary-path.patch @@ -236,6 +236,14 @@ CC_FOR_TARGET="gcc" \ GOOS=linux \ GOARCH=%{gohostarch} \ ./make.bash --no-clean + +CFLAGS="$RPM_OPT_FLAGS" \ +LDFLAGS="$RPM_LD_FLAGS" \ +CC="gcc" \ +CC_FOR_TARGET="gcc" \ +GOOS=windows \ +GOARCH=amd64 \ + ./make.bash --no-clean popd %install
but with go1.5, this bootstrapping is not needed. just `dnf install golang`, then `GOOS=windows GOARCH=amd64 go build <yourcode>` and it will produce <yourcode>.exe What is the issue here?
Closing as mingw is not needed for the compiler to produce windows binaries. That feature is a part of the compiler. Example: ``` vbatts@valse ~/x (master) $ cat hello.go package main import "fmt" func main() { fmt.Println("hello world!") } vbatts@valse ~/x (master) $ rpm -q golang golang-1.5-3.fc22.x86_64 vbatts@valse ~/x (master) $ go version go version go1.5 linux/amd64 vbatts@valse ~/x (master) $ GOOS=windows GOARCH=amd64 go build hello.go vbatts@valse ~/x (master) $ GOOS=darwin GOARCH=amd64 go build -o hello.darwin hello.go vbatts@valse ~/x (master) $ GOOS=freebsd GOARCH=386 go build -o hello.freebsd hello.go vbatts@valse ~/x (master) $ GOOS=linux GOARCH=arm go build -o hello.linux hello.go vbatts@valse ~/x (master) $ file hello* hello.darwin: Mach-O 64-bit x86_64 executable hello.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows hello.freebsd: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), statically linked, not stripped hello.go: C source, ASCII text hello.linux: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped ```