Skip to content

Commit

Permalink
Emit compilation error when compiled for Windows targets (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored May 7, 2024
1 parent 54a96f7 commit 8e80522
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 149 deletions.
33 changes: 1 addition & 32 deletions .github/workflows/md5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,4 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
targets: x86_64-apple-darwin
- run: cargo test --release

# Windows tests
windows:
strategy:
matrix:
include:
# 64-bit Windows (GNU)
- target: x86_64-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: x86_64-pc-windows-gnu
toolchain: stable
# 32-bit Windows (GNU)
- target: i686-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: i686-pc-windows-gnu
toolchain: stable

runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW${{ startsWith(matrix.target, 'i686-') && '32' || '64' }}
pacboy: cc:p
path-type: inherit
- run: cargo test --target ${{ matrix.target }} --release
shell: msys2 {0}
- run: cargo test --release --target x86_64-apple-darwin
33 changes: 1 addition & 32 deletions .github/workflows/sha1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,7 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
targets: x86_64-apple-darwin
- run: cargo test --release

# Windows tests
windows:
strategy:
matrix:
include:
# 64-bit Windows (GNU)
- target: x86_64-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: x86_64-pc-windows-gnu
toolchain: stable
# 32-bit Windows (GNU)
- target: i686-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: i686-pc-windows-gnu
toolchain: stable

runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW${{ startsWith(matrix.target, 'i686-') && '32' || '64' }}
pacboy: cc:p
path-type: inherit
- run: cargo test --target ${{ matrix.target }} --release
shell: msys2 {0}
- run: cargo test --release --target x86_64-apple-darwin

# Cross-compiled tests
cross:
Expand Down
33 changes: 1 addition & 32 deletions .github/workflows/sha2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,7 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
targets: x86_64-apple-darwin
- run: cargo test --release

# Windows tests
windows:
strategy:
matrix:
include:
# 64-bit Windows (GNU)
- target: x86_64-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: x86_64-pc-windows-gnu
toolchain: stable
# 32-bit Windows (GNU)
- target: i686-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: i686-pc-windows-gnu
toolchain: stable

runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW${{ startsWith(matrix.target, 'i686-') && '32' || '64' }}
pacboy: cc:p
path-type: inherit
- run: cargo test --target ${{ matrix.target }} --release
shell: msys2 {0}
- run: cargo test --release --target x86_64-apple-darwin

# Cross-compiled tests
cross:
Expand Down
33 changes: 1 addition & 32 deletions .github/workflows/whirlpool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,4 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
targets: x86_64-apple-darwin
- run: cargo test --release

# Windows tests
windows:
strategy:
matrix:
include:
# 64-bit Windows (GNU)
- target: x86_64-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: x86_64-pc-windows-gnu
toolchain: stable
# 32-bit Windows (GNU)
- target: i686-pc-windows-gnu
toolchain: 1.48.0 # MSRV
- target: i686-pc-windows-gnu
toolchain: stable

runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
targets: ${{ matrix.target }}
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW${{ startsWith(matrix.target, 'i686-') && '32' || '64' }}
pacboy: cc:p
path-type: inherit
- run: cargo test --target ${{ matrix.target }} --release
shell: msys2 {0}
- run: cargo test --release --target x86_64-apple-darwin
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion md5/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.2 (2024-05-06)
### Changed
- Emit compilation error when compiled for Windows targets. ([#79])

[#79]: https://github.com/RustCrypto/asm-hashes/pull/79

## 0.5.1 (2023-08-07)
### Changed
- Prefix x86 asm symbols with `_`` on Windows like on Apple ([#61])
- Prefix x86 asm symbols with `_` on Windows like on Apple ([#61])
- Fix deprecated use of `cc::Build::compile` ([#59])

[#61]: https://github.com/RustCrypto/asm-hashes/pull/61
Expand Down
2 changes: 1 addition & 1 deletion md5/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "md5-asm"
version = "0.5.1"
version = "0.5.2"
authors = ["RustCrypto Developers"]
license = "MIT"
description = "Assembly implementation of MD5 compression function"
Expand Down
2 changes: 1 addition & 1 deletion md5/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
} else if target_arch == "x86_64" {
"src/x64.S"
} else {
panic!("Unsupported target architecture");
panic!("Unsupported target architecture: {}", target_arch);
};
cc::Build::new().flag("-c").file(asm_path).compile("md5");
}
3 changes: 3 additions & 0 deletions md5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
compile_error!("crate can only be used on x86 and x86-64 architectures");

#[cfg(target_os = "windows")]
compile_error!("crate does not support Windows targets");

#[link(name = "md5", kind = "static")]
extern "C" {
fn md5_compress(state: &mut [u32; 4], block: &[u8; 64]);
Expand Down
8 changes: 7 additions & 1 deletion sha1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.3 (2024-05-06)
### Changed
- Emit compilation error when compiled for Windows targets. ([#79])

[#79]: https://github.com/RustCrypto/asm-hashes/pull/79

## 0.5.2 (2023-08-07)
### Changed
- Prefix x86 asm symbols with `_`` on Windows like on Apple ([#61])
- Prefix x86 asm symbols with `_` on Windows like on Apple ([#61])
- Fix deprecated use of `cc::Build::compile` ([#59])

[#61]: https://github.com/RustCrypto/asm-hashes/pull/61
Expand Down
2 changes: 1 addition & 1 deletion sha1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha1-asm"
version = "0.5.2"
version = "0.5.3"
authors = ["RustCrypto Developers"]
license = "MIT"
description = "Assembly implementation of SHA-1 compression function"
Expand Down
2 changes: 1 addition & 1 deletion sha1/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
} else if target_arch == "aarch64" {
"src/aarch64.S"
} else {
panic!("Unsupported target architecture");
panic!("Unsupported target architecture: {}", target_arch);
};
let mut build = cc::Build::new();
if target_arch == "aarch64" {
Expand Down
3 changes: 3 additions & 0 deletions sha1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")))]
compile_error!("crate can only be used on x86, x86_64 and AArch64 architectures");

#[cfg(target_os = "windows")]
compile_error!("crate does not support Windows targets");

#[link(name = "sha1", kind = "static")]
extern "C" {
fn sha1_compress(state: &mut [u32; 5], block: &[u8; 64]);
Expand Down
10 changes: 8 additions & 2 deletions sha2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.6.4 (2024-05-06)
### Changed
- Emit compilation error when compiled for Windows targets. ([#79])

[#79]: https://github.com/RustCrypto/asm-hashes/pull/79

## 0.6.3 (2023-08-07)
### Changed
- Prefix x86 asm symbols with `_`` on Windows like on Apple ([#61])
- Prefix x86 asm symbols with `_` on Windows like on Apple ([#61])

[#61]: https://github.com/RustCrypto/asm-hashes/pull/61

## 0.6.2 (2021-07-16)
### Changed
- Prefix x86 asm symbols with `_`` on Windows like on Apple ([#61])
- Prefix x86 asm symbols with `_` on Windows like on Apple ([#61])
- Fix deprecated use of `cc::Build::compile` ([#59])

[#61]: https://github.com/RustCrypto/asm-hashes/pull/61
Expand Down
2 changes: 1 addition & 1 deletion sha2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sha2-asm"
version = "0.6.3"
version = "0.6.4"
authors = ["RustCrypto Developers"]
license = "MIT"
description = "Assembly implementation of SHA-2 compression functions"
Expand Down
2 changes: 1 addition & 1 deletion sha2/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
build256.flag("-march=armv8-a+crypto");
("src/sha256_aarch64.S", "")
} else {
panic!("Unsupported target architecture");
panic!("Unsupported target architecture: {}", target_arch);
};

if target_arch != "aarch64" {
Expand Down
3 changes: 3 additions & 0 deletions sha2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86", target_arch = "aarch64")))]
compile_error!("crate can only be used on x86, x86-64 and aarch64 architectures");

#[cfg(target_os = "windows")]
compile_error!("crate does not support Windows targets");

#[link(name = "sha256", kind = "static")]
extern "C" {
fn sha256_compress(state: &mut [u32; 8], block: &[u8; 64]);
Expand Down
8 changes: 7 additions & 1 deletion whirlpool/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.6.2 (2024-05-06)
### Changed
- Emit compilation error when compiled for Windows targets. ([#79])

[#79]: https://github.com/RustCrypto/asm-hashes/pull/79

## 0.6.1 (2023-08-07)
### Changed
- Prefix x86 asm symbols with `_`` on Windows like on Apple ([#61])
- Prefix x86 asm symbols with `_` on Windows like on Apple ([#61])
- Fix deprecated use of `cc::Build::compile` ([#59])

[#61]: https://github.com/RustCrypto/asm-hashes/pull/61
Expand Down
2 changes: 1 addition & 1 deletion whirlpool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "whirlpool-asm"
version = "0.6.1"
version = "0.6.2"
authors = ["RustCrypto Developers"]
license = "MIT"
description = "Assembly implementation of Whirlpool compression function"
Expand Down
2 changes: 1 addition & 1 deletion whirlpool/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
} else if target_arch == "x86_64" {
"src/x64.S"
} else {
panic!("Unsupported target architecture");
panic!("Unsupported target architecture: {}", target_arch);
};
cc::Build::new()
.flag("-c")
Expand Down
3 changes: 3 additions & 0 deletions whirlpool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
compile_error!("crate can only be used on x86 and x86-64 architectures");

#[cfg(target_os = "windows")]
compile_error!("crate does not support Windows targets");

#[link(name = "whirlpool", kind = "static")]
extern "C" {
fn whirlpool_compress(state: &mut [u64; 8], block: &[u8; 64]);
Expand Down

0 comments on commit 8e80522

Please sign in to comment.