Skip to content

Commit

Permalink
Add support and CI checks for 32-bit x86 architectures
Browse files Browse the repository at this point in the history
Format in `mod.rs`

Modernize `impl_lcm_array` macro to avoid warnings
    * Warnings because `skip` is not a valid `cfg` flag; use extra case
    instead
    * `?` has been stabilized in rust and is more precise than `*`

Disable compilation of avx2 code on i686 architectures

chore: bump patch version

Use `Focal Fossa` image in travis ci

Default is `Xenial` but the glibc version for that one is too old and
makes wasi error in CI:

```
wasmtime: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by wasmtime)
wasmtime: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by wasmtime)
The command "ci/script.sh" exited with 1.
```

Prepare to support 32-bit avx2

This reverts commit cdef661.

Different import on 32-bit architecture

fmt in decode/mod.rs

feature `bench_black_box` has been stabilized

Add 32 bit test on amd64

Clarify precendence in `bytes_per_line`

Add `gcc-multilib` to allow compilation on 32 bit targets

Remove spurious newline
  • Loading branch information
tvsfx committed Oct 30, 2024
1 parent bd37b72 commit cd6c6a7
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 11 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@ branches:
- master

language: rust
os: linux
dist: focal

jobs:
include:
# amd64 linux
- rust: stable
os: linux
arch: amd64
before_install:
- sudo apt update
- sudo apt install -y gcc-multilib # Allow compilation for 32-bit target
- rust: beta
os: linux
arch: amd64
before_install:
- sudo apt update
- sudo apt install -y gcc-multilib
- rust: nightly
env: FEATURES=--features=nightly
os: linux
arch: amd64
before_install:
- sudo apt update
- sudo apt install -y gcc-multilib

# arm64 linux
- rust: stable
os: linux
arch: arm64
- rust: beta
os: linux
arch: arm64
- rust: nightly
env: FEATURES=--features=nightly
os: linux
arch: arm64

install: ci/install.sh
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "b64-ct"
version = "0.1.2"
version = "0.1.3"
authors = ["Fortanix, Inc."]
license = "MPL-2.0"
edition = "2018"
Expand All @@ -24,7 +24,7 @@ readme = "README.md"
[features]
default = ["std"]
std = []
nightly = [] # Used only for testing
nightly = [] # Used only for testing

[dev-dependencies]
rand = "0.7"
Expand Down
3 changes: 3 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -xeo pipefail
# need to be repeated on other os and arch.
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$TRAVIS_CPU_ARCH" = "amd64" ]
then
rustup target add i686-unknown-linux-gnu

rustup target add wasm32-wasi
cargo install cargo-wasi
curl -L https://github.com/CraneStation/wasmtime/releases/download/dev/wasmtime-dev-x86_64-linux.tar.xz \
Expand All @@ -16,4 +18,5 @@ then

rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin

fi
3 changes: 3 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ cargo test $FEATURES
# need to be repeated on other os and arch.
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$TRAVIS_CPU_ARCH" = "amd64" ]
then
cargo test --no-default-features --target=i686-unknown-linux-gnu
cargo test $FEATURES --target=i686-unknown-linux-gnu

cargo wasi test --no-default-features
cargo wasi test $FEATURES

Expand Down
3 changes: 3 additions & 0 deletions src/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;

#[rustfmt::skip]
Expand Down
3 changes: 3 additions & 0 deletions src/decode/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;

use crate::avx2::*;
Expand Down
4 changes: 2 additions & 2 deletions src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mod tests {
use super::*;

use crate::test_support::rand_base64_size;
use crate::{ToBase64};
use crate::ToBase64;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub(super) fn test_avx2() -> avx2::Avx2 {
Expand Down Expand Up @@ -367,7 +367,7 @@ mod tests {

let mut v: Vec<u8> = vec![];
let bytes_per_line = BASE64_PEM_WRAP * 3 / 4;
for _i in 0..2*bytes_per_line {
for _i in 0..(2 * bytes_per_line) {
let encoded = v.to_base64(BASE64_PEM);
let decoded = decode64(encoded.as_bytes(), decoder, packer).unwrap();
assert_eq!(v, decoded);
Expand Down
3 changes: 3 additions & 0 deletions src/encode/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;

use crate::avx2::*;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
//! [not sufficient on some platforms]: https://ts.data61.csiro.au/projects/TS/cachebleed/
#![no_std]
#![cfg_attr(all(test, feature = "nightly"), feature(test, bench_black_box))]
#![cfg_attr(all(test, feature = "nightly"), feature(test))]

extern crate alloc;
#[cfg(any(test, feature = "std"))]
Expand Down

0 comments on commit cd6c6a7

Please sign in to comment.