← All tasks
cppWasmEdge/WasmEdge #5337Not a task: not reproduced

feat: use the system's libblake3 if available

envgap__WasmEdge__WasmEdge-5337

01 / FAILURE SIGNATURE

As reported upstream

- GCC generates a compilation warning (`error: ‘std::filesystem::__cxx11::path std::filesystem::__cxx11::u8path(const _Source&) [with _Source = std::basic_string_view<char>; _Require = path; _CharT = char]’ is deprecated: use 'path((const char8_t*)&*source)' instead [-Werror=deprecated-declarations]`)
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
fd02289f31956d02a7826e7d75669d604bc9f13d
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

WasmEdge/WasmEdge #5337 · read the original issue
### Summary

libblake3 was recently packaged separately in Debian, and can now be dynamically linked across projects. We've been switching various projects (e.g. crun recently) to use that instead. I would like WasmEdge to build against this system-provided version instead of the vendored copy, for all the usual reasons of system vs. vendored copies.

For the next few years until the system copy of libblake3 becomes more prevalent, it probably makes sense to continue allowing with a vendored copy. Another alternative if you'd like to keep the source tree clean would to be to handle fetching it dynamically like I believe you do right now with spdlog.

### Details

The libblake3 package ships CMake files (and pkg-config), so hooking that up to the build system is quite trivial. I attempted to ship this patch in the Debian package:

```diff
diff --git a/lib/aot/CMakeLists.txt b/lib/aot/CMakeLists.txt
index b6d65cf..6505cb8 100644
--- a/lib/aot/CMakeLists.txt
+++ b/lib/aot/CMakeLists.txt
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-FileCopyrightText: 2019-2024 Second State INC
 
+find_package(blake3 CONFIG REQUIRED)
+
 wasmedge_add_library(wasmedgeAOT
   blake3.cpp
   cache.cpp
@@ -10,7 +12,7 @@ target_link_libraries(wasmedgeAOT
   PUBLIC
   wasmedgeCommon
   wasmedgeSystem
-  utilBlake3
+  BLAKE3::blake3
   std::filesystem
 )
 
@@ -23,5 +25,4 @@ target_include_directories(wasmedgeAOT
 target_include_directories(wasmedgeAOT
   PUBLIC
   ${PROJECT_BINARY_DIR}/include
-  ${PROJECT_SOURCE_DIR}/thirdparty/blake3
 )
```

However, this creates this interesting cascading problem:
- blake3-targets.cmake states `INTERFACE_COMPILE_FEATURES "c_std_99;cxx_std_20"` (not sure why)
- In turn this bumps `lib/aot` from `-std=c++17` to `-std=c++20`.
- lib/aot/cache.cpp uses `std::filesystem::u8path` in two places, which is deprecated in C++20
- GCC generates a compilation warning (`error: ‘std::filesystem::__cxx11::path std::filesystem::__cxx11::u8path(const _Source&) [with _Source = std::basic_string_view<char>; _Require = path; _CharT = char]’ is deprecated: use 'path((const char8_t*)&*source)' instead [-Werror=deprecated-declarations]`)
- lib/aot is compiled with `-Werror`, which includes `-Werror=deprecated-declarations`
- therefore, compilation of lib/aot fails!

We could attempt to manually include libblake3's config, and build it with C++17. Another easy and safer workaround would be to build with `-Wno-error=deprecated-declarations`. But perhaps a better, more forward-looking alternative would be to bump lib/aot to be C++20-compatible?

### Appendix

_No response_
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]