Fix build cfg for BLAKE3

This commit is contained in:
BoloniniD 2022-08-05 21:27:26 +03:00
parent 48c91619b0
commit ef4ca4279a
10 changed files with 43 additions and 31 deletions

View File

@ -2,15 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "BLAKE3-cmake"
version = "0.1.0"
dependencies = [
"blake3",
"cbindgen",
"cc",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
@ -55,6 +46,15 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "blake3"
version = "0.1.0"
dependencies = [
"blake3 1.3.1",
"cbindgen",
"cc",
]
[[package]]
name = "blake3"
version = "1.3.1"

View File

@ -2,6 +2,7 @@
name = "blake3"
version = "0.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,6 +2,8 @@ extern crate cbindgen;
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=./src/lib.rs");
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let package_name = env::var("CARGO_PKG_NAME").unwrap();

View File

@ -68,6 +68,7 @@ function(build_cargo target_name project_dir)
COMMAND export BUILD_FOR_OSX=${OSX_RUST_ROOT}
COMMAND env CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} cargo build ${CARGO_RELEASE_FLAG} ${TARGET_SPEC}
COMMAND cp ${output_library} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND cat ./include/blake3.h
OUTPUT ${output_library}
WORKING_DIRECTORY ${project_dir})

View File

@ -54,8 +54,26 @@ usize_is_size_t = true
# "feature = serde" = "DEFINE_SERDE"
[export]
include = []
exclude = []
include = ["blake3_apply_shim",
"blake3_apply_shim_msan_compat",
"blake3_free_char_pointer",
]
exclude = ["blake3_compress_in_place_avx512",
"blake3_compress_in_place_portable",
"blake3_compress_in_place_sse2",
"blake3_compress_in_place_sse41",
"blake3_compress_xof_avx512",
"blake3_compress_xof_sse2",
"blake3_compress_xof_sse41",
"blake3_hash_many_avx2",
"blake3_hash_many_avx512",
"blake3_hash_many_neon",
"blake3_hash_many_sse2",
"blake3_hash_many_sse41",
"BLOCK_LEN",
"CHUNK_LEN",
"DEGREE",
]
# prefix = "CAPI_"
item_types = []
renaming_overrides_prefixing = false

View File

@ -1,16 +0,0 @@
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
extern "C" {
char *blake3_apply_shim(const char *begin, uint32_t _size, uint8_t *out_char_data);
char *blake3_apply_shim_msan_compat(const char *begin, uint32_t size, uint8_t *out_char_data);
} // extern "C"

View File

@ -42,4 +42,10 @@ pub unsafe extern "C" fn blake3_apply_shim_msan_compat(
let mut reader = hasher.finalize_xof();
reader.fill(std::slice::from_raw_parts_mut(out_char_data, OUT_LEN));
std::ptr::null_mut()
}
}
// Freeing memory according to docs: https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_raw
#[no_mangle]
pub unsafe extern "C" fn blake3_free_char_pointer(ptr_to_free: *mut c_char) {
std::mem::drop(CString::from_raw(ptr_to_free));
}

2
contrib/boringssl vendored

@ -1 +1 @@
Subproject commit 8061ac62d67953e61b793042e33baf1352e67510
Subproject commit c1e01a441d6db234f4f12e63a7657d1f9e6db9c1

2
contrib/krb5 vendored

@ -1 +1 @@
Subproject commit d879821c7a4c70b0c3ad739d9951d1a2b1903df7
Subproject commit 5149dea4e2be0f67707383d2682b897c14631374

View File

@ -597,7 +597,7 @@ struct ImplXxHash64
struct ImplBLAKE3
{
static constexpr auto name = "BLAKE3";
enum { length = OUT_LEN };
enum { length = 32 };
static void apply(const char * begin, const size_t size, unsigned char* out_char_data)
{