Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b3sum fails to compile on CentOS 7 (unrecognized command line option) #6

Closed
cesarb opened this issue Jan 10, 2020 · 7 comments
Closed

Comments

@cesarb
Copy link
Contributor

cesarb commented Jan 10, 2020

When trying to compile with cargo install b3sum on CentOS 7, it fails with the following error message:

cargo:warning=cc: error: unrecognized command line option ‘-mavx512f’
cargo:warning=cc: error: unrecognized command line option ‘-mavx512vl’
exit code: 1

Full output:

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

Caused by:
  process didn't exit successfully: `/tmp/cargo-installxeuQpU/release/build/blake3-46d96c605b25f4dd/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "-std=c11" "-mavx512f" "-mavx512vl" "-o" "/tmp/cargo-installxeuQpU/release/build/blake3-5036c51346845a8c/out/c/blake3_avx512.o" "-c" "c/blake3_avx512.c"
cargo:warning=cc: error: unrecognized command line option ‘-mavx512f’
cargo:warning=cc: error: unrecognized command line option ‘-mavx512vl’
exit code: 1

--- stderr


error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-Wall" "-Wextra" "-std=c11" "-mavx512f" "-mavx512vl" "-o" "/tmp/cargo-installxeuQpU/release/build/blake3-5036c51346845a8c/out/c/blake3_avx512.o" "-c" "c/blake3_avx512.c" with args "cc" did not execute successfully (status code exit code: 1).



warning: build failed, waiting for other jobs to finish...
error: failed to compile `b3sum v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-installxeuQpU`

Caused by:
  build failed

The gcc version is:

$ cc --version
cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling with cargo install --no-default-features --features rayon b3sum works.

@veorq
Copy link
Member

veorq commented Jan 10, 2020

Your version of gcc looks from 2015, tried upgrading?

@cesarb
Copy link
Contributor Author

cesarb commented Jan 10, 2020

It's a fully up-to-date install of CentOS 7 (which is nearly identical to RHEL 7). Like it or not, each major RHEL release is supported for a long time (over 10 years) while keeping the same version of almost all components (with a couple of exceptions for fast-moving things like web browsers), which is why large companies love using it. At work, we have some clients still using RHEL 6 (or CentOS 6), which has the even older GCC 4.4.

@oconnor663
Copy link
Member

I didn't enable AVX-512 by default for the blake3 crate, because it's hopefully going to be widely used in all sorts of programs, and this sort of build failure is really confusing and hard to figure out when it happens deep in your dependency tree. But I decided to keep it on for b3sum, because that helps a lot with discoverability, and --no-default-features seems like an acceptable workaround at the top level. Is --no-default-features acceptable for your use case?

One thing we could definitely improve here is the error message that you get. I think build.rs can explicitly check whether the compiler supports these flags, and if the feature is enabled but not supported, it can print an explicit message that clarifies what's going on. Maybe b3sum can add a build.rs of its own, solely for the purpose of printing clear instructions about --no-default-features in this case. What do you think?

@cesarb
Copy link
Contributor Author

cesarb commented Jan 10, 2020

Maybe b3sum can add a build.rs of its own, solely for the purpose of printing clear instructions about --no-default-features in this case. What do you think?

Yes, I think that would be an acceptable workaround. The ideal solution would be to autodetect when these gcc flags are not available and automatically disable the avx512 feature, but I don't think build.rs can disable cargo features (and in case the feature was explicitly requested, it's in poor form to silently disable it).

oconnor663 added a commit that referenced this issue Jan 13, 2020
If AVX-512 is enabled, and the local C compiler doesn't support it, the
build is going to fail. However, if we check for this explicitly, we can
give a better error message.

Fixes #6.
@oconnor663
Copy link
Member

Just released v0.1.1. Could you confirm that this gives a better error message on CentOS 7, and that the --no-default-features workaround still works?

@cesarb
Copy link
Contributor Author

cesarb commented Jan 13, 2020

Just released v0.1.1. Could you confirm that this gives a better error message on CentOS 7, and that the --no-default-features workaround still works?

Yes, both work correctly. Compiling with cargo install -f --no-default-features --features rayon b3sum works, and compiling with cargo install -f b3sum outputs:

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

Caused by:
  process didn't exit successfully: `/tmp/cargo-installOX69d7/release/build/blake3-fa2b61db160ab4b5/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
CC_x86_64-unknown-linux-gnu = None
CC_x86_64_unknown_linux_gnu = None
HOST_CC = None
CC = None
CFLAGS_x86_64-unknown-linux-gnu = None
CFLAGS_x86_64_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")

--- stderr
The "c_avx512" feature is enabled, but your C compiler does not support the
"-mavx512f" flag. If you are building the "b3sum" or "bao_bin" crates, you can
disable AVX-512 with Cargo's "--no-default-features" flag. (Note that this also
disables other default features like Rayon-based multithreading, which you can
re-enable with "--features=rayon".) Other crates might or might not support
this workaround.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `b3sum v0.1.1`, intermediate artifacts can be found at `/tmp/cargo-installOX69d7`

Caused by:
  build failed

@oconnor663
Copy link
Member

Awesome, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants