From 67dde919a6a0e2092c219ba947383e5c8a51c859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 9 Jul 2023 17:11:16 +0200 Subject: [PATCH 1/3] WIP --- .github/workflows/check-binary-size.yml | 47 ++++++------------------- .github/workflows/post-binary-size.yml | 24 +++++++++++++ 2 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/post-binary-size.yml diff --git a/.github/workflows/check-binary-size.yml b/.github/workflows/check-binary-size.yml index 5104b6d88..e7b2f53c1 100644 --- a/.github/workflows/check-binary-size.yml +++ b/.github/workflows/check-binary-size.yml @@ -1,11 +1,11 @@ # This workflow checks if a PR commit has changed the size of a hello world Rust program. # It downloads Rustc and compiles two versions of a stage0 compiler - one using the base commit # of the PR, and one using the latest commit in the PR. -# If the size of the hello world program has changed, it posts a comment to the PR. +# It then uploads the two built binaries as artifacts. name: Check binary size on: - pull_request_target: + pull_request: branches: - master @@ -28,7 +28,9 @@ jobs: - name: Fetch backtrace run: git submodule update --init library/backtrace - name: Create hello world program that uses backtrace - run: printf "fn main() { panic!(); }" > foo.rs + run: | + printf "fn main() { panic!(); }" > foo.rs + mkdir -p binaries - name: Build binary with base version of backtrace run: | printf "[llvm]\ndownload-ci-llvm = true\n\n[rust]\nincremental = false\n" > config.toml @@ -41,7 +43,7 @@ jobs: python3 x.py build library --stage 0 cp -r ./build/x86_64-unknown-linux-gnu/stage0/bin ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin cp -r ./build/x86_64-unknown-linux-gnu/stage0/lib/*.so ./build/x86_64-unknown-linux-gnu/stage0-sysroot/lib - ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binary-reference + ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binaries/binary-reference - name: Build binary with PR version of backtrace run: | cd library/backtrace @@ -52,36 +54,9 @@ jobs: python3 x.py build library --stage 0 cp -r ./build/x86_64-unknown-linux-gnu/stage0/bin ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin cp -r ./build/x86_64-unknown-linux-gnu/stage0/lib/*.so ./build/x86_64-unknown-linux-gnu/stage0-sysroot/lib - ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binary-updated - - name: Display binary size - run: | - ls -la binary-* - echo "SIZE_REFERENCE=$(stat -c '%s' binary-reference)" >> "$GITHUB_ENV" - echo "SIZE_UPDATED=$(stat -c '%s' binary-updated)" >> "$GITHUB_ENV" - - name: Post a PR comment if the size has changed - uses: actions/github-script@v6 + ./build/x86_64-unknown-linux-gnu/stage0-sysroot/bin/rustc -O foo.rs -o binaries/binary-updated + - name: Upload binaries + uses: actions/upload-artifact@v3 with: - script: | - const reference = process.env.SIZE_REFERENCE; - const updated = process.env.SIZE_UPDATED; - const diff = updated - reference; - const plus = diff > 0 ? "+" : ""; - const diff_str = `${plus}${diff}B`; - - if (diff !== 0) { - const percent = (((updated / reference) - 1) * 100).toFixed(2); - // The body is created here and wrapped so "weirdly" to avoid whitespace at the start of the lines, - // which is interpreted as a code block by Markdown. - const body = `Below is the size of a hello-world Rust program linked with libstd with backtrace. - - Original binary size: **${reference}B** - Updated binary size: **${updated}B** - Difference: **${diff_str}** (${percent}%)`; - - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body - }) - } + name: binaries + path: binaries/ diff --git a/.github/workflows/post-binary-size.yml b/.github/workflows/post-binary-size.yml new file mode 100644 index 000000000..7c30939aa --- /dev/null +++ b/.github/workflows/post-binary-size.yml @@ -0,0 +1,24 @@ +# This workflow posts a comment after the Check binary size workflow finishes. +# It is in a separate workflow to avoid running untrusted code with elevated permissions in the +# Check binary size workflow +name: Post binary size + +on: + workflow_run: + workflows: [Check binary size] + types: + - completed + +jobs: + post: + name: Post binary size + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + run_id: ${{ github.event.workflow_run.id }} + - run: ls From 6d8d66268c44946c4adedf98a97e116ea6c0eb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 9 Jul 2023 17:18:17 +0200 Subject: [PATCH 2/3] WIP --- .github/workflows/main.yml | 247 ------------------------------------- 1 file changed, 247 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 29fff2795..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,247 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - test: - name: Test - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-20.04 - rust: stable - - os: ubuntu-20.04 - rust: beta - - os: ubuntu-20.04 - rust: nightly - - os: macos-latest - rust: stable - - os: macos-latest - rust: nightly - # Note that these are on nightly due to rust-lang/rust#63700 not being - # on stable yet - - os: windows-latest - rust: stable-x86_64-msvc - - os: windows-latest - rust: stable-i686-msvc - - os: windows-latest - rust: stable-x86_64-gnu - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust (rustup) - run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - shell: bash - - run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV - shell: bash - - # full fidelity of backtraces on 32-bit msvc requires frame pointers, so - # enable that for our tests - - name: Force frame pointers - run: echo RUSTFLAGS="-Cforce-frame-pointers $RUSTFLAGS" >> $GITHUB_ENV - shell: bash - if: matrix.rust == 'stable-i686-msvc' - - - run: cargo build - - run: cargo test - - run: cargo test --features "serialize-rustc" - - run: cargo test --features "serialize-serde" - - run: cargo test --features "verify-winapi" - - run: cargo test --features "cpp_demangle" - - run: cargo test --no-default-features - - run: cargo test --no-default-features --features "std" - - run: cargo test --manifest-path crates/cpp_smoke_test/Cargo.toml - # This test is specifically about packed debuginfo with `*.dSYM` files - - run: cargo test --manifest-path crates/macos_frames_test/Cargo.toml - env: - CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: packed - CARGO_PROFILE_TEST_SPLIT_DEBUGINFO: packed - - run: cargo test --features gimli-symbolize --manifest-path crates/without_debuginfo/Cargo.toml - - run: cargo test --manifest-path crates/line-tables-only/Cargo.toml --features gimli-symbolize - - # Test debuginfo compression still works - - run: cargo test - if: contains(matrix.os, 'ubuntu') - env: - RUSTFLAGS: "-C link-arg=-Wl,--compress-debug-sections=zlib-gabi" - - run: cargo test - if: contains(matrix.os, 'ubuntu') - env: - RUSTFLAGS: "-C link-arg=-Wl,--compress-debug-sections=zlib-gnu" - - # Test that, on macOS, packed/unpacked debuginfo both work - - run: cargo clean && cargo test - # Test that, on macOS, packed/unpacked debuginfo both work - if: matrix.os == 'macos-latest' - env: - CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: unpacked - CARGO_PROFILE_TEST_SPLIT_DEBUGINFO: unpacked - - run: cargo clean && cargo test - if: matrix.os == 'macos-latest' - env: - CARGO_PROFILE_DEV_SPLIT_DEBUGINFO: packed - CARGO_PROFILE_TEST_SPLIT_DEBUGINFO: packed - # Test that, on macOS, binaries with no UUID work - - run: cargo clean && cargo test - if: matrix.os == 'macos-latest' - env: - RUSTFLAGS: "-C link-arg=-Wl,-no_uuid" - - # Test that, on Linux, packed/unpacked debuginfo both work - - run: cargo clean && cargo test - if: matrix.rust == 'nightly' - env: - RUSTFLAGS: "-C split-debuginfo=unpacked -Zunstable-options" - - run: cargo clean && cargo test - if: matrix.rust == 'nightly' - env: - RUSTFLAGS: "-C split-debuginfo=packed -Zunstable-options" - - # Test that separate debug info works - - run: ./ci/debuglink-docker.sh - if: contains(matrix.os, 'ubuntu') - - # Test that including as a submodule will still work, both with and without - # the `backtrace` feature enabled. - - run: cargo build --manifest-path crates/as-if-std/Cargo.toml - - run: cargo build --manifest-path crates/as-if-std/Cargo.toml --no-default-features - - windows_arm64: - name: Windows AArch64 - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust - run: rustup update stable --no-self-update && rustup default stable - shell: bash - - run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV - shell: bash - - run: rustup target add aarch64-pc-windows-msvc - - run: cargo test --no-run --target aarch64-pc-windows-msvc - - run: cargo test --no-run --target aarch64-pc-windows-msvc --features verify-winapi - - ios: - name: iOS - runs-on: macos-latest - strategy: - matrix: - include: - - target: aarch64-apple-ios - sdk: iphoneos - - target: x86_64-apple-ios - sdk: iphonesimulator - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - run: rustup target add ${{ matrix.target }} - - run: | - export RUSTFLAGS=-Dwarnings - export SDK_PATH=`xcrun --show-sdk-path --sdk ${{ matrix.sdk }}` - export RUSTFLAGS="-C link-arg=-isysroot -C link-arg=$SDK_PATH" - cargo test --no-run --target ${{ matrix.target }} - name: Build tests - - docker: - name: Docker - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - target: - - aarch64-unknown-linux-gnu - - arm-unknown-linux-gnueabihf - - armv7-unknown-linux-gnueabihf - - i586-unknown-linux-gnu - - i686-unknown-linux-gnu - - powerpc64-unknown-linux-gnu - - s390x-unknown-linux-gnu - - x86_64-pc-windows-gnu - - x86_64-unknown-linux-gnu - - x86_64-unknown-linux-musl - - arm-linux-androideabi - - armv7-linux-androideabi - - aarch64-linux-android - - i686-linux-android - - x86_64-linux-android - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust - run: rustup update stable && rustup default stable - - run: rustup target add ${{ matrix.target }} - - run: cargo generate-lockfile - - run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV - shell: bash - - run: ./ci/run-docker.sh ${{ matrix.target }} - - rustfmt: - name: Rustfmt - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust - run: rustup update stable && rustup default stable && rustup component add rustfmt - - run: cargo fmt --all -- --check - - build: - name: Build Targets - runs-on: ubuntu-20.04 - strategy: - matrix: - target: - - wasm32-unknown-unknown - - wasm32-wasi - - x86_64-unknown-fuchsia - - x86_64-fortanix-unknown-sgx - - x86_64-unknown-illumos - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust - run: rustup update nightly && rustup default nightly - - run: rustup target add ${{ matrix.target }} - - run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV - shell: bash - - run: cargo build --target ${{ matrix.target }} - - run: cargo build --manifest-path crates/as-if-std/Cargo.toml --target ${{ matrix.target }} - - msrv: - name: MSRV - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Rust - run: rustup update 1.55.0 && rustup default 1.55.0 - - run: cargo build - - miri: - name: Miri - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Miri - run: | - rustup toolchain install nightly --component miri - rustup override set nightly - cargo miri setup - - run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test From 4d50fe293087cd8d16f1b6b5dbf557493aa863ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 9 Jul 2023 17:18:49 +0200 Subject: [PATCH 3/3] WIP --- .github/workflows/check-binary-size.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-binary-size.yml b/.github/workflows/check-binary-size.yml index e7b2f53c1..5da578045 100644 --- a/.github/workflows/check-binary-size.yml +++ b/.github/workflows/check-binary-size.yml @@ -60,3 +60,4 @@ jobs: with: name: binaries path: binaries/ +# FOO