Hello Kent,

I extended the rumprun+rust example (available in this PR
<https://github.com/seL4/camkes/pull/4>) with a simple camkes connection
between the rumprum camkes component and a serial server component, as
shown below (full code here
<https://github.com/GaloisInc/camkes/blob/devel_rust_app/apps/rumprun_rust/rumprun_rust.camkes>
):

* composition {*
*     component rumprun_platform_layer rrpl;*

*     component rumprun_rust hello1;*
*     RUMPRUN_META_CONNECTION(hello1, rrpl)*

*     component rumprun hello2;*
*     RUMPRUN_META_CONNECTION(hello2, rrpl)*

*     component Server server;*

*     connection seL4SharedData conn(from hello1.camkes_buffer, to
server.buffer);*
*     connection seL4Notification simpleEvent1(from hello1.camkes_ev, to
server.ev);*
*     connection seL4Notification simpleEvent2(from server.ev1, to
hello1.camkes_ev1);*
* }*

I added a simple rust program
<https://github.com/GaloisInc/camkes/blob/devel_rust_app/apps/rumprun_rust/components/hellorust/rustest/src/main.rs>
(running on rumprun_rust):

*fn main() {*
* println!("Hello rust!");*
* unsafe {*
*  camkes_ev_emit();*
* }*
* println!("Waiting for event!");*
* unsafe {*
* camkes_ev1_wait();*
* }*
* println!("Got event!");*

*}*

*#[no_mangle]*
*extern {*
*    fn camkes_ev_emit();*
*    fn camkes_ev1_wait(); *
*}*

In order to compile the cargo project, I added a build.rs script
<https://github.com/GaloisInc/camkes/blob/devel_rust_app/apps/rumprun_rust/components/hellorust/rustest/build.rs>
to package the generated camkes object file (camkes.o) into an archite that
cargo can link against.

The problem is, that the generated camkes.c file contains its own main
function:

*int USED main(int argc UNUSED, char *argv[]) {*
*    assert(argc == 2);*
*    assert(strcmp(argv[0], "camkes") == 0);*

*    int thread_id = (int)(uintptr_t)(argv[1]);*
*    return post_main(thread_id);*
*}*

which collides with the *fn main()* defined in rust. (I get *multiple
definition of `main'* error).

How is this handled in rumprun_ethernet
<https://github.com/GaloisInc/camkes/blob/devel_rust_app/apps/rumprun_ethernet/rumprun_ethernet.camkes>
example? There is also a main function for the rumpkernel component
<https://github.com/GaloisInc/camkes/blob/devel_rust_app/apps/rumprun_ethernet/components/rump_ether/tcp_server.c#L49>,
and the main() from camkes, but the compilation process handles this
correctly.

Could you point me in the right direction?

Regards
Michal
_______________________________________________
Devel mailing list
[email protected]
https://sel4.systems/lists/listinfo/devel

Reply via email to