Comments (20)
I need the equivalent of https://doc.rust-lang.org/nightly/cargo/reference/specifying-dependencies.html#platform-specific-dependencies for features but it does not seem to exist yet (rust-lang/cargo#7914 (comment))
from liboqs-rust.
I need the equivalent of ...
To fix the OpenSSL issue on Windows, you can swap
Line 45 in 805ac8e
if cfg!(all(not(windows), feature = "openssl")) {
Is there a reason why static linking is enabled by default? Is it needed for your use case of liboqs-rust
? I am unable to get this crate to compile on Windows, even with the default features disabled (I have no idea how the Windows CI passes currently). I've also asked others to try and they've also encountered difficulties. Note that liboqs
itself compiles and the binaries run fine in Visual Studio. I also tested the liboqs.sln
project that liboqs-sys
generates as part of the build process in Visual Studio and it compiles fine as well.
Every time I compile liboqs-rust
, even with OpenSSL disabled, I'm met with a linker error:
Compiling oqs-sys v0.3.0
Compiling oqs v0.3.0
error: could not find native static library `oqs`, perhaps an -L flag is missing?
error: aborting due to previous error
error: could not compile `oqs-sys`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
The only way the linking bug seems to fix itself is by changing this
Line 56 in 805ac8e
println!("cargo:rustc-link-lib=oqs");
Tl;dr I'm having a hard time seeing how something with the build script is not wrong currently. If the stuff above is acceptable and desired, I'll open a PR off my testing branch.
from liboqs-rust.
if cfg!(all(not(windows), feature = "openssl")) {
I don't want to force-disable openssl
on Windows, because if you do set up everything correctly, it works fine, and gives you access to accelerated versions of a bunch of primitives that make up between 20% to up to 90% of the runtime of some schemes.
I have no idea how the Windows CI passes currently
Presumably it's set up differently.
I'm not sure if println!("cargo:rustc-link-lib=static=oqs");
should indeed be static, I've mainly just copied that from some example somewhere initially and as I only run Linux, it's obviously not been a problem for me. I'd merge a PR that removes static=
assuming it passes CI.
from liboqs-rust.
I don't want to force-disable openssl on Windows
I should add that if you don't want to have openssl in your crate, you can simply specify no-default-features
and use a build.rs
that emits the openssl
feature where it is supported.
from liboqs-rust.
I dont want to force disable OpenSSL on Windows
I don’t think it works at all from my testing. This line in the primary C library explodes MSVC if you try to enable OpenSSL. And as stated originally, liboqs unconditionally disables compiling OpenSSL on Windows. None of its CI jobs even attempt to enable it either.
no-default-features
That would only be a solution if the static linking bug was fixed. But, due to the liboqs’ behavior with OpenSSL and Windows I think its not very important, at least until the C code is patched to support MSVC.
from liboqs-rust.
This line in the primary C library explodes MSVC if you try to enable OpenSSL.
That file should not be compiled though... It's only for tests against NIST's Known-Answer Tests
from liboqs-rust.
Well, it seems to be anyway. These are the errors that MSVC gives when you try to compile main
on Windows with OpenSSL, sorry I didn't share these sooner:
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(36,15): error C2143: syntax error: missing ')' before '(' [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(36,24): error C2059: syntax error: ')' [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(36,25): error C2059: syntax error: ')' [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(37,13): error C2143: syntax error: missing ')' before 'type' [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(37,13): error C2091: function returns function [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(37,32): error C2085: 'handleErrors': not in formal parameter list [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
liboqs-rust\oqs-sys\liboqs\src\common\rand\rand_nist.c(37,32): error C2143: syntax error: missing ';' before '{' [liboqs-rust\target\debug\build\oqs-sys-45a0b0771bd42382\out\build\src\common\common.vcxproj]
I tried changing the function to decorated like this and it looked to of fixed it.
#ifdef OQS_USE_OPENSSL
# ifdef __GNUC__
__attribute__((noreturn))
# elif defined(_MSC_VER)
__declspec(noreturn)
from liboqs-rust.
I'm running into problems if I don't statically link liboqs
:(
from liboqs-rust.
Are you building liboqs
directly? How are you building liboqs
? You should be passing -DOQS_BUILD_ONLY_LIB=Yes
if you want to match what this crate is doing.
from liboqs-rust.
I’m not building it directly. I am attempting to compile it through this Rust crate. Every error I’ve posted has come from the output of oqs-sys
‘ build script using cargo build
.
from liboqs-rust.
That's definitely weird...
from liboqs-rust.
I've figured out why CI was not having problems: CI wasn't running tests on Windows at all 🙈 (#30)
from liboqs-rust.
That would explain a bit. Can't believe I didn't see that sooner D:
from liboqs-rust.
Yeah Github Action's workflow syntax is rather sensitive to these problems where you define matrix vars but don't actually use them
from liboqs-rust.
The branch in #30 works on a Windows 10 Dev VM (from Microsoft) that's up-to-date; unfortunately I am having trouble updating the Github Actions VM to use a more recent Windows SDK.
from liboqs-rust.
I've managed to figure out the problem in #30, so you could try that branch. Don't forget to make sure you update the submodule if you check out that branch.
from liboqs-rust.
I checked out the branch and confirmed it fixes the linking issue. My tests also run after configuring the stack size.
from liboqs-rust.
This is very unrelated, but it would be cool if we could get this liboqs-rust
to work with the openssl-sys
crate. To get this compiling, the build.rs
logic has duplicated some of the searching and link logic of that crate. It also has a vendored feature to get around the headaches of needing OpenSSL present on your system.
Its probably not possible, at least not easily, since liboqs links to it, but it would be a great feature. I tried tinkering with it but the linker on both Linux and Windows isn't happy with the idea.
from liboqs-rust.
The main problem is the openssl-sys
crate build.rs
does not expose the location where it found OpenSSL. Otherwise I could pass it on to liboqs
— I did look into this.
from liboqs-rust.
Ah, that sucks :/ Good to know though.
from liboqs-rust.
Related Issues (20)
- Update NTRU
- ARMv8 compatibility: CI and cross-compiling? HOT 8
- WASM compatibility HOT 4
- Stack overflow when generating a key pair on Windows HOT 2
- Support RustCrypto KEM and Signature traits
- Stack overflow on some tests HOT 6
- How to encrypt message with the symetric key of kem HOT 1
- Clean up clippy lints
- Cmake files are not included in package
- Permit unbundling the library HOT 7
- cargo vendor failure for this crate due to include(.CMake/compiler_opts.cmake) HOT 3
- Version numbering HOT 19
- Compiling fails when encountering new compiler warnings HOT 11
- expose `OQS_PERMIT_UNSUPPORTED_ARCHITECTURE`, for example as cargo feature HOT 3
- Updated liboqs-sys create on crates.io HOT 10
- Don't recompile oqs everytime cargo build is invoked HOT 2
- Please document how to build against the system copy of liboqs
- MacOS build fails (as linking against OpenSSL1 instead of 3) HOT 2
- Cross compilation results in size mismatch of `ssize_t` and pointer size
- Invert no-std logic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liboqs-rust.