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

Rust crate does not work with MSVC #169

Closed
Rigidity opened this issue Jun 12, 2023 · 4 comments
Closed

Rust crate does not work with MSVC #169

Rigidity opened this issue Jun 12, 2023 · 4 comments

Comments

@Rigidity
Copy link

Rigidity commented Jun 12, 2023

The Rust crate blst does not compile when using MSVC as the compiler.

image

I'm not a C developer, but I did a little digging to figure out the root cause, and it appears that __STDC_VERSION__ was not defined. Following suggestions in the similar issue #103, I tried adding CFLAGS=/std:c11, but I got the same error.

I tried preprocessing a C file with these variables using C11 and it output the other condition that can cause the no_asm file to error, which is __STDC_NO_VLA__ being set to 1.

Apparently MSVC does not support Variable Length Arrays, which appears to be an optional extension. I did some research and it seems that they are generally not recommended for a variety of reasons, e.g. security, performance, and portability.

I'm using Windows 11 with Visual Studio 2022.

@dot-asm
Copy link
Collaborator

dot-asm commented Jun 12, 2023

The Rust crate blst does not compile when using MSVC as the compiler.

This is a bit misleading, as the problem is not as general. It doesn't work specifically with 32-bit MSVC as the compiler.

If you have to build for 32-bit Windows (why?), add clang in the Visual Studio installer and execute cargo at x86 Tools Command Prompt. For reference, the prompt gives you 32-bit clang-cl on your %PATH%. This, 32-bit clang-cl on %PATH%, can be achieved by any other means.

@Rigidity
Copy link
Author

I'm just trying to cargo run some code using BLS locally, not build an executable for 32 bit Windows. I'm on a 64 bit machine (Ryzen 5600X).

I'm using PowerShell inside of VSCode, which is a pretty typical development environment. Not sure why the shell I'm using plays any role in whether or not blst will compile?

@dot-asm
Copy link
Collaborator

dot-asm commented Jun 12, 2023

I'm just trying to cargo run

Then your Rust installation is configured with i686-pc-windows-msvc as default target, instead of apparently expected x86_64-pc-windows-msvc. I naturally don't know how you installed and configured Rust on your computer, but you have the keyword now. Either ensure that x86_64 is the default, or pass --target=x86_64-pc-windows-msvc on cargo command line :-)

@Rigidity
Copy link
Author

Weird, I'm on a 64-bit version of the OS on 64-bit hardware, so I'm really not sure why it decided to default to i686. Setting the target did indeed work.

Thanks for the help.

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

2 participants