Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-style command support. #203

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions expected/wasm32-wasi/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ _exit
_flushlbf
_initialize
_start
_start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does _start appear twice now?

Copy link
Member Author

@sunfishcode sunfishcode Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined in crt1.o and crt1-reactor.o. Programs will only use one or the other, but the script which generates defined-symbols.txt doesn't know that.

a64l
abort
abs
Expand Down
2 changes: 1 addition & 1 deletion libc-bottom-half/cloudlibc/src/include/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void *calloc(size_t, size_t);
div_t div(int, int) __pure2;
double drand48(void);
double erand48(__uint16_t *);
_Noreturn void exit(int);
#endif
_Noreturn void exit(int);
void free(void *);
#ifdef __wasilibc_unmodified_upstream
char *getenv(const char *);
Expand Down
18 changes: 18 additions & 0 deletions libc-bottom-half/crt/crt1-command.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <wasi/api.h>
#include <stdlib.h>
extern void __wasm_call_ctors(void);
extern int __original_main(void);
extern void __wasm_call_dtors(void);

__attribute__((export_name("_start")))
void _start(void) {
// Call `__original_main` which will either be the application's zero-argument
// `__original_main` function or a libc routine which calls `__main_void`.
// TODO: Call `main` directly once we no longer have to support old compilers.
int r = __original_main();

// If main exited successfully, just return, otherwise call `exit`.
if (r != 0) {
exit(r);
}
}