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

Apps fail to compile when using lib-ukrust #1147

Open
Mihnea27 opened this issue Oct 26, 2023 · 2 comments · May be fixed by #1350
Open

Apps fail to compile when using lib-ukrust #1147

Mihnea27 opened this issue Oct 26, 2023 · 2 comments · May be fixed by #1350
Labels
kind/bug Something isn't working

Comments

@Mihnea27
Copy link

Describe the bug

Including lib-ukrust [1] and lib-rust [2] makes application not compile. I've noticed this trying to compile an application with an external Rust library but the behaviour is the same if you include the two libraries with any application.

[1] https://github.com/unikraft/unikraft/tree/staging/lib/ukrust
[2] https://github.com/unikraft/lib-rust

Steps to reproduce

  1. Take the app-helloworld [3] application and add the lib-ukrust and lib-rust libraries with make menuconfig, lib-musl is also needed.
  2. The rust toolchain needs to be set to nightly with:
    rustup override set nightly
  3. make

I've tested for x86_64 with KVM, but the error should hold for all combinations.

Expected behavior

The application compiles to a binary that can be run with qemu.

Which architectures were you using or does this bug affect?

x86_64

Which platforms were you using or does this bug affect?

kvm

Relevant log output

make[1]: Entering directory '/home/mihnea27/git/unikraft'
  LN      Makefile
  CP      config
  GEN     libsyscall_shim: provided_syscalls.in.new
  CP      libsyscall_shim: provided_syscalls.in
  GEN     libuklibid: libraries.in.new
   RUSTC   libukrust: ukrust_sys.o
warning: target json file contains unused fields: needs-plt

error[E0425]: cannot find function `__ukrust_sys_malloc` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:42:28
   |
42 |         unsafe { bindings::__ukrust_sys_malloc(layout.size() as u64) as *mut u8 }
   |                            ^^^^^^^^^^^^^^^^^^^ not found in `bindings`

error[E0425]: cannot find function `__ukrust_sys_free` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:46:28
   |
46 |         unsafe { bindings::__ukrust_sys_free(ptr as *mut c_types::c_void); }
   |                            ^^^^^^^^^^^^^^^^^ not found in `bindings`

error[E0425]: cannot find function `__ukrust_sys_malloc` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:55:24
   |
55 |     unsafe { bindings::__ukrust_sys_malloc(size as u64) as *mut u8 }
   |                        ^^^^^^^^^^^^^^^^^^^ not found in `bindings`

error[E0425]: cannot find function `__ukrust_sys_free` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:60:24
   |
60 |     unsafe { bindings::__ukrust_sys_free(ptr as *mut c_types::c_void); }
   |                        ^^^^^^^^^^^^^^^^^ not found in `bindings`

error[E0425]: cannot find function `__ukrust_sys_realloc` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:66:19
   |
66 |         bindings::__ukrust_sys_realloc(
   |                   ^^^^^^^^^^^^^^^^^^^^ not found in `bindings`

error[E0425]: cannot find function `__ukrust_sys_calloc` in module `bindings`
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/allocator.rs:75:24
   |
75 |     unsafe { bindings::__ukrust_sys_calloc(0, size as u64) as *mut u8 }
   |                        ^^^^^^^^^^^^^^^^^^^ not found in `bindings`

warning: the feature `lang_items` is internal to the compiler or standard library
  --> /home/mihnea27/git/unikraft/lib/ukrust/ukrust_sys/lib.rs:39:5
   |
39 |     lang_items,
   |     ^^^^^^^^^^
   |
   = note: using it is strongly discouraged
   = note: `#[warn(internal_features)]` on by default

error: aborting due to 6 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0425`.
make[2]: *** [/home/mihnea27/git/unikraft/lib/ukrust/Makefile.uk:36: /home/mihnea27/unikernels/app-helloworld/build/libukrust/ukrust_sys.o] Error 1
make[1]: *** [Makefile:1156: sub-make] Error 2
make[1]: Leaving directory '/home/mihnea27/git/unikraft'
make: *** [Makefile:6: all] Error 2
@Mihnea27 Mihnea27 added the kind/bug Something isn't working label Oct 26, 2023
@Mihnea27
Copy link
Author

Mihnea27 commented Oct 26, 2023

Compiling Unikraft with lib-ukrust included results in the following error initially and then on subsequent compiles it results in the initial error reported:

mihnea27@mihnea27-debian-desktop:~/git/unikraft$ RUST_BACKTRACE=full make
  LN      Makefile
  CP      config
  MKDIR   lxdialog
  MAKE    kconfig
  GEN     config.h
  GEN     libuklibid: libraries.in.new
  CP      libuklibid: libraries.in
   BINDGEN  libukrust: bindings_generated.rs
/home/mihnea27/git/unikraft/lib/uklibid/include/uk/libid.h:11:10: fatal error: 'uk/bits/libid.h' file not found
thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("/home/mihnea27/git/unikraft/lib/uklibid/include/uk/libid.h:11:10: fatal error: 'uk/bits/libid.h' file not found\n")', src/main.rs:48:36
stack backtrace:
   0:     0x56404a7da30c - <unknown>
   1:     0x56404a7ee8fe - <unknown>
   2:     0x56404a7b2601 - <unknown>
   3:     0x56404a7be67e - <unknown>
   4:     0x56404a7be2e7 - <unknown>
   5:     0x56404a7beb91 - <unknown>
   6:     0x56404a7dad37 - <unknown>
   7:     0x56404a7da424 - <unknown>
   8:     0x56404a7be842 - <unknown>
   9:     0x56404a5ce8f3 - <unknown>
  10:     0x56404a5ce9d3 - <unknown>
  11:     0x56404a5e1f77 - <unknown>
  12:     0x56404a5eb957 - <unknown>
  13:     0x56404a5e2283 - <unknown>
  14:     0x56404a5e4619 - <unknown>
  15:     0x56404a7b1f15 - <unknown>
  16:     0x56404a5ebcb8 - <unknown>
  17:     0x7fbf5d5cf1ca - <unknown>
  18:     0x7fbf5d5cf285 - __libc_start_main
  19:     0x56404a5ceb41 - <unknown>
  20:                0x0 - <unknown>
make[1]: *** [/home/mihnea27/git/unikraft/lib/ukrust/Makefile.uk:28: /home/mihnea27/git/unikraft/build/libukrust/bindings_generated.rs] Error 1
make: *** [Makefile:1156: sub-make] Error 2

The error comes from this line https://github.com/unikraft/unikraft/blob/97523b55ac9e1327f7294da1feec8d4869da534d/lib/ukrust/Makefile.uk#L28C2-L28C2 that calls bindgen to generate the Rust bindings

@cocodery
Copy link

cocodery commented Nov 16, 2023

Yeah, I meet this problem too.
Besides, I find another sub-problem related.
Each time when you run command make after clean, which has select libukrust, you will get an error message like that

fatal error: 'uk/bits/libid.h' file not found

I trace commands generated by make --just-print and it shows part of it below
And you have too run twice to avoid this sub-problem.
I think it needs to do change the order of generated commands to fix.

printf ' %-7s %s\n' 'GEN' 'libuklibid':' libraries.in.new' && /bin/bash libraries.in.new.cmd
printf ' %-7s %s\n' 'CP' 'libuklibid':' libraries.in' && /bin/bash libraries.in.cmd
printf ' %-7s %s\n' ' RUSTC' ' libukrust':' ukrust_sys.o' && /bin/bash ukrust_sys.o.cmd
printf ' %-7s %s\n' ' RUSTC' ' libukrust':' alloc.o' && /bin/bash alloc.o.cmd
printf ' %-7s %s\n' 'AWK' 'libuklibid':' libid.h' && /bin/bash /home/cocodery/workspace/proj/unikraft/hello-world/helloworld-rust/build/libuklibid/include/uk/bits/libid.h.cmd
printf ' %-7s %s\n' 'AWK' 'libuklibid':' namemap.c' && /bin/bash /home/cocodery/workspace/proj/unikraft/hello-world/helloworld-rust/build/libuklibid/namemap.c.cmd
printf ' %-7s %s\n' 'AWK' 'libuklibid':' selfids.c' && /bin/bash /home/cocodery/workspace/proj/unikraft/hello-world/helloworld-rust/build/libuklibid/selfids.c.cmd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Status: 🧊 Icebox
2 participants