Wasmer: Compile error due to AVX-512 error on Blake 3 dependency

Created on 11 Apr 2020  路  7Comments  路  Source: wasmerio/wasmer

Describe the bug

Clean clone of Wasmer fails to compile on MacOS due to AVX-512 error when compiling assembly code from Blake 3.

The actual compilation command that fails (full compilation log below):

"cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c11" "-o" "wasmer/target/debug/build/blake3-da163d92031ce8e8/out/c/blake3_avx512_x86-64_unix.o" "-c" "c/blake3_avx512_x86-64_unix.S"

cargo:warning=c/blake3_avx512_x86-64_unix.S:2315:9: error: instruction requires: AVX-512 ISA AVX-512 VL ISA
cargo:warning=        vpxord xmm3, xmm3, xmm0

It seems to be that it's probably related to this cargo:rustc-cfg=blake3_avx512_ffi.

Compilation works if -march=skylake-avx512 is added to command above, the error happens because Clang by default does not enable AVX-512 intrinsics since they are not supported by my CPU.

Should this issue be reported to Blake3 folk instead/aswell?

Steps to reproduce

git clone wasmer-repo
cargo build

Actual behavior

Additional context

Full compilation log:

error: failed to run custom build command for `blake3 v0.3.1`

Caused by:
  process didn't exit successfully: `wasmer/target/debug/build/blake3-32d62a0f85ffa978/build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
cargo:rerun-if-env-changed=CARGO_FEATURE_PREFER_INTRINSICS
TARGET = Some("x86_64-apple-darwin")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
cargo:rerun-if-env-changed=CARGO_FEATURE_PREFER_INTRINSICS
cargo:rustc-cfg=blake3_sse41_ffi
cargo:rustc-cfg=blake3_avx2_ffi
cargo:rustc-cfg=blake3_avx512_ffi
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c11" "-o" "wasmer/target/debug/build/blake3-da163d92031ce8e8/out/c/blake3_sse41_x86-64_unix.o" "-c" "c/blake3_sse41_x86-64_unix.S"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c11" "-o" "wasmer/target/debug/build/blake3-da163d92031ce8e8/out/c/blake3_avx2_x86-64_unix.o" "-c" "c/blake3_avx2_x86-64_unix.S"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-std=c11" "-o" "wasmer/target/debug/build/blake3-da163d92031ce8e8/out/c/blake3_avx512_x86-64_unix.o" "-c" "c/blake3_avx512_x86-64_unix.S"
cargo:warning=c/blake3_avx512_x86-64_unix.S:28:9: error: instruction requires: AVX-512 ISA
cargo:warning=        kmovw k1, r9d
cargo:warning=        ^
cargo:warning=c/blake3_avx512_x86-64_unix.S:38:9: error: instruction requires: AVX-512 ISA AVX-512 VL ISA
cargo:warning=        vpcmpltud k2, ymm2, ymm0
cargo:warning=        ^
rustc 1.42.0 (b8cedc004 2020-03-09) | x86_64

Output of sysctl -a | grep machdep.cpu.features:

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

To note, no support for AVX-512.

馃悶 bug

Most helpful comment

This build break should be fixed in version 0.3.2, which we just published.

All 7 comments

After a little bit further investigation, this seems to be handled by:

fn c_compiler_exists_and_supports_avx512() in https://github.com/BLAKE3-team/BLAKE3/blob/master/build.rs#L77

However it fails in some cases as reported above.

Going to open a bug report upstream.

And as workaround: CARGO_FEATURE_PREFER_INTRINSICS=1 cargo build

Apologies for the breakage, I'm looking into why that function is getting the wrong answer.

This build break should be fixed in version 0.3.2, which we just published.

Thanks for the fast fixes!

I am trying to build wasmer for x86_64 and aarch64 and it seems to require a nightly version of rust.

Building with cargo +nightly update && cargo +nightly build on cargo 1.44.0-nightly (7019b3ed3 2020-03-17)
seems to still produce the following even though non nightly succeeds now:

error[E0658]: use of unstable library feature 'stdsimd'
   --> /home/rimi/.cargo/registry/src/github.com-1ecc6299db9ec823/blake3-0.3.2/src/platform.rs:303:12
    |
303 |         if is_x86_feature_detected!("avx512f") && is_x86_feature_detected!("avx512vl") {
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
    = help: add `#![feature(stdsimd)]` to the crate attributes to enable
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `blake3`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Should I use some other specific nightly version? Or make another separate ticket?

@Rochet2 you're seeing this issue. It was fixed on March 21, so if you update your nightly toolchain with rustup update, this issue should go away.

Thanks a lot will try. Edit: Seems to have worked 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aergonaut picture aergonaut  路  3Comments

fd picture fd  路  3Comments

danchitnis picture danchitnis  路  4Comments

MaxGraey picture MaxGraey  路  3Comments

ensch picture ensch  路  5Comments