diff --git a/.github/workflows/test-aot-cli.yml b/.github/workflows/test-aot-cli.yml index 926940d..901e711 100644 --- a/.github/workflows/test-aot-cli.yml +++ b/.github/workflows/test-aot-cli.yml @@ -39,6 +39,10 @@ jobs: run: | cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_UNIT_TESTING=1 -DBUILD_LLVM_AOT_CLI=1 -G Ninja cmake --build build --target all -j + - name: test emit llvm + run: | + ./build/cli/bpftime-vm build -emit-llvm .github/assets/sum.bpf.o + - name: Do compilation & run run: | export PATH=$PATH:~/.bpftime @@ -53,5 +57,6 @@ jobs: echo "Not found!" exit 1 fi + \ No newline at end of file diff --git a/README.md b/README.md index 8c7ac53..939fb0a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,14 @@ This library is optimized for performance, flexibility, and minimal dependencies For a comprehensive userspace eBPF runtime that includes support for maps, helpers, and seamless execution of Uprobe, syscall trace, XDP, and other eBPF programs—similar to kernel functionality but in userspace—please refer to the [bpftime](https://github.com/eunomia-bpf/bpftime) project. -## build +- [Userspace eBPF VM with LLVM JIT/AOT Compiler](#userspace-ebpf-vm-with-llvm-jitaot-compiler) + - [build project](#build-project) + - [Use llvmbpf as a library](#use-llvmbpf-as-a-library) + - [Use llvmbpf as a AOT compiler](#use-llvmbpf-as-a-aot-compiler) + - [Test with bpf-conformance](#test-with-bpf-conformance) + - [License](#license) + +## build project ```sh sudo apt install llvm-15-dev libzstd-dev diff --git a/cli/README.md b/cli/README.md index fa9394f..077e992 100644 --- a/cli/README.md +++ b/cli/README.md @@ -15,6 +15,5 @@ Subcommands: A CLI compiler for AOT of llvm-jit. -It can build ebpf ELF into native elf, or execute compiled native ELF. **Helpers and relocations are not supported** +It can build ebpf ELF into native elf, or execute compiled native ELF. **Helpers and relocations are not supported. For helpers and maps, please use bpftime aot cli in the [bpftime/tools](https://github.com/eunomia-bpf/bpftime)** -This program might be installed by running `make release-with-llvm-jit` in the project root. diff --git a/cli/main.cpp b/cli/main.cpp index 14921be..508a031 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -92,10 +92,14 @@ static int build_ebpf_program(const std::string &ebpf_elf, i, "helper_" + std::to_string(i), nullptr); } auto result = vm.do_aot_compile(emit_llvm); - + if (!result) { + SPDLOG_ERROR("Failed to compile program {}: {}", + name, vm.get_error_message()); + return 1; + } auto out_path = output / (std::string(name) + ".o"); std::ofstream ofs(out_path, std::ios::binary); - ofs.write((const char *)result.data(), result.size()); + ofs.write((const char *)result->data(), result->size()); if (!emit_llvm) SPDLOG_INFO("Program {} written to {}", name, out_path.c_str());