rustpq / pqcrypto

Rust Post-Quantum cryptography
212 stars 38 forks source link

Files not found when building on Windows #34

Closed l3utterfly closed 2 years ago

l3utterfly commented 2 years ago

I'm getting errors building on Windows with: rustc 1.62.0-nightly (8f36334ca 2022-04-06) VS2022

I'm getting the errors:

cfiles\sp800-185.c(4): fatal error C1083: Cannot open include file: 'sp800-185.h': No such file or directory cfiles\aes.c(32): fatal error C1083: Cannot open include file: 'aes.h': No such file or directory cfiles\sha2.c(10): fatal error C1083: Cannot open include file: 'sha2.h': No such file or directory cfiles\nistseedexpander.c(9): fatal error C1083: Cannot open include file: 'nistseedexpander.h': No such file or directory

Any help?

l3utterfly commented 2 years ago

Full output if needed:

Updating git repository https://github.com/rustpq/pqcrypto Updating git submodule https://github.com/pqclean/PQClean.git Updating git submodule https://github.com/eliben/pycparser.git Compiling pqcrypto-traits v0.3.4 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-internals v0.2.3 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-falcon v0.2.10 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-classicmceliece v0.1.6 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-frodo v0.4.10 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-kyber v0.7.4 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-hqc v0.1.4 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-rainbow v0.2.4 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-ntruprime v0.1.5 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-sphincsplus v0.6.3 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-ntru v0.5.7 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-saber v0.1.10 (https://github.com/rustpq/pqcrypto#dedb29e9) Compiling pqcrypto-dilithium v0.4.4 (https://github.com/rustpq/pqcrypto#dedb29e9) error: failed to run custom build command for pqcrypto-internals v0.2.3 (https://github.com/rustpq/pqcrypto#dedb29e9)

Caused by: process didn't exit successfully: C:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-11b1745acdab2985\build-script-build (exit code: 1) --- stdout cargo:includepath=\?\C:\Users\gcpth.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include TARGET = Some("x86_64-pc-windows-msvc") OPT_LEVEL = Some("0") HOST = Some("x86_64-pc-windows-msvc") CC_x86_64-pc-windows-msvc = None CC_x86_64_pc_windows_msvc = None HOST_CC = None CC = None CFLAGS_x86_64-pc-windows-msvc = None CFLAGS_x86_64_pc_windows_msvc = None HOST_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None CARGO_CFG_TARGET_FEATURE = Some("fxsr,llvm14-builtins-abi,sse,sse2") DEBUG = Some("true") running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\nistseedexpander.o" "-c" "cfiles\nistseedexpander.c" running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\aes.o" "-c" "cfiles\aes.c" running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\sha2.o" "-c" "cfiles\sha2.c" running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\sp800-185.o" "-c" "cfiles\sp800-185.c" running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\fips202.o" "-c" "cfiles\fips202.c" nistseedexpander.c aes.c sha2.c sp800-185.c fips202.c cfiles\nistseedexpander.c(9): fatal error C1083: Cannot open include file: 'nistseedexpander.h': No such file or directory cfiles\aes.c(32): fatal error C1083: Cannot open include file: 'aes.h': No such file or directory exit code: 2 cfiles\sha2.c(10): fatal error C1083: Cannot open include file: 'sha2.h': No such file or directory exit code: 2 cfiles\sp800-185.c(4): fatal error C1083: Cannot open include file: 'sp800-185.h': No such file or directoryc files\fips202.c(13): fatal error C1083: Cannot open include file: 'fips202.h': No such file or directory exit code: 2 exit code: 2 exit code: 2

--- stderr

error occurred: Command "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" "-W4" "-FoC:\src\butterfly-consensus\sphincs-test\target\debug\build\pqcrypto-internals-49d4009b3b02f44e\out\cfiles\fips202.o" "-c" "cfiles\fips202.c" with args "cl.exe" did not execute successfully (status code exit code: 2).

warning: build failed, waiting for other jobs to finish...

l3utterfly commented 2 years ago

Figured out a workaround:

It seems the build process cannot find the ".h" files in the "include" folder. Manually moving them to the "cfiles" folder in the project "pqcrypto-internals" worked for the build process.

I'm not familiar with the rust build process enough to figure out the cause of this issue though. So any help would be appreciated here.

thomwiggers commented 2 years ago

-I" "\\?\C:\Users\gcpth\.cargo\git\checkouts\pqcrypto-e9887127992f2d13\dedb29e\pqcrypto-internals\include" should set the include path. I'm not sure why that's prefixed with \\?.

The includepath is set here. I don't run Windows, it's not easy for me to test this. I'm also at a workshop today.

l3utterfly commented 2 years ago

Thanks for the pointer, I'll look into this a bit more since I'm on Windows

l3utterfly commented 2 years ago

I've managed to fix the issue by using an external "dunce" crate. The include path creation changes simply to: dunce::canonicalize(Path::new("include")).unwrap()

https://stackoverflow.com/questions/50322817/how-do-i-remove-the-prefix-from-a-canonical-windows-path

On non-Windows systems, this should not affect anything as it compiles back to Path::canonicalize.

Let me know if you think this is acceptable. I can create a PR if you want

l3utterfly commented 2 years ago

Thanks for merging the PR. Do you mind bumping up the version on crates.io with this change? I can then use it without including the source code in my project.

Appreciate it!

thomwiggers commented 2 years ago

Yep that's #36.

Closed by #36

thomwiggers commented 2 years ago

(Commenting on stuff from my phone is easy, running the update script will require a boring talk at RWC)