diff options
author | Ayke van Laethem <[email protected]> | 2021-09-22 02:44:28 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-10-04 18:22:55 +0200 |
commit | a6246e60f3d9bd54095e1a28baca2d799cd1cb15 (patch) | |
tree | 9238f1c1fd620f26b991cad7b5adf29c781aaa90 /compileopts/target.go | |
parent | 0a80da46b1eca3cc5da51633b95d5a31b949a59b (diff) | |
download | tinygo-a6246e60f3d9bd54095e1a28baca2d799cd1cb15.tar.gz tinygo-a6246e60f3d9bd54095e1a28baca2d799cd1cb15.zip |
main: remove -target flag for LLVM targets
It is better to use environment variables (GOOS and GOARCH) for
consistency instead of providing two slightly incompatible ways. This
-target flag should only be used to specify a .json file (either
directly or in the TinyGo targets directory). Previously it was possible
to specify the LLVM target as well but that was never really fully
supported.
So:
- To specify a different OS/arch like you would in regular Go, use
GOOS and GOARCH.
- To specify a microcontroller chip or board, use the -target flag.
Also remove the old `os.Setenv` which might have had a purpose long ago
but doesn't have a purpose now.
Diffstat (limited to 'compileopts/target.go')
-rw-r--r-- | compileopts/target.go | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/compileopts/target.go b/compileopts/target.go index 7a2bc15f4..aaa5fadad 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -189,41 +189,16 @@ func LoadTarget(options *Options) (*TargetSpec, error) { // Arduino). spec := &TargetSpec{} err := spec.loadFromGivenStr(options.Target) - if err == nil { - // Successfully loaded this target from a built-in .json file. Make sure - // it includes all parents as specified in the "inherits" key. - err = spec.resolveInherits() - if err != nil { - return nil, err - } - return spec, nil - } else if !os.IsNotExist(err) { - // Expected a 'file not found' error, got something else. Report it as - // an error. + if err != nil { + return nil, err + } + // Successfully loaded this target from a built-in .json file. Make sure + // it includes all parents as specified in the "inherits" key. + err = spec.resolveInherits() + if err != nil { return nil, err - } else { - // Load target from given triple, ignore GOOS/GOARCH environment - // variables. - tripleSplit := strings.Split(options.Target, "-") - if len(tripleSplit) < 3 { - return nil, errors.New("expected a full LLVM target or a custom target in -target flag") - } - goos := tripleSplit[2] - if strings.HasPrefix(goos, "darwin") { - goos = "darwin" - } - goarch := map[string]string{ // map from LLVM arch to Go arch - "i386": "386", - "i686": "386", - "x86_64": "amd64", - "aarch64": "arm64", - "armv7": "arm", - }[tripleSplit[0]] - if goarch == "" { - goarch = tripleSplit[0] - } - return defaultTarget(goos, goarch, strings.Join(tripleSplit, "-")) } + return spec, nil } // WindowsBuildNotSupportedErr is being thrown, when goos is windows and no target has been specified. |