1

When I cargo run, I get met with

error: failed to run custom build command for `ring v0.16.20`

  --- stderr
  running "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-g3" "-DNDEBUG" "-c" "-oC:\\Users\\Derpboimoon\\documents\\rust\\phosphorus\\target\\debug\\build\\ring-d6190243a10e7549\\out\\aes_nohw.o" "crypto/fipsmodule/aes/aes_nohw.c"
  crypto/fipsmodule/aes/aes_nohw.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
   /* Copyright (c) 2019, Google Inc.

  thread 'main' panicked at 'execution failed', C:\Users\Pat\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\build.rs:656:9

Here is my Cargo.toml file:

[package]
name = "phosphorus"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.7.0", default-features = false, features = ["macros", "sync", "rt-multi-thread"] }
twilight-http = "0.3"

I am using rustup default stable-x86_64-pc-windows-gnu if that helps.

I read around stack overflow and it seems that I need to set the gcc target to x86_64. How do I do that? I suspect the error is from tokio, but not sure.

Any help would be appreciated!

HippoBaguette
  • 308
  • 4
  • 15
  • 1
    From [Building *ring*: Supported Toolchains](https://github.com/briansmith/ring/blob/main/BUILDING.md#supported-toolchains): "On Windows, *ring* supports the x86_64-pc-windows-msvc and i686-pc-windows-msvc targets best. [...] Patches to get it working on other variants, including in particular [...] the -gnu targets ([#330](https://github.com/briansmith/ring/issues/330)) are welcome." – eggyal Jun 27 '21 at 10:11
  • 2
    The dependency on *ring* comes from `twilight-http`, via `hyper-rustls` (which is an optional, but default, dependency): see the ["TLS" section in its README](https://github.com/twilight-rs/twilight/tree/main/http#tls). – eggyal Jun 27 '21 at 10:23

2 Answers2

3

I took this approach to solve the "failed to run custom build command for ring" issue using rust-musl-builder:

  1. Add the target to rust toolchain:
rustup target add x86_64-unknown-linux-musl
  1. Define alias to run a docker container
alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder'
  1. Build your project using the container
rust-musl-builder cargo build --release

Here is a list of supported targets: https://doc.rust-lang.org/rustc/platform-support.html

Julian Espinel
  • 2,586
  • 5
  • 26
  • 20
1

This might hels someone else on Windows:

  1. Install Visual Studio; make sure you select; .NET desktop development, Desktop development with C++, and Universal Windows Platform development.
  2. Show the installed toolchain rustup show.
  3. Then change and set the toolchain by running rustup default stable-x86_64-pc-windows-msvc.

This worked for me after weeks of not getting a working solution.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83