fix(Dockerfile): setup for building libafl_qemu in Docker
Closes #1895
This is currently a draft, as llvm.sh doesn't install llvm-config and also doesn't support installing version 18 on Debian Bookworm which is the current base of the Rust images.
llvm.sh doesn't install llvm-config
for this you can simply apt install llvm-config-18 after running llvm.sh
But unfortunately ./llvm.sh 18 in line 24 of the docker file fails with the error message:
+ apt-get install -y clang-18 lldb-18 lld-18 clangd-18
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package clang-18
E: Unable to locate package lldb-18
E: Unable to locate package lld-18
E: Unable to locate package clangd-18
Other people have had the same issue (the adding of the repository with add-apt-repository doesn't seem to work) and there is a workaround (https://github.com/llvm/llvm-project/issues/62475#issuecomment-1592651066) but I'm unsure if I should implement the workaround or if I should try and land the fix against the source repo.
Would you be open to accept the workaround?
For future reference: There is no need install llvm-config separately it is part of the llvm-18 package as llvm-config-18
Okay, the build now gets to the point that new bindings get generated which differ from the current bindings (unsafe extern "C" vs extern "C") here.
Do you consider resolving this in scope for this PR or should it be separate?
you can just include it here if you found the fix
Steps to verify this fix works:
docker build -t libafl . && docker run --name libafl --rm -it libafl
# In the now open shell
cargo build --no-default-features -p libafl_qemu && cargo build --no-default-features -p libafl_qemu --release
Also changed the dev container to use the new syntax.
I also tried to verify that this works by running the fuzzers/qemu_systemmode example but I'm not able to interpret the runtime output of the fuzzer. (It does build and start)
error[E0308]: arguments to this function are incorrect
--> /home/runner/work/LibAFL/LibAFL/libafl_qemu/src/emu.rs:1533:23
|
1533 | let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: expected normal fn, found unsafe fn
--> /home/runner/work/LibAFL/LibAFL/libafl_qemu/src/emu.rs:1533:60
|
1533 | let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
| ^^^
= note: expected enum `std::option::Option<extern "C" fn(_, _, _) -> _>`
found enum `std::option::Option<unsafe extern "C" fn(_, _, _) -> _>`
still there's this error (in qemu_fuzzers CI build)
is this ready?