diff options
Diffstat (limited to 'compileopts')
-rw-r--r-- | compileopts/config.go | 9 | ||||
-rw-r--r-- | compileopts/options.go | 1 | ||||
-rw-r--r-- | compileopts/target.go | 16 |
3 files changed, 25 insertions, 1 deletions
diff --git a/compileopts/config.go b/compileopts/config.go index a5ab7cd8f..67c773de1 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -72,6 +72,12 @@ func (c *Config) GOARM() string { return c.Options.GOARM } +// GOMIPS will return the GOMIPS environment variable given to the compiler when +// building a program. +func (c *Config) GOMIPS() string { + return c.Options.GOMIPS +} + // BuildTags returns the complete list of build tags used during this build. func (c *Config) BuildTags() []string { tags := append([]string(nil), c.Target.BuildTags...) // copy slice (avoid a race) @@ -240,6 +246,9 @@ func (c *Config) LibcPath(name string) (path string, precompiled bool) { if c.ABI() != "" { archname += "-" + c.ABI() } + if c.Target.SoftFloat { + archname += "-softfloat" + } // Try to load a precompiled library. precompiledDir := filepath.Join(goenv.Get("TINYGOROOT"), "pkg", archname, name) diff --git a/compileopts/options.go b/compileopts/options.go index 8b0e2266d..9601ae322 100644 --- a/compileopts/options.go +++ b/compileopts/options.go @@ -23,6 +23,7 @@ type Options struct { GOOS string // environment variable GOARCH string // environment variable GOARM string // environment variable (only used with GOARCH=arm) + GOMIPS string // environment variable (only used with GOARCH=mips and GOARCH=mipsle) Directory string // working dir, leave it unset to use the current working dir Target string Opt string diff --git a/compileopts/target.go b/compileopts/target.go index ecbebd8b3..9388b8496 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -30,6 +30,7 @@ type TargetSpec struct { Features string `json:"features,omitempty"` GOOS string `json:"goos,omitempty"` GOARCH string `json:"goarch,omitempty"` + SoftFloat bool // used for non-baremetal systems (GOMIPS=softfloat etc) BuildTags []string `json:"build-tags,omitempty"` GC string `json:"gc,omitempty"` Scheduler string `json:"scheduler,omitempty"` @@ -86,6 +87,10 @@ func (spec *TargetSpec) overrideProperties(child *TargetSpec) error { if src.Uint() != 0 { dst.Set(src) } + case reflect.Bool: + if src.Bool() { + dst.Set(src) + } case reflect.Ptr: // for pointers, copy if not nil if !src.IsNil() { dst.Set(src) @@ -290,13 +295,22 @@ func defaultTarget(options *Options) (*TargetSpec, error) { } case "mips", "mipsle": spec.CPU = "mips32r2" - spec.Features = "+fpxx,+mips32r2,+nooddspreg,-noabicalls" spec.CFlags = append(spec.CFlags, "-fno-pic") if options.GOOS == "mips" { llvmarch = "mips" // big endian } else { llvmarch = "mipsel" // little endian } + switch options.GOMIPS { + case "hardfloat": + spec.Features = "+fpxx,+mips32r2,+nooddspreg,-noabicalls" + case "softfloat": + spec.SoftFloat = true + spec.Features = "+mips32r2,+soft-float,-noabicalls" + spec.CFlags = append(spec.CFlags, "-msoft-float") + default: + return nil, fmt.Errorf("invalid GOMIPS=%s: must be hardfloat or softfloat", options.GOMIPS) + } case "wasm": llvmarch = "wasm32" spec.CPU = "generic" |