noxf / libwebp-sys Goto Github PK
View Code? Open in Web Editor NEWbindgen'd FFI bindings to libwebp
bindgen'd FFI bindings to libwebp
Hi, and thanks for this great library!
I am trying to decode animations by following this API documentation:
https://developers.google.com/speed/webp/docs/container-api#webpanimdecoder_api
It seems that this requires creation of a WebPAnimDecoder
(https://docs.rs/libwebp-sys/0.9.4/libwebp_sys/struct.WebPAnimDecoder.html). However this struct has private fields, so I can't construct it. Is there a better or different way to decode animations with this library currently?
I took an ugly workaround to use WebPAnimEncoder
...
cargo:warning=#include <assert.h>
cargo:warning= ^~~~~~~~~~
cargo:warning=1 error generated.
exit status: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "/Users/leping/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.4.2/vendor" "-Wall" "-Wextra" "-fvisibility=hidden" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-o" "/Users/leping/Desktop/online-webp-tool/target/wasm32-unknown-unknown/release/build/libwebp-sys-a70f591a50f6f57f/out/alpha_dec.o" "-c" "/Users/leping/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.4.2/vendor/src/dec/alpha_dec.c" with args "clang" did not execute successfully (status code exit status: 1).
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
A double free (CVE-2023-1999) was fixed in libwebp
in Firefox 112 and apparently Chrome, but there is not a lot of public info about this. Ubuntu 23.04 just updated the libwebp
package to fix this issue. The same fix was applied upstream in February.
I would suggest applying this patch in libwebp-sys, too. Surprisingly, there is no 1.3.1 release yet, but the upstream 1.3.0 branch contains the fix and two other fixes (apparently for memleaks). Last update to that branch was in March without a release since then.
(I filed the same issue in libwebp-sys2)
I upload the webp-sys crate to debian today. Some bindgen tests fail on 32-bit arches (arm, x86):
running 19 tests
test ffi::bindgen_test_layout_WebPAnimDecoderOptions ... ok
test ffi::bindgen_test_layout_WebPAnimEncoderOptions ... ok
test ffi::bindgen_test_layout_WebPAnimInfo ... ok
test ffi::bindgen_test_layout_WebPAuxStats ... ok
test ffi::bindgen_test_layout_WebPBitstreamFeatures ... ok
test ffi::bindgen_test_layout_WebPConfig ... ok
test ffi::bindgen_test_layout_WebPDecBuffer ... FAILED
test ffi::bindgen_test_layout_WebPChunkIterator ... FAILED
test ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1 ... FAILED
test ffi::bindgen_test_layout_WebPDecoderOptions ... ok
test ffi::bindgen_test_layout_WebPData ... FAILED
test ffi::bindgen_test_layout_WebPDecoderConfig ... FAILED
test ffi::bindgen_test_layout_WebPIterator ... FAILED
test ffi::bindgen_test_layout_WebPMemoryWriter ... FAILED
test ffi::bindgen_test_layout_WebPMuxAnimParams ... ok
test ffi::bindgen_test_layout_WebPMuxFrameInfo ... FAILED
test ffi::bindgen_test_layout_WebPYUVABuffer ... FAILED
test ffi::bindgen_test_layout_WebPRGBABuffer ... FAILED
test ffi::bindgen_test_layout_WebPPicture ... FAILED
failures:
---- ffi::bindgen_test_layout_WebPDecBuffer stdout ----
thread 'ffi::bindgen_test_layout_WebPDecBuffer' panicked at 'assertion failed: `(left == right)`
left: `84`,
right: `120`: Size of: WebPDecBuffer', src/ffi.rs:1710:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPDecBuffer
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1710:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPDecBuffer::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1707:40
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPChunkIterator stdout ----
thread 'ffi::bindgen_test_layout_WebPChunkIterator' panicked at 'assertion failed: `(left == right)`
left: `44`,
right: `56`: Size of: WebPChunkIterator', src/ffi.rs:2978:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPChunkIterator
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2978:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPChunkIterator::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2975:44
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1 stdout ----
thread 'ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1' panicked at 'assertion failed: `(left == right)`
left: `48`,
right: `80`: Size of: WebPDecBuffer__bindgen_ty_1', src/ffi.rs:1670:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1670:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1666:54
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPData stdout ----
thread 'ffi::bindgen_test_layout_WebPData' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `16`: Size of: WebPData', src/ffi.rs:2291:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPData
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2291:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPData::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2288:35
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPDecoderConfig stdout ----
thread 'ffi::bindgen_test_layout_WebPDecoderConfig' panicked at 'assertion failed: `(left == right)`
left: `200`,
right: `240`: Size of: WebPDecoderConfig', src/ffi.rs:2189:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPDecoderConfig
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2189:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPDecoderConfig::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2186:44
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPIterator stdout ----
thread 'ffi::bindgen_test_layout_WebPIterator' panicked at 'assertion failed: `(left == right)`
left: `64`,
right: `80`: Size of: WebPIterator', src/ffi.rs:2798:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPIterator
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2798:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPIterator::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2795:39
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPMemoryWriter stdout ----
thread 'ffi::bindgen_test_layout_WebPMemoryWriter' panicked at 'assertion failed: `(left == right)`
left: `16`,
right: `32`: Size of: WebPMemoryWriter', src/ffi.rs:714:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPMemoryWriter
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:714:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPMemoryWriter::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:711:43
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPMuxFrameInfo stdout ----
thread 'ffi::bindgen_test_layout_WebPMuxFrameInfo' panicked at 'assertion failed: `(left == right)`
left: `36`,
right: `48`: Size of: WebPMuxFrameInfo', src/ffi.rs:2405:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPMuxFrameInfo
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2405:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPMuxFrameInfo::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:2402:43
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPYUVABuffer stdout ----
thread 'ffi::bindgen_test_layout_WebPYUVABuffer' panicked at 'assertion failed: `(left == right)`
left: `48`,
right: `80`: Size of: WebPYUVABuffer', src/ffi.rs:1517:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPYUVABuffer
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1517:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPYUVABuffer::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1514:41
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPRGBABuffer stdout ----
thread 'ffi::bindgen_test_layout_WebPRGBABuffer' panicked at 'assertion failed: `(left == right)`
left: `12`,
right: `24`: Size of: WebPRGBABuffer', src/ffi.rs:1456:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPRGBABuffer
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1456:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPRGBABuffer::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:1453:41
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
---- ffi::bindgen_test_layout_WebPPicture stdout ----
thread 'ffi::bindgen_test_layout_WebPPicture' panicked at 'assertion failed: `(left == right)`
left: `172`,
right: `256`: Size of: WebPPicture', src/ffi.rs:848:5
stack backtrace:
0: rust_begin_unwind
at /usr/src/rustc-1.67.1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:64:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /usr/src/rustc-1.67.1/library/core/src/panicking.rs:199:5
4: libwebp_sys::ffi::bindgen_test_layout_WebPPicture
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:848:5
5: libwebp_sys::ffi::bindgen_test_layout_WebPPicture::{{closure}}
at /usr/share/cargo/registry/libwebp-sys-0.9.2/src/ffi.rs:845:38
6: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
7: core::ops::function::FnOnce::call_once
at /usr/src/rustc-1.67.1/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
ffi::bindgen_test_layout_WebPChunkIterator
ffi::bindgen_test_layout_WebPData
ffi::bindgen_test_layout_WebPDecBuffer
ffi::bindgen_test_layout_WebPDecBuffer__bindgen_ty_1
ffi::bindgen_test_layout_WebPDecoderConfig
ffi::bindgen_test_layout_WebPIterator
ffi::bindgen_test_layout_WebPMemoryWriter
ffi::bindgen_test_layout_WebPMuxFrameInfo
ffi::bindgen_test_layout_WebPPicture
ffi::bindgen_test_layout_WebPRGBABuffer
ffi::bindgen_test_layout_WebPYUVABuffer
test result: FAILED. 8 passed; 11 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
I believe making a Vec from the data allocated by llibwebp is unsound since that will try to free it with the rust allocator. I think they should be making slices, and then freeing the buffers using libwebp_sys::WebPFree
(Or maybe another of the free functions).
I'm specifically referring to the decoding examples.
Hello,
I tried building this in an Apple Silicon chip and got this error
Compiling tokio-native-tls v0.3.0
The following warnings were emitted during compilation:
warning: clang: error: the clang compiler does not support '-march=native'
warning: clang: error: the clang compiler does not support '-march=native'
error: failed to run custom build command for `libwebp-sys v0.6.0`
Caused by:
process didn't exit successfully: `/Users/christian/Developer/cmnh/imageflow/target/release/build/libwebp-sys-647a8e6d13b44bda/build-script-build` (exit status: 1)
--- stdout
OPT_LEVEL = Some("3")
TARGET = Some("aarch64-apple-darwin")
HOST = Some("aarch64-apple-darwin")
CC_aarch64-apple-darwin = None
CC_aarch64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_aarch64-apple-darwin = None
CFLAGS_aarch64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = Some(" -march=native -O3")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
CC_aarch64-apple-darwin = None
CC_aarch64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_aarch64-apple-darwin = None
CFLAGS_aarch64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = Some(" -march=native -O3")
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-march=native" "-O3" "-I" "/Users/christian/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.6.0/vendor" "-fvisibility=hidden" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-DWEBP_HAVE_NEON=1" "-o" "/Users/christian/Developer/cmnh/imageflow/target/release/build/libwebp-sys-0c4a95c8caa884c9/out/alpha_dec.o" "-c" "/Users/christian/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.6.0/vendor/src/dec/alpha_dec.c"
cargo:warning=clang: error: the clang compiler does not support '-march=native'
exit status: 1
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-march=native" "-O3" "-I" "/Users/christian/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.6.0/vendor" "-fvisibility=hidden" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-DWEBP_HAVE_NEON=1" "-o" "/Users/christian/Developer/cmnh/imageflow/target/release/build/libwebp-sys-0c4a95c8caa884c9/out/buffer_dec.o" "-c" "/Users/christian/.cargo/registry/src/github.com-1ecc6299db9ec823/libwebp-sys-0.6.0/vendor/src/dec/buffer_dec.c"
cargo:warning=clang: error: the clang compiler does not support '-march=native'
exit status: 1
--- stderr
Any workaround or indication about how to build/run this on this arch. Thanks
Allow looking for libwebp via pkg-config
and then using the system version if available
To reproduce, add to Cargo.toml
[profile.test]
opt-level = 3
Then run cross test --target aarch64-unknown-linux-gnu -v
To get cross running quickly on CI, you could use these commands. Github arm-linux runners won't be free for a while, but cross is fast
To install binstall
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
or
Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content
To install cross
cargo binstall cross
This also affects
cross test --target aarch64-unknown-linux-gnu -v
+ cargo metadata --format-version 1 --filter-platform aarch64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ "C:\Program Files\Docker\Docker\resources\bin\docker.EXE"
+ "C:\Program Files\Docker\Docker\resources\bin\docker.EXE" run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e 'USER=lilith' --rm --user 1000:1000 -v 'C:\Users\lilith\.xargo:/xargo:z' -v 'C:\Users\lilith\.cargo:/cargo:z' -v /cargo/bin -v 'C:\Users\lilith\Documents\GitHub\libwebp-sys:/project:z' -v 'C:\Users\lilith\.rustup\toolchains\stable-x86_64-unknown-linux-gnu:/rust:z,ro' -v 'C:\Users\lilith\Documents\GitHub\libwebp-sys\target:/target:z' -w /project -i -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 sh -c 'PATH=$PATH:/rust/bin cargo test --target aarch64-unknown-linux-gnu -v'
Fresh shlex v1.3.0
Fresh glob v0.3.1
Fresh libc v0.2.158
Fresh jobserver v0.1.32
Fresh cc v1.1.13
Compiling libwebp-sys v0.9.5 (/project)
Running `/target/debug/build/libwebp-sys-3d77577e83ed02a9/build-script-build`
The following warnings were emitted during compilation:
warning: [email protected]: /tmp/cc4nVy2X.s: Assembler messages:
warning: [email protected]: /tmp/cc4nVy2X.s: Error: unaligned opcodes detected in executable segment
warning: [email protected]: ToolExecError: Command "aarch64-linux-gnu-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-I" "/project/vendor" "-Wall" "-Wextra" "-fvisibility=hidden" "-Wall" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-DWEBP_HAVE_NEON=1" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out/4f39fca00dbd5c57-quant_enc.o" "-c" "/project/vendor/src/enc/quant_enc.c" with args aarch64-linux-gnu-gcc did not execute successfully (status code exit status: 1).
error: failed to run custom build command for `libwebp-sys v0.9.5 (/project)`
Caused by:
process didn't exit successfully: `/target/debug/build/libwebp-sys-3d77577e83ed02a9/build-script-build` (exit status: 1)
--- stdout
OPT_LEVEL = Some(3)
TARGET = Some(aarch64-unknown-linux-gnu)
OUT_DIR = Some(/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CC_aarch64-unknown-linux-gnu
CC_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_aarch64_unknown_linux_gnu
CC_aarch64_unknown_linux_gnu = Some(aarch64-linux-gnu-gcc)
cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
CC_KNOWN_WRAPPER_CUSTOM = None
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(true)
CARGO_CFG_TARGET_FEATURE = Some(neon)
cargo:rerun-if-env-changed=CFLAGS_aarch64-unknown-linux-gnu
CFLAGS_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CFLAGS_aarch64_unknown_linux_gnu
CFLAGS_aarch64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
OPT_LEVEL = Some(3)
TARGET = Some(aarch64-unknown-linux-gnu)
OUT_DIR = Some(/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CC_aarch64-unknown-linux-gnu
CC_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CC_aarch64_unknown_linux_gnu
CC_aarch64_unknown_linux_gnu = Some(aarch64-linux-gnu-gcc)
cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
CC_KNOWN_WRAPPER_CUSTOM = None
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(true)
CARGO_CFG_TARGET_FEATURE = Some(neon)
cargo:rerun-if-env-changed=CFLAGS_aarch64-unknown-linux-gnu
CFLAGS_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CFLAGS_aarch64_unknown_linux_gnu
CFLAGS_aarch64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
cargo:rerun-if-env-changed=AR_aarch64-unknown-linux-gnu
AR_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=AR_aarch64_unknown_linux_gnu
AR_aarch64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_AR
TARGET_AR = None
cargo:rerun-if-env-changed=AR
AR = None
cargo:rerun-if-env-changed=CROSS_COMPILE
CROSS_COMPILE = None
RUSTC_LINKER = Some(aarch64-linux-gnu-gcc)
cargo:rerun-if-env-changed=ARFLAGS_aarch64-unknown-linux-gnu
ARFLAGS_aarch64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=ARFLAGS_aarch64_unknown_linux_gnu
ARFLAGS_aarch64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=TARGET_ARFLAGS
TARGET_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
cargo:rustc-link-lib=static=sharpyuv
cargo:rustc-link-search=native=/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
exit status: 0
cargo:warning=/tmp/cc4nVy2X.s: Assembler messages:
cargo:warning=/tmp/cc4nVy2X.s: Error: unaligned opcodes detected in executable segment
exit status: 0
exit status: 0
exit status: 0
exit status: 1
cargo:warning=ToolExecError: Command "aarch64-linux-gnu-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-I" "/project/vendor" "-Wall" "-Wextra" "-fvisibility=hidden" "-Wall" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-DWEBP_HAVE_NEON=1" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out/4f39fca00dbd5c57-quant_enc.o" "-c" "/project/vendor/src/enc/quant_enc.c" with args aarch64-linux-gnu-gcc did not execute successfully (status code exit status: 1).
--- stderr
error occurred: Command "aarch64-linux-gnu-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-I" "/project/vendor" "-Wall" "-Wextra" "-fvisibility=hidden" "-Wall" "-DNDEBUG=1" "-D_THREAD_SAFE=1" "-DWEBP_HAVE_NEON=1" "-o" "/target/aarch64-unknown-linux-gnu/debug/build/libwebp-sys-45399092962d16c8/out/4f39fca00dbd5c57-quant_enc.o" "-c" "/project/vendor/src/enc/quant_enc.c" with args aarch64-linux-gnu-gcc did not execute successfully (status code exit status: 1).
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
Valgrind shows the following:
==215198== 90,096 bytes in 3 blocks are definitely lost in loss record 11 of 11
==215198== at 0x4841848: malloc (vg_replace_malloc.c:431)
==215198== by 0x525C15: WebPMemoryWrite (in /home/kavin/Workspace/piped-proxy/target/release/piped-proxy)
==215198== by 0x53FC5E: VP8EncWrite (in /home/kavin/Workspace/piped-proxy/target/release/piped-proxy)
==215198== by 0x526F64: WebPEncode (in /home/kavin/Workspace/piped-proxy/target/release/piped-proxy)
==215198== by 0x526357: Encode (in /home/kavin/Workspace/piped-proxy/target/release/piped-proxy)
==215198== by 0x5263A4: WebPEncodeRGB (in /home/kavin/Workspace/piped-proxy/target/release/piped-proxy)
Code:
let image = image::load_from_memory(&resp_bytes).unwrap();
let width = image.width();
let height = image.height();
let quality = 85;
let data = image.as_rgb8().unwrap().as_raw();
let bytes: Vec<u8> = unsafe {
let mut out_buf = std::ptr::null_mut();
let stride = width as i32 * 3;
let len: usize = WebPEncodeRGB(data.as_ptr(), width as i32, height as i32, stride, quality as f32, &mut out_buf);
std::slice::from_raw_parts(out_buf, len).into()
};
image-rs is depending on this crate, when i try to compile image-rs into wasm, this crate seems compile failed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.