Skip to content

Add optimize(size) to some particularly large functions #705

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

Merged
merged 2 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ jobs:

# Test that including as a submodule will still work, both with and without
# the `backtrace` feature enabled.
# Building as if part of std requires nightly features to be available
- run: cargo build --manifest-path crates/as-if-std/Cargo.toml
if: matrix.rust == 'nightly'
- run: cargo build --manifest-path crates/as-if-std/Cargo.toml --no-default-features
if: matrix.rust == 'nightly'

windows_arm64:
name: Windows AArch64
Expand Down
4 changes: 3 additions & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
set -ex

cargo test --target $TARGET
cargo build --target $TARGET --manifest-path crates/as-if-std/Cargo.toml
if rustc --version | grep nightly; then
cargo build --target $TARGET --manifest-path crates/as-if-std/Cargo.toml
fi
2 changes: 1 addition & 1 deletion crates/as-if-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// submodule into the standard library. We try to set this crate up similarly
// to the standard library itself to minimize the likelihood of issues when
// updating the `backtrace` crate.

#![feature(optimize_attribute)]
#![no_std]

extern crate alloc;
Expand Down
4 changes: 4 additions & 0 deletions src/symbolize/gimli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ struct Context<'a> {
}

impl<'data> Context<'data> {
// #[feature(optimize_attr)] is enabled when we're built inside libstd
#[cfg_attr(backtrace_in_libstd, optimize(size))]
fn new(
stash: &'data Stash,
object: Object<'data>,
Expand Down Expand Up @@ -355,6 +357,8 @@ impl Cache {
}

// unsafe because this is required to be externally synchronized
// #[feature(optimize_attr)] is enabled when we're built inside libstd
#[cfg_attr(backtrace_in_libstd, optimize(size))]
unsafe fn with_global(f: impl FnOnce(&mut Self)) {
// A very small, very simple LRU cache for debug info mappings.
//
Expand Down
Loading