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

No warning when CloudABI entrypoint is missing #23

Open
mcandre opened this issue Dec 26, 2018 · 1 comment
Open

No warning when CloudABI entrypoint is missing #23

mcandre opened this issue Dec 26, 2018 · 1 comment

Comments

@mcandre
Copy link

mcandre commented Dec 26, 2018

Porting applications from libc to cloudlibc is hard work, but one problem is particularly pernicious: cloudlibc toolchains do not warn the programmer when he or she forgets basic steps for correctly wiring up the new entrypoint.

  • C: No warning is presented at compilation time when the entrypoint continues to use a traditional libc-style <void|int> main([int argc[, char **argv]]) signature, as opposed to the recommended void program_main(const argdata_t *ad) signature.
  • Rust: No warning is presented at compilation time when the entrypoint function does not query argdata::env::argdata().

When this happens, the user observes the resulting CloudABI executable emit no output. It would be better for the runtime to present a dummy warning that the entrypoint was misconfigured. Best of all would be to detect this at compile time, and refuse to produce a binary with the wrong entrypoint.

@EdSchouten
Copy link
Member

I agree with this. Just to give some background: when it was just C that we supported, I wanted to remove support for main() entirely at some point. Unfortunately, there are an insane number of build systems out there that do compile-based checks that depend on main() working. GNU Autoconf checks for the existence of a function by compiling something like this:

void function_you_are_looking_for(); 
void main() { function_you_are_looking_for(); }

I guess that for the existing toolchain setup that we have, we should keep main() working, even if people shouldn't make use of it.

I am currently experimenting with building CloudABI software through Bazel. With Bazel it is far less common (or even impossible?) to do compile-based feature checking, meaning that the necessity for supporting main() is likely a lot less. I could likely omit this source file entirely, meaning we simply get a hard linker error in case program_main() is missing:

https://github.com/NuxiNL/cloudlibc/blob/master/src/libc/program/program_main.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants