Skip to content

Commit

Permalink
Merge 4b8c438 into 0c71b5a
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed May 8, 2023
2 parents 0c71b5a + 4b8c438 commit 93083b4
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 130 deletions.
95 changes: 40 additions & 55 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ jobs:
build:
strategy:
matrix:
os: ["ubuntu-latest"]
rust_channel: ["stable", "beta", "nightly", "1.42.0"]
os: ['ubuntu-latest']
rust_channel: ['stable', 'beta', 'nightly', '1.42.0']
include:
- rust_channel: "stable"
os: "macOS-latest"
- rust_channel: stable
os: macOS-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- name: Install rust channel
run: |
rustup install ${{matrix.rust_channel}}
rustup default ${{matrix.rust_channel}}
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust_channel}}
- name: MSRV dependencies
if: matrix.rust_channel == '1.42.0'
run: |
Expand Down Expand Up @@ -54,14 +52,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- name: Install nightly rust
run: |
rustup install nightly
rustup default nightly
- name: Install rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Install `cargo fuzz`
run: cargo install cargo-fuzz --vers "^0.11.0"
run: cargo install cargo-fuzz --vers '^0.11.0'
- run: cargo fuzz build -Oa
- uses: actions/upload-artifact@v3
with:
Expand All @@ -75,8 +69,8 @@ jobs:
run_fuzz_targets:
strategy:
matrix:
fuzz_target: ["debug_abbrev", "debug_aranges", "debug_info", "debug_line", "eh_frame", "eh_frame_hdr"]
name: "Run `${{matrix.fuzz_target}}` fuzz target"
fuzz_target: ['debug_abbrev', 'debug_aranges', 'debug_info', 'debug_line', 'eh_frame', 'eh_frame_hdr']
name: Run `${{matrix.fuzz_target}}` fuzz target
needs: build_fuzz_targets
runs-on: ubuntu-latest
steps:
Expand All @@ -90,7 +84,7 @@ jobs:
with:
name: fuzz-targets
# Note: -max_total_time=300 == 300 seconds == 5 minutes.
- name: "Run `${{matrix.fuzz_target}}` fuzz target"
- name: Run `${{matrix.fuzz_target}}` fuzz target
run: |
mkdir ${{matrix.fuzz_target}}_artifacts
chmod +x ./fuzz-targets/${{matrix.fuzz_target}}
Expand All @@ -110,56 +104,49 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo test --no-default-features
# Ensure gimli can be built without alloc.
- run: cargo check --no-default-features --features read-core
- run: cargo test --no-default-features --features read
- run: cargo test --no-default-features --features read,fallible-iterator
- run: cargo test --no-default-features --features read,std
- run: cargo test --no-default-features --features read,endian-reader
- run: cargo test --no-default-features --features read,endian-reader,std
- run: cargo test --no-default-features --features write
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- run: cargo hack test --feature-powerset --exclude-features rustc-dep-of-std

bench:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- name: Install nightly rust
run: |
rustup install nightly
rustup default nightly
- name: Install rust nightly
uses: dtolnay/rust-toolchain@nightly
- run: cargo bench

cross:
strategy:
matrix:
target:
# A 32-bit target.
- "i686-unknown-linux-gnu"
- i686-unknown-linux-gnu
# A big-endian target
- "mips64-unknown-linux-gnuabi64"
- mips64-unknown-linux-gnuabi64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- run: cargo install cross
- run: rustup target add ${{matrix.target}}
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{matrix.target}}
- uses: taiki-e/install-action@v2
with:
tool: cross
- run: cross test --target ${{matrix.target}}

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- name: Install rust
run: |
rustup install stable
rustup default stable
rustup component add rustfmt
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check

coverage:
Expand All @@ -169,22 +156,20 @@ jobs:
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v3
- name: Install rustup
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal
- name: Install rust
run: |
rustup install stable
rustup default stable
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- name: Run cargo-tarpaulin
run: cargo tarpaulin --ignore-tests --out Lcov
- name: Upload to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: './lcov.info'
path-to-lcov: ./lcov.info

doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rust stable
uses: dtolnay/rust-toolchain@stable
- run: cargo doc
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ stable_deref_trait = { version = "1.1.0", default-features = false, optional = t

# Internal feature, only used when building as part of libstd, not part of the
# stable interface of this crate.
core = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-core' }
alloc = { version = '1.0.0', optional = true, package = 'rustc-std-workspace-alloc' }
compiler_builtins = { version = '0.1.2', optional = true }
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
compiler_builtins = { version = "0.1.2", optional = true }

[dev-dependencies]
crossbeam = "0.8"
Expand All @@ -43,15 +43,15 @@ default = ["read", "write", "std", "fallible-iterator", "endian-reader"]

# Internal feature, only used when building as part of libstd, not part of the
# stable interface of this crate.
rustc-dep-of-std = ['core', 'alloc', 'compiler_builtins']
rustc-dep-of-std = ["core", "alloc", "compiler_builtins"]

[profile.test]
split-debuginfo = 'packed'
split-debuginfo = "packed"

[profile.bench]
debug = true
codegen-units = 1
split-debuginfo = 'packed'
split-debuginfo = "packed"

[[example]]
name = "simple"
Expand Down
4 changes: 2 additions & 2 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ macro_rules! dw {
if let Some(s) = self.static_string() {
f.pad(s)
} else {
#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
{
f.pad(&format!("Unknown {}: {}", stringify!($struct_name), self.0))
}
#[cfg(not(feature = "read"))]
#[cfg(not(feature = "read-core"))]
{
write!(f, "Unknown {}: {}", stringify!($struct_name), self.0)
}
Expand Down
6 changes: 3 additions & 3 deletions src/leb128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! Read and write signed integers:
//!
//! ```
//! # #[cfg(all(feature = "read", feature = "write"))] {
//! # #[cfg(all(feature = "read-core", feature = "write"))] {
//! use gimli::{EndianSlice, NativeEndian, leb128};
//!
//! let mut buf = [0; 1024];
Expand All @@ -28,7 +28,7 @@
//! Or read and write unsigned integers:
//!
//! ```
//! # #[cfg(all(feature = "read", feature = "write"))] {
//! # #[cfg(all(feature = "read-core", feature = "write"))] {
//! use gimli::{EndianSlice, NativeEndian, leb128};
//!
//! let mut buf = [0; 1024];
Expand Down Expand Up @@ -247,7 +247,7 @@ pub mod write {
}

#[cfg(test)]
#[cfg(all(feature = "read", feature = "write"))]
#[cfg(all(feature = "read-core", feature = "write"))]
mod tests {
use super::{low_bits_of_byte, low_bits_of_u64, read, write, CONTINUATION_BIT};
use crate::endianity::NativeEndian;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#![no_std]

#[allow(unused_imports)]
#[cfg(any(feature = "read", feature = "write"))]
#[cfg(any(feature = "read-core", feature = "write"))]
#[macro_use]
extern crate alloc;

Expand Down
10 changes: 5 additions & 5 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
use alloc::vec::Vec;

use core::cmp::{Ord, Ordering};
Expand Down Expand Up @@ -1827,7 +1827,7 @@ impl<R: Reader> FrameDescriptionEntry<R> {
/// Specification of what storage should be used for [`UnwindContext`].
///
#[cfg_attr(
feature = "read",
feature = "read-core",
doc = "
Normally you would only need to use [`StoreOnHeap`], which places the stack
on the heap using [`Vec`]. This is the default storage type parameter for [`UnwindContext`].
Expand Down Expand Up @@ -1873,10 +1873,10 @@ pub trait UnwindContextStorage<R: Reader>: Sized {
type Stack: ArrayLike<Item = UnwindTableRow<R, Self>>;
}

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
const MAX_RULES: usize = 192;

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
impl<R: Reader> UnwindContextStorage<R> for StoreOnHeap {
type Rules = [(Register, RegisterRule<R>); MAX_RULES];
type Stack = Vec<UnwindTableRow<R, Self>>;
Expand Down Expand Up @@ -1944,7 +1944,7 @@ impl<R: Reader, A: UnwindContextStorage<R>> Default for UnwindContext<R, A> {
}
}

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
impl<R: Reader> UnwindContext<R> {
/// Construct a new call frame unwinding context.
pub fn new() -> Self {
Expand Down
14 changes: 7 additions & 7 deletions src/read/endian_slice.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Working with byte slices that have an associated endianity.

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
use alloc::borrow::Cow;
#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
use alloc::string::String;
use core::ops::{Deref, Index, Range, RangeFrom, RangeTo};
use core::str;
Expand Down Expand Up @@ -84,7 +84,7 @@ where

/// Converts the slice to a string, including invalid characters,
/// using `String::from_utf8_lossy`.
#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
#[inline]
pub fn to_string_lossy(&self) -> Cow<'input, str> {
String::from_utf8_lossy(self.slice)
Expand Down Expand Up @@ -287,18 +287,18 @@ where
Ok(EndianSlice::new(slice, self.endian))
}

#[cfg(not(feature = "read"))]
#[cfg(not(feature = "read-core"))]
fn cannot_implement() -> super::reader::seal_if_no_alloc::Sealed {
super::reader::seal_if_no_alloc::Sealed
}

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
#[inline]
fn to_slice(&self) -> Result<Cow<[u8]>> {
Ok(self.slice.into())
}

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
#[inline]
fn to_string(&self) -> Result<Cow<str>> {
match str::from_utf8(self.slice) {
Expand All @@ -307,7 +307,7 @@ where
}
}

#[cfg(feature = "read")]
#[cfg(feature = "read-core")]
#[inline]
fn to_string_lossy(&self) -> Result<Cow<str>> {
Ok(String::from_utf8_lossy(self.slice))
Expand Down

0 comments on commit 93083b4

Please sign in to comment.