briansmith / ring

Safe, fast, small crypto using Rust
Other
3.74k stars 704 forks source link

Doesn't compile for x86_64_pc_windows_gnu #1869

Closed twothirdshuman closed 10 months ago

twothirdshuman commented 10 months ago

I get this error in an empty project with the only dependency being ring. gcc.exe is at C:\MinGW\bin which is in $env:PATH


PS C:\code\ring-test> cargo build          
   Compiling ring v0.17.7
The following warnings were emitted during compilation:

warning: crypto/curve25519/curve25519.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
warning:  /* Copyright (c) 2020, Google Inc.
warning:

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

Caused by:
  process didn't exit successfully: `C:\code\ring-test\target\debug\build\ring-81fc3c87f644d3c3\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-pc-windows-gnu")
  HOST = Some("x86_64-pc-windows-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-gnu
  CC_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_gnu
  CC_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-gnu
  CFLAGS_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_gnu
  CFLAGS_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-I" "include" "-I" "C:\\code\\ring-test\\target\\debug\\build\\ring-6ee7a381e36e4bc0\\out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-DNDEBUG" "-o" "C:\\code\\ring-test\\target\\debug\\build\\ring-6ee7a381e36e4bc0\\out\\crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
  cargo:warning=crypto/curve25519/curve25519.c:1:0: sorry, unimplemented: 64-bit mode not compiled in

  cargo:warning= /* Copyright (c) 2020, Google Inc.

  cargo:warning=

  exit code: 1

  --- stderr

Wuninitialized" "-Wwrite-strings" "-g3" "-DNDEBUG" "-o" "C:\\code\\ring-test\\target\\debug\\build\\ring-6ee7a381e36e4bc0\\out\\crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "gcc.exe" did not execute successfully (status code exit code: 1).```
twothirdshuman commented 10 months ago

Something I noted when I tried debugging this issue myself was that curve25519.c doesn't seem to exist anywhere in the project file structure. The error produced by gcc is probably a missing file error.

briansmith commented 10 months ago

To find the cause of your problem, I did the following:

So, I believe if you reinstall MinGW and select the 64-bit option, you will get things working.

(curve25519.c is in crypto/curve25519/.)