mozilla/rust — pull request #11153 by alexcrichton (2013-12-26 23:04:22+00:00)
Title: Implement the #[boot] attribute

Before this patch there was no ability to link to both libnative and libgreen
and specify which should be used to boot the main function. This commit moves
this logic into a #[boot] attribute which can allow control over this. The
changes made are:

1. The lang_start function is moved back into libstd with the signature:
fn(*u8, *u8, int, *u8) or (main, boot, argc, argv)
2. Functions can now be tagged with #[boot] to indicate that the function can be
used to boot a rust crate. This boot function is serialized to metadata.
3. Imports of external modules can also be tagged with #[boot] to indicate that
the crate's boot-function should be used to boot the runtime
4. Only one #[boot] function/crate is allowed in an executable, more than one is
an error (along with zero as well).
5. The compiler will automatically inject '#[boot] extern mod green;' for now,
this can be overrided with #[no_boot].

With this new attribute, control over how a crate boots can be fine-tuned per
executable and libraries can specify arbitrary boot functions. The boot function
is purely responsible for dictating what context the 'main' function is run in,
runtime initialization via rt::init is not the responsibility of the boot
function. Finally, the boot function is also responsible for blocking until all
rust tasks have exited.