openbsd/arm not listed as a valid build target
jeroenjacobs79 opened this issue · comments
gox does not list openbsd/arm as a valid target:
gox -osarch-list | grep openbsd
openbsd/386 (default: true)
openbsd/amd64 (default: true)
Trying to build executable:
> $ gox -osarch="openbsd/arm" -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}"
No valid platforms to build for. If you specified a value
for the 'os', 'arch', or 'osarch' flags, make sure you're
using a valid value.
However, building by Go directly works just fine:
> $ GOOS=openbsd GOARCH=arm go build -v -o mybin
> $ file mybin
mybin: ELF 32-bit LSB executable, ARM, version 1 (OpenBSD), statically linked, for OpenBSD, not stripped
Version info:
> $ go version
go version go1.13.4 darwin/amd64
@jeroenjacobs79 with a few hacks to https://github.com/mitchellh/gox/blob/master/platform.go
can get a few more with a bit of trial and error
windows arm64 or arm no... golang itslef wont..
bsd etc arm64 sure. riscv64 is in go but naciente
then gox the gox folder voll'a
golang/go#27532
Suggestion [3,General]: The command gox was not found, but does exist in the current location. PowerShell 7 does not load commands from the current location by default. If you trust this command, instead type: ".\gox". See "get-help about_Command_Precedence" for more details.
PS C:\Users\black\Downloads\gox-master\gox-master> ./gox
Number of parallel builds: 11
--> windows/arm64: github.com/mitchellh/gox
--> openbsd/386: github.com/mitchellh/gox
--> darwin/386: github.com/mitchellh/gox
--> darwin/amd64: github.com/mitchellh/gox
--> linux/386: github.com/mitchellh/gox
--> linux/amd64: github.com/mitchellh/gox
--> linux/arm: github.com/mitchellh/gox
--> freebsd/386: github.com/mitchellh/gox
--> freebsd/amd64: github.com/mitchellh/gox
--> linux/s390x: github.com/mitchellh/gox
--> netbsd/386: github.com/mitchellh/gox
--> netbsd/amd64: github.com/mitchellh/gox
--> freebsd/arm: github.com/mitchellh/gox
--> openbsd/amd64: github.com/mitchellh/gox
--> windows/386: github.com/mitchellh/gox
--> windows/amd64: github.com/mitchellh/gox
--> linux/mipsle: github.com/mitchellh/gox
--> linux/mips64: github.com/mitchellh/gox
--> linux/mips64le: github.com/mitchellh/gox
--> linux/mips: github.com/mitchellh/gox
--> freebsd/riscv64: github.com/mitchellh/gox
--> linux/riscv64: github.com/mitchellh/gox
--> windows/arm: github.com/mitchellh/gox
--> netbsd/arm: github.com/mitchellh/gox
3 errors occurred:
--> windows/arm64 error: exit status 2
Stderr: cmd/go: unsupported GOOS/GOARCH pair windows/arm64
--> freebsd/riscv64 error: exit status 2
Stderr: cmd/go: unsupported GOOS/GOARCH pair freebsd/riscv64
--> linux/riscv64 error: exit status 1
Stderr: go tool compile: exit status 2
compile: unknown architecture "riscv64"
PS C:\Users\black\Downloads\gox-master\gox-master>
package main
import (
"fmt"
"log"
"strings"
version "github.com/hashicorp/go-version"
)
// Platform is a combination of OS/arch that can be built against.
type Platform struct {
OS string
Arch string
// Default, if true, will be included as a default build target
// if no OS/arch is specified. We try to only set as a default popular
// targets or targets that are generally useful. For example, Android
// is not a default because it is quite rare that you're cross-compiling
// something to Android AND something like Linux.
Default bool
}
func (p *Platform) String() string {
return fmt.Sprintf("%s/%s", p.OS, p.Arch)
}
var (
Platforms_1_0 = []Platform{
{"darwin", "386", true},
{"darwin", "amd64", true},
{"linux", "386", true},
{"linux", "amd64", true},
{"linux", "arm", true},
{"freebsd", "386", true},
{"freebsd", "amd64", true},
{"openbsd", "386", true},
{"openbsd", "amd64", true},
{"windows", "386", true},
{"windows", "amd64", true},
}
Platforms_1_1 = append(Platforms_1_0, []Platform{
{"freebsd", "arm", true},
{"netbsd", "386", true},
{"netbsd", "amd64", true},
{"netbsd", "arm", true},
{"plan9", "386", false},
}...)
Platforms_1_3 = append(Platforms_1_1, []Platform{
{"dragonfly", "386", false},
{"dragonfly", "amd64", false},
{"nacl", "amd64", false},
{"nacl", "amd64p32", false},
{"nacl", "arm", false},
{"solaris", "amd64", false},
}...)
Platforms_1_4 = append(Platforms_1_3, []Platform{
{"android", "arm", false},
{"plan9", "amd64", false},
}...)
Platforms_1_5 = append(Platforms_1_4, []Platform{
{"darwin", "arm", false},
{"darwin", "arm64", false},
{"linux", "arm64", false},
{"linux", "ppc64", false},
{"linux", "ppc64le", false},
}...)
Platforms_1_6 = append(Platforms_1_5, []Platform{
{"android", "386", false},
{"linux", "mips64", false},
{"linux", "mips64le", false},
}...)
Platforms_1_7 = append(Platforms_1_5, []Platform{
// While not fully supported s390x is generally useful
{"linux", "s390x", true},
{"plan9", "arm", false},
// Add the 1.6 Platforms, but reflect full support for mips64 and mips64le
{"android", "386", false},
{"linux", "mips64", true},
{"linux", "mips64le", true},
}...)
Platforms_1_8 = append(Platforms_1_7, []Platform{
{"linux", "mips", true},
{"linux", "mipsle", true},
}...)
Platforms_1_9 = append(Platforms_1_8, []Platform{
{"linux", "riscv64", true},
{"freebsd", "riscv64", true},
{"windows", "arm", true},
{"windows", "arm64", true},
}...)
// no new platforms in 1.10
Platforms_1_10 = Platforms_1_9
PlatformsLatest = Platforms_1_10
)
// SupportedPlatforms returns the full list of supported platforms for
// the version of Go that is
func SupportedPlatforms(v string) []Platform {
// Use latest if we get an unexpected version string
if !strings.HasPrefix(v, "go") {
return PlatformsLatest
}
// go-version only cares about version numbers
v = v[2:]
current, err := version.NewVersion(v)
if err != nil {
log.Printf("Unable to parse current go version: %s\n%s", v, err.Error())
// Default to latest
return PlatformsLatest
}
var platforms = []struct {
constraint string
plat []Platform
}{
{"<= 1.0", Platforms_1_0},
{">= 1.1, < 1.3", Platforms_1_1},
{">= 1.3, < 1.4", Platforms_1_3},
{">= 1.4, < 1.5", Platforms_1_4},
{">= 1.5, < 1.6", Platforms_1_5},
{">= 1.6, < 1.7", Platforms_1_6},
{">= 1.7, < 1.8", Platforms_1_7},
{">= 1.8, < 1.9", Platforms_1_8},
{">= 1.9, < 1.10", Platforms_1_9},
{">=1.10, < 1.11", Platforms_1_10},
}
for _, p := range platforms {
constraints, err := version.NewConstraint(p.constraint)
if err != nil {
panic(err)
}
if constraints.Check(current) {
return p.plat
}
}
// Assume latest
return Platforms_1_9
}
riscv targets if in newer go perhaps...
As a "work-around" I created a makefile and just use "make -j" for concurrent builds, which does the job as well. It removes the dependency on hard-coded os/arch targets which currently exists in gox.
Beware, here be dragons: https://github.com/jeroenjacobs79/tobw/blob/develop/Makefile
i was to lazy to reboot to linux for the day ... on own laptop ,
birthday ...
so with a bit of hackery since i needed a few xbuild's from balena as is for a few docker projects..
and reload of rpi and rock64pro.... tonight ... to test..
i added a few less likely targets . #142
as a test openbsd freebsd etc arm and arm64 etc oh my...
riscv64 in golang is newish , windows arm is barely alive...
however got a gox out none the less , and hex of bin on quick inspection of header looks like a genuine arm windows coff. exe. not bad for a meddlesome Sec-Eng...
arm64 would be on windows for iot (BAIT devices at network edge.... )
with Gentoo emerge can get around a good many as well but BSD is unfortunately deprecated.