]> git.proxmox.com Git - wasi-libc.git/commit
Call `populate_args` only if we actually need command-line arguments (#112)
authorDan Gohman <sunfish@mozilla.com>
Fri, 25 Oct 2019 00:30:46 +0000 (17:30 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Oct 2019 00:30:46 +0000 (17:30 -0700)
commitafbf94c39e733961de6f161fc5b25cf56d3e4ca3
tree571cf408086176cbc12b108d93996ab407a5c855
parent1f11b91e7f57d205d19c477053168a710f132231
Call `populate_args` only if we actually need command-line arguments (#112)

* Link `populate_args` only if we actually need command-line arguments.

This avoids linking in the argv/argc initialization code,
and the __wasi_args_sizes_get and __wasi_args_get imports, in
programs that don't use command-line arguments. The way this works is,
if the user writes `int main(int argc, char *argv[])`, the argument
initialization code is loaded, and if they write `int main(void)`,
it's not loaded.

This promotes the `__original_main` mechanism into an effective contract
between the compiler and libc, which wasn't its original purpose,
however it seems to fit this purpose quite well.

* Document that `__original_main` may be the user's zero-arg `main`.
expected/wasm32-wasi/defined-symbols.txt
libc-bottom-half/cloudlibc/src/include/stdlib.h
libc-bottom-half/crt/crt1.c
libc-bottom-half/sources/__original_main.c [new file with mode: 0644]