mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +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
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user