]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add GOWASM environment variable
authorRichard Musiol <mail@richard-musiol.de>
Sat, 23 Mar 2019 13:18:19 +0000 (14:18 +0100)
committerRichard Musiol <neelance@gmail.com>
Sat, 23 Mar 2019 20:33:57 +0000 (20:33 +0000)
This change adds the environment variable GOWASM, which is a comma
separated list of experimental WebAssembly features that the compiled
WebAssembly binary is allowed to use. The default is to use no
experimental features. Initially there are no features avaiable.

More information about feature proposals can be found at
https://github.com/WebAssembly/proposals

Change-Id: I4c8dc534c99ecff8bb075dded0186ca8f8decaef
Reviewed-on: https://go-review.googlesource.com/c/go/+/168881
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
doc/install-source.html
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/envcmd/env.go
src/cmd/internal/objabi/util.go

index c11151be64154f8daefa40365e74cb0d2dae305f..46dc618a9c74b21b2f26cc06c28ce61d4df63746 100644 (file)
@@ -638,6 +638,17 @@ for which the compiler will target. The default is <code>power8</code>.
 </ul>
 </li>
 
+
+<li><code>$GOWASM</code> (for <code>wasm</code> only)
+       <p>
+       This variable is a comma separated list of <a href="https://github.com/WebAssembly/proposals">experimental WebAssembly features</a> that the compiled WebAssembly binary is allowed to use.
+       The default is to use no experimental features.
+       </p>
+       <ul>
+               <li>(no features yet)</li>
+       </ul>
+</li>
+
 </ul>
 
 <p>
index 80a154b066d5f1e27ba09c0b1bbfa3d9e88347e1..35f7f1a17399830c2a5e0ae3d8aa915e83c9e427 100644 (file)
@@ -105,6 +105,7 @@ var (
        GOMIPS   = objabi.GOMIPS
        GOMIPS64 = objabi.GOMIPS64
        GOPPC64  = fmt.Sprintf("%s%d", "power", objabi.GOPPC64)
+       GOWASM   = objabi.GOWASM
 )
 
 // Update build context to use our computed GOROOT.
index 08291dfb14c769ea513309462595ee407b702230..645f83246a620bf16818a9b30bb1363fdcf35ec7 100644 (file)
@@ -83,6 +83,8 @@ func MkEnv() []cfg.EnvVar {
                env = append(env, cfg.EnvVar{Name: "GOMIPS64", Value: cfg.GOMIPS64})
        case "ppc64", "ppc64le":
                env = append(env, cfg.EnvVar{Name: "GOPPC64", Value: cfg.GOPPC64})
+       case "wasm":
+               env = append(env, cfg.EnvVar{Name: "GOWASM", Value: cfg.GOWASM.String()})
        }
 
        cc := cfg.DefaultCC(cfg.Goos, cfg.Goarch)
index 665c8b3be60ff9db50ce5d75267e65a20cb1dd1f..c007f6c47535992c355f01a064a951d51718f3d3 100644 (file)
@@ -29,6 +29,7 @@ var (
        GOMIPS   = gomips()
        GOMIPS64 = gomips64()
        GOPPC64  = goppc64()
+       GOWASM   = gowasm()
        GO_LDSO  = defaultGO_LDSO
        Version  = version
 )
@@ -76,6 +77,29 @@ func goppc64() int {
        panic("unreachable")
 }
 
+type gowasmFeatures struct {
+       // no features yet
+}
+
+func (f *gowasmFeatures) String() string {
+       var flags []string
+       // no features yet
+       return strings.Join(flags, ",")
+}
+
+func gowasm() (f gowasmFeatures) {
+       for _, opt := range strings.Split(envOr("GOWASM", ""), ",") {
+               switch opt {
+               // no features yet
+               case "":
+                       // ignore
+               default:
+                       log.Fatalf("Invalid GOWASM value. No such feature: " + opt)
+               }
+       }
+       return
+}
+
 func Getgoextlinkenabled() string {
        return envOr("GO_EXTLINK_ENABLED", defaultGO_EXTLINK_ENABLED)
 }