Work on windows client build.
This commit is contained in:
@@ -0,0 +1,142 @@
|
|||||||
|
# Building nyash_client
|
||||||
|
|
||||||
|
Cross-compilation guide for **Ubuntu 24.04 LTS** — produces native Linux binary and Windows `.exe` from a single build server.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Ubuntu 24.04 LTS (Noble Numbat)
|
||||||
|
- Internet access on the build server
|
||||||
|
- No GPU required — OpenCL CPU runtime is provided by the user at runtime
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 1 — System packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt update && sudo apt install -y \
|
||||||
|
curl wget git unzip build-essential pkg-config \
|
||||||
|
gcc-mingw-w64-x86-64 mingw-w64 mingw-w64-tools \
|
||||||
|
ocl-icd-opencl-dev opencl-headers pocl-opencl-icd \
|
||||||
|
protobuf-compiler
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 2 — Rust
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
# Select: 1 (default)
|
||||||
|
|
||||||
|
source $HOME/.cargo/env
|
||||||
|
|
||||||
|
rustup target add x86_64-pc-windows-gnu
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustc --version
|
||||||
|
protoc --version
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 3 — OpenCL Windows stub
|
||||||
|
|
||||||
|
The build server does not need a GPU or OpenCL runtime. Only a linker stub (`libOpenCL.a`) is required at compile time. The actual OpenCL runtime is provided by the user's OS/drivers at runtime.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~
|
||||||
|
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.12.14/OpenCL-SDK-v2023.12.14-Win-x64.zip
|
||||||
|
unzip OpenCL-SDK-v2023.12.14-Win-x64.zip -d opencl-sdk
|
||||||
|
|
||||||
|
SDK=~/opencl-sdk/OpenCL-SDK-v2023.12.14-Win-x64
|
||||||
|
|
||||||
|
# Generate .def from DLL
|
||||||
|
cd $SDK/bin
|
||||||
|
gendef OpenCL.dll
|
||||||
|
|
||||||
|
# Generate libOpenCL.a from .def
|
||||||
|
x86_64-w64-mingw32-dlltool \
|
||||||
|
-D OpenCL.dll \
|
||||||
|
-d OpenCL.def \
|
||||||
|
-l libOpenCL.a
|
||||||
|
|
||||||
|
# Install into MinGW sysroot
|
||||||
|
sudo cp libOpenCL.a /usr/x86_64-w64-mingw32/lib/
|
||||||
|
sudo cp -r $SDK/include/CL /usr/x86_64-w64-mingw32/include/
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ls /usr/x86_64-w64-mingw32/lib/libOpenCL.a
|
||||||
|
ls /usr/x86_64-w64-mingw32/include/CL/cl.h
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 4 — Clone the repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~
|
||||||
|
git clone https://github.com/Nyanraltotlapun/nyash-aes-xts256-plain64.git
|
||||||
|
cd nyash-aes-xts256-plain64/nyash_client
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 5 — Cargo config
|
||||||
|
|
||||||
|
Create `.cargo/config.toml` in the `nyash_client` directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p .cargo
|
||||||
|
cat > .cargo/config.toml << 'EOF'
|
||||||
|
[target.x86_64-pc-windows-gnu]
|
||||||
|
linker = "x86_64-w64-mingw32-gcc"
|
||||||
|
ar = "x86_64-w64-mingw32-ar"
|
||||||
|
rustflags = ["-L", "/usr/x86_64-w64-mingw32/lib"]
|
||||||
|
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
linker = "gcc"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
PROTOC = "/usr/bin/protoc"
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 6 — Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rustup target add x86_64-pc-windows-gnu
|
||||||
|
|
||||||
|
# Linux
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
cargo build --release --target x86_64-pc-windows-gnu
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
| Platform | Path |
|
||||||
|
|----------|------|
|
||||||
|
| Linux | `target/release/nyash-client` |
|
||||||
|
| Windows | `target/x86_64-pc-windows-gnu/release/nyash-client.exe` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Runtime requirements for end users
|
||||||
|
|
||||||
|
The `.exe` does **not** bundle an OpenCL runtime — it is loaded dynamically from the user's system.
|
||||||
|
|
||||||
|
| OS | OpenCL source |
|
||||||
|
|---------|----------------------------------------------------|
|
||||||
|
| Windows | Intel CPU Runtime for OpenCL — installed automatically with Intel drivers, or download from [intel.com](https://www.intel.com/content/www/us/en/developer/articles/tool/opencl-drivers.html) |
|
||||||
|
| Linux | `sudo apt install pocl-opencl-icd` (CPU) or vendor GPU driver |
|
||||||
@@ -23,5 +23,9 @@ tonic-prost-build = "0.14.5"
|
|||||||
ocl-include = "0.6"
|
ocl-include = "0.6"
|
||||||
flate2 = "1.1.9"
|
flate2 = "1.1.9"
|
||||||
|
|
||||||
|
[target.x86_64-pc-windows-gnu]
|
||||||
|
linker = "x86_64-w64-mingw32-gcc"
|
||||||
|
ar = "x86_64-w64-mingw32-ar"
|
||||||
|
rustflags = ["-L", "/usr/x86_64-w64-mingw32/lib"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ fn list_devices(dev_type: DeviceType) -> Vec<(Device, Platform)> {
|
|||||||
let list_res = Device::list(plt, Some(dev_type));
|
let list_res = Device::list(plt, Some(dev_type));
|
||||||
match list_res {
|
match list_res {
|
||||||
Ok(dev_l) => devices.extend(dev_l.iter().map(|dev| (*dev, plt.clone()))),
|
Ok(dev_l) => devices.extend(dev_l.iter().map(|dev| (*dev, plt.clone()))),
|
||||||
Err(_) => {}
|
Err(_) => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
@@ -157,10 +157,15 @@ fn dev_sel_dialog(all_devices: &Vec<(Device, Platform)>) -> Vec<usize> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_devices_conf(file_name: &str) -> Result<(Vec<(Device, Platform)>, AppConfig), String> {
|
pub fn get_devices_conf(file_name: &str) -> Result<(Vec<(Device, Platform)>, AppConfig), String> {
|
||||||
let dev_type = dev_type_from_str("ALL").expect("Unexpected device type!");
|
let dev_type = dev_type_from_str("GPU").expect("Unexpected device type!");
|
||||||
|
|
||||||
// Get devices to be used for key search
|
// Get devices to be used for key search
|
||||||
let all_devices: Vec<(Device, Platform)> = list_devices(dev_type);
|
let mut all_devices: Vec<(Device, Platform)> = list_devices(dev_type);
|
||||||
|
if all_devices.len() == 0 {
|
||||||
|
println!("Cannot detect GPU devices. Will try to list all!");
|
||||||
|
all_devices = list_devices(dev_type_from_str("ALL").expect("Unexpected device type!"));
|
||||||
|
}
|
||||||
|
|
||||||
if all_devices.len() == 0 {
|
if all_devices.len() == 0 {
|
||||||
return Err("Cannot find any usable devices.".to_string());
|
return Err("Cannot find any usable devices.".to_string());
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user