diff options
author | Ayke van Laethem <[email protected]> | 2021-11-04 20:57:43 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-11-05 08:50:36 +0100 |
commit | fb33f3813d01a33c52e82a51f026cd28107659f9 (patch) | |
tree | ff41551fcd202981601bc4e7b0a56f5f2d96d2de /src/runtime/runtime.go | |
parent | 670fcf59d8c8cb97f8aa1e113a9614564f377bb3 (diff) | |
download | tinygo-fb33f3813d01a33c52e82a51f026cd28107659f9.tar.gz tinygo-fb33f3813d01a33c52e82a51f026cd28107659f9.zip |
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.
Diffstat (limited to 'src/runtime/runtime.go')
-rw-r--r-- | src/runtime/runtime.go | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index 55102411b..5243d34eb 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -23,16 +23,6 @@ func GOROOT() string { return "/usr/local/go" } -// This is the default set of arguments, if nothing else has been set. -// This may be overriden by modifying this global at runtime init (for example, -// on Linux where there are real command line arguments). -var args = []string{"/proc/self/exe"} - -//go:linkname os_runtime_args os.runtime_args -func os_runtime_args() []string { - return args -} - // Copy size bytes from src to dst. The memory areas must not overlap. // Calls to this function are converted to LLVM intrinsic calls such as // llvm.memcpy.p0i8.p0i8.i32(dst, src, size, false). |