mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
runtime: only initialize os.runtime_args when needed
This generally means that code size is reduced, especially when the os
package is not imported.
Specifically:
- On Linux (which currently statically links musl), it avoids calling
malloc, which avoids including the musl C heap for small programs
saving around 1.6kB.
- On WASI, it avoids initializing the args slice when the os package
is not used. This reduces binary size by around 1kB.
This commit is contained in:
committed by
Ron Evans
parent
670fcf59d8
commit
fb33f3813d
@@ -11,6 +11,14 @@ package runtime
|
||||
// The primary use case is `tinygo test`, which takes some parameters (such as
|
||||
// -test.v).
|
||||
|
||||
// This is the default set of arguments, if nothing else has been set.
|
||||
var args = []string{"/proc/self/exe"}
|
||||
|
||||
//go:linkname os_runtime_args os.runtime_args
|
||||
func os_runtime_args() []string {
|
||||
return args
|
||||
}
|
||||
|
||||
var env []string
|
||||
|
||||
//go:linkname syscall_runtime_envs syscall.runtime_envs
|
||||
|
||||
Reference in New Issue
Block a user