From aae9e9fbc07689e4f7262952c903c568eb127be9 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 05:48:11 +0000 Subject: [PATCH 01/17] We hae binaries. So dependabot everything. Also remote nostd --- .github/dependabot.yml | 10 +++++----- .github/workflows/nostd.yml | 28 ---------------------------- 2 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/nostd.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8139a93..82c4a47 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,10 +8,10 @@ updates: directory: / schedule: interval: daily - ignore: - - dependency-name: "*" + #ignore: + # - dependency-name: "*" # patch and minor updates don't matter for libraries # remove this ignore rule if your package has binaries - update-types: - - "version-update:semver-patch" - - "version-update:semver-minor" + # update-types: + # - "version-update:semver-patch" + # - "version-update:semver-minor" diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml deleted file mode 100644 index 32d56c3..0000000 --- a/.github/workflows/nostd.yml +++ /dev/null @@ -1,28 +0,0 @@ -permissions: - contents: read -on: - push: - branches: [main] - pull_request: -# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5 -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true -name: no-std -jobs: - nostd: - runs-on: ubuntu-latest - name: ${{ matrix.target }} - strategy: - matrix: - target: [thumbv7m-none-eabi, aarch64-unknown-none] - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: rustup target add ${{ matrix.target }} - run: rustup target add ${{ matrix.target }} - - name: cargo check - run: cargo check --target ${{ matrix.target }} --no-default-features From d1479173bc9e7ec5532389b97e475ce1e3c718b1 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 05:51:17 +0000 Subject: [PATCH 02/17] Remove our old CI --- .github/workflows/ci.yml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8576df6..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Cargo Build & Test - -on: - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build_and_test: - name: Rust project - latest - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - toolchain: - - stable - - beta - - nightly - steps: - - uses: actions/checkout@v3 - - uses: giraffate/clippy-action@v1 - - run: rustup update ${{ matrix.toolchain }} && rustup component add clippy && rustup default ${{ matrix.toolchain }} - - run: cargo build --verbose - - run: cargo test --verbose - \ No newline at end of file From c8a17c022d417aac8b87285a251e8d93cd9a9d91 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 20:51:50 +0000 Subject: [PATCH 03/17] Add miri flag, disable loom --- .github/workflows/safety.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index eb5a5d6..693ce0a 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -62,17 +62,17 @@ jobs: - name: cargo miri test run: cargo miri test env: - MIRIFLAGS: "" - loom: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: cargo test --test loom - run: cargo test --release --test loom - env: - LOOM_MAX_PREEMPTIONS: 2 - RUSTFLAGS: "--cfg loom" + MIRIFLAGS: "-Zmiri-isolation-error=warn" + #loom: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: true + # - name: Install stable + # uses: dtolnay/rust-toolchain@stable + # - name: cargo test --test loom + # run: cargo test --release --test loom + # env: + # LOOM_MAX_PREEMPTIONS: 2 + # RUSTFLAGS: "--cfg loom" From e6661edc1ea7c91a7361d07881f3c771211bd7ca Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 20:55:25 +0000 Subject: [PATCH 04/17] Update config.toml to take linking options out. Those should remain local, not checked in. --- .cargo/config.toml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index cdb14f7..bd8bb3d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,21 +1,3 @@ -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-Clink-arg=-fuse-ld=lld"] - -# NOTE: you must manually install https://github.com/michaeleisel/zld on mac. you can easily do this with the "brew" package manager: -# `brew install michaeleisel/zld/zld` -[target.x86_64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"] - -[target.aarch64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld"] - -[target.x86_64-pc-windows-msvc] -linker = "rust-lld.exe" - -[target.wasm32-unknown-unknown] -runner = "wasm-server-runner" - [target.'cfg(all())'] rustflags = [ "-Wclippy::pedantic", From 2720733d12e4ca84fd913bad352a516d54d45505 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 21:16:16 +0000 Subject: [PATCH 05/17] Disable isolation in miri as we need to read in test input files --- .github/workflows/safety.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index 693ce0a..81b0685 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -62,7 +62,7 @@ jobs: - name: cargo miri test run: cargo miri test env: - MIRIFLAGS: "-Zmiri-isolation-error=warn" + MIRIFLAGS: "-Zmiri-disable-isolation" #loom: # runs-on: ubuntu-latest # steps: From 46400fbddcf3abbf0bb868c94ac769162f664e84 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 21:25:00 +0000 Subject: [PATCH 06/17] Bump msrv to 1.65 --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3fb97ad..8571ff0 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability strategy: matrix: - msrv: [1.56.1] # 2021 edition requires 1.56 + msrv: [1.65] # 2021 edition requires 1.56 name: ubuntu / ${{ matrix.msrv }} steps: - uses: actions/checkout@v3 From a40baf18036bb1cd06f8b210edeccbeb5a93b941 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 22:23:58 +0000 Subject: [PATCH 07/17] suppress leak suppressions file for now --- .github/workflows/safety.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index 81b0685..b029223 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" + #LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest From 01313bbaa6df689dd099a7160b05026f53218169 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 22:24:11 +0000 Subject: [PATCH 08/17] Bump msrv comment explaining why --- .github/workflows/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8571ff0..0c49097 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability strategy: matrix: - msrv: [1.65] # 2021 edition requires 1.56 + msrv: [1.65] # let/else support name: ubuntu / ${{ matrix.msrv }} steps: - uses: actions/checkout@v3 From 0c21a2a1b73b4709f11f56a9121ed618f6da8474 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Tue, 23 May 2023 22:24:23 +0000 Subject: [PATCH 09/17] Change test to see if miri gets happier --- cpu/src/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpu/src/tests.rs b/cpu/src/tests.rs index c2c419f..0fc1248 100644 --- a/cpu/src/tests.rs +++ b/cpu/src/tests.rs @@ -184,8 +184,7 @@ macro_rules! init_test { // This should fail { - let ret = cpu.reset(); - assert!(ret.is_err(), "reset worked before power_on"); + assert!(cpu.reset().is_err(), "reset worked before power_on"); } // Now it should work. From 7ade788c7f176ed8c9452c681826db9ecdbeca44 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Wed, 24 May 2023 04:25:38 +0000 Subject: [PATCH 10/17] Fixup tests trying to get miri to work. Turns out it won't due to: https://github.com/rust-lang/unsafe-code-guidelines/issues/134 so disable that check --- .github/workflows/safety.yml | 2 +- cpu/src/tests.rs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index b029223..0125bd4 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -62,7 +62,7 @@ jobs: - name: cargo miri test run: cargo miri test env: - MIRIFLAGS: "-Zmiri-disable-isolation" + MIRIFLAGS: "-Zmiri-disable-isolation,-Zmiri-disable-stacked-borrows" #loom: # runs-on: ubuntu-latest # steps: diff --git a/cpu/src/tests.rs b/cpu/src/tests.rs index 0fc1248..41a593b 100644 --- a/cpu/src/tests.rs +++ b/cpu/src/tests.rs @@ -183,9 +183,7 @@ macro_rules! init_test { let mut cpu = setup($type, 0x1212, 0xEA, None, None, None, None); // This should fail - { - assert!(cpu.reset().is_err(), "reset worked before power_on"); - } + assert!(cpu.reset().is_err(), "reset worked before power_on"); // Now it should work. cpu.power_on()?; @@ -196,10 +194,7 @@ macro_rules! init_test { } // This should fail now. - { - let ret = cpu.power_on(); - assert!(ret.is_err(), "power_on passes twice"); - } + assert!(cpu.power_on().is_err(), "power_on passes twice"); } if $rand { assert!(track.len() == 2, "didn't get both decimal states"); From 50bdc45218c84ec0b67ac01c6bcf5cbd270e3450 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Wed, 24 May 2023 16:52:40 +0000 Subject: [PATCH 11/17] take 2 for multiple miri flags --- .github/workflows/safety.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index 0125bd4..0666a0d 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -62,7 +62,7 @@ jobs: - name: cargo miri test run: cargo miri test env: - MIRIFLAGS: "-Zmiri-disable-isolation,-Zmiri-disable-stacked-borrows" + MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" #loom: # runs-on: ubuntu-latest # steps: From f5619a31d8c213cadf38616a47f3e731392bef8d Mon Sep 17 00:00:00 2001 From: James Chacon Date: Wed, 24 May 2023 19:12:03 +0000 Subject: [PATCH 12/17] Try adding a leak suppresions file --- .github/workflows/safety.yml | 2 +- cpu/src/lsan-suppressions.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 cpu/src/lsan-suppressions.txt diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index 0666a0d..f81d8f7 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - #LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" + LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest diff --git a/cpu/src/lsan-suppressions.txt b/cpu/src/lsan-suppressions.txt new file mode 100644 index 0000000..1d7c7d4 --- /dev/null +++ b/cpu/src/lsan-suppressions.txt @@ -0,0 +1,2 @@ +# These tests are intended to leak some top level objects +leak:cpu::tests:: From ca5af5cd6673038e3584d971c84a0e7184fe3f61 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Wed, 24 May 2023 20:40:31 +0000 Subject: [PATCH 13/17] try putting lsan at top level --- cpu/src/lsan-suppressions.txt => lsan-suppressions.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cpu/src/lsan-suppressions.txt => lsan-suppressions.txt (100%) diff --git a/cpu/src/lsan-suppressions.txt b/lsan-suppressions.txt similarity index 100% rename from cpu/src/lsan-suppressions.txt rename to lsan-suppressions.txt From 6c4ede0a5c93c670edc963d9c59bf65a56a88da2 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Thu, 25 May 2023 04:56:56 +0000 Subject: [PATCH 14/17] Rework a few things: sanitizer - specify path relative in github actions miri - use sampling of tests from cpu. Otheriwse it OOMs --- .github/workflows/safety.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index f81d8f7..7b00680 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" + LSAN_OPTIONS: "suppressions=${GITHUB_WORKSPACE}/carglsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest @@ -59,10 +59,20 @@ jobs: with: toolchain: ${{ env.NIGHTLY }} components: miri - - name: cargo miri test - run: cargo miri test + - name: cargo miri test c64basic + run: cargo miri test -p c64basic env: - MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" + # Ignore leaks - cpu test does this on purpose. Isolation needed for + # test data loads. Stacked borrows because eyre doesn't + # work. + MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" + - name: cargo miri test cpu + run: cargo miri test -p cpu tests::init_tests test::irq_and_nmi test::load_tests tests::nop_hlt_tests::classic_nop_0x02_hlt tests::store_tests tests::rom_tests::functional_test + env: + # Ignore leaks - cpu test does this on purpose. Isolation needed for + # test data loads. Stacked borrows because eyre doesn't + # work. + MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" #loom: # runs-on: ubuntu-latest # steps: From d6b47474cdeb8e27fec3d1e60da4528e4956f19d Mon Sep 17 00:00:00 2001 From: James Chacon Date: Thu, 25 May 2023 05:01:59 +0000 Subject: [PATCH 15/17] Specify tests better --- .github/workflows/safety.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index 7b00680..fee3b5d 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -67,7 +67,7 @@ jobs: # work. MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" - name: cargo miri test cpu - run: cargo miri test -p cpu tests::init_tests test::irq_and_nmi test::load_tests tests::nop_hlt_tests::classic_nop_0x02_hlt tests::store_tests tests::rom_tests::functional_test + run: cargo miri test -p cpu --test tests::init_tests --test test::irq_and_nmi --test test::load_tests --test tests::nop_hlt_tests::classic_nop_0x02_hlt --test tests::store_tests --test tests::rom_tests::functional_test env: # Ignore leaks - cpu test does this on purpose. Isolation needed for # test data loads. Stacked borrows because eyre doesn't From a4d5d33a0334f8d64711a79f515bcd24c859ff79 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Sun, 4 Jun 2023 22:02:34 +0000 Subject: [PATCH 16/17] Break miri up for c64basic vs cpu For CPU only do a subset and run in separate runs to avoid OOMs. Try again to get leak detector happy --- .github/workflows/safety.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index fee3b5d..dad0f05 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - LSAN_OPTIONS: "suppressions=${GITHUB_WORKSPACE}/carglsan-suppressions.txt" + LSAN_OPTIONS: "suppressions=/${GITHUB_WORKSPACE}/lsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest @@ -62,16 +62,19 @@ jobs: - name: cargo miri test c64basic run: cargo miri test -p c64basic env: - # Ignore leaks - cpu test does this on purpose. Isolation needed for - # test data loads. Stacked borrows because eyre doesn't - # work. - MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" + # Disable isolation as we load external input files/images. + MIRIFLAGS: "-Zmiri-disable-isolation" - name: cargo miri test cpu - run: cargo miri test -p cpu --test tests::init_tests --test test::irq_and_nmi --test test::load_tests --test tests::nop_hlt_tests::classic_nop_0x02_hlt --test tests::store_tests --test tests::rom_tests::functional_test + run: | + # Only test a subset and do them in separate runs or miri OOMs + for i in init_tests irq_and_nmi load_tests store_tests nop_hlt_tests::classic_nop_0x02_hlt rom_tests::functional_test; do + echo Testing $i + cargo miri test -p cpu $i + done env: - # Ignore leaks - cpu test does this on purpose. Isolation needed for - # test data loads. Stacked borrows because eyre doesn't - # work. + # Ignore leaks - cpu test does this on purpose. + # Disable isolation as we load external input files/images. + # Stacked borrows because eyre doesn't work. MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" #loom: # runs-on: ubuntu-latest From e2cba0179043d5905e72b0fa502b0bf1963e01d4 Mon Sep 17 00:00:00 2001 From: James Chacon Date: Mon, 5 Jun 2023 04:59:12 +0000 Subject: [PATCH 17/17] Change to a test miri can run. Try a different way to pass lsan suppressions file --- .github/workflows/safety.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index dad0f05..ecdb6e6 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - LSAN_OPTIONS: "suppressions=/${GITHUB_WORKSPACE}/lsan-suppressions.txt" + LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest @@ -67,7 +67,7 @@ jobs: - name: cargo miri test cpu run: | # Only test a subset and do them in separate runs or miri OOMs - for i in init_tests irq_and_nmi load_tests store_tests nop_hlt_tests::classic_nop_0x02_hlt rom_tests::functional_test; do + for i in init_tests irq_and_nmi load_tests store_tests nop_hlt_tests::classic_nop_0x02_hlt rom_tests::undocumented_opcodes_test; do echo Testing $i cargo miri test -p cpu $i done