From a91f9442a3b9f166459ce8244537ec4aee1286e9 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:13:42 +0200 Subject: [PATCH 01/11] Disable LTO --- Cargo.toml | 4 +++- cargo-marker/src/backend/driver.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 862c3844..60783860 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,11 @@ resolver = "2" [profile.release] codegen-units = 1 -lto = true strip = false +# ⚠️ Turns there is some bug in LTO on Windows, because it leads to the +# `marker_rustc_driver` crashing with "exit code: 0xc0000005, STATUS_ACCESS_VIOLATION" +lto = true [workspace.package] edition = "2021" diff --git a/cargo-marker/src/backend/driver.rs b/cargo-marker/src/backend/driver.rs index 864f7efe..a524df49 100644 --- a/cargo-marker/src/backend/driver.rs +++ b/cargo-marker/src/backend/driver.rs @@ -143,7 +143,7 @@ fn build_driver(toolchain: &str, version: &str, mut additional_rustc_flags: Opti // Build driver let mut cmd = Cargo::with_toolchain(toolchain).command(); if is_local_driver() { - cmd.args(["build", "--bin", "marker_rustc_driver"]); + cmd.args(["build", "--bin", "marker_rustc_driver", "--release"]); } else { cmd.args(["install", "marker_rustc_driver", "--version", version, "--force"]); From 695e1290aeaf0c218284ab6fe0033b44ccd80582 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:19:01 +0200 Subject: [PATCH 02/11] Add CI checks --- .github/workflows/ci.yml | 4 ++++ Cargo.toml | 2 +- cargo-marker/src/backend/driver.rs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53e71d9f..9757afbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 + - run: MARKER_ALLOW_DRIVER_BUILD=1 cargo build -p cargo_marker -p marker_rustc_driver --release + - run: + - run: cargo test --locked --all-features --all-targets - run: cargo test --locked --all-features --doc @@ -207,3 +210,4 @@ jobs: # +stable is to force using the pre-installed `cargo` on the runner instead of # what's specified in `rust-toolchain.toml` - run: cargo +stable marker --version + - run: cargo marker diff --git a/Cargo.toml b/Cargo.toml index 60783860..e74eb2fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ resolver = "2" codegen-units = 1 strip = false -# ⚠️ Turns there is some bug in LTO on Windows, because it leads to the +# ⚠️ Turns out there is some bug in LTO on Windows, because it leads to the # `marker_rustc_driver` crashing with "exit code: 0xc0000005, STATUS_ACCESS_VIOLATION" lto = true diff --git a/cargo-marker/src/backend/driver.rs b/cargo-marker/src/backend/driver.rs index a524df49..864f7efe 100644 --- a/cargo-marker/src/backend/driver.rs +++ b/cargo-marker/src/backend/driver.rs @@ -143,7 +143,7 @@ fn build_driver(toolchain: &str, version: &str, mut additional_rustc_flags: Opti // Build driver let mut cmd = Cargo::with_toolchain(toolchain).command(); if is_local_driver() { - cmd.args(["build", "--bin", "marker_rustc_driver", "--release"]); + cmd.args(["build", "--bin", "marker_rustc_driver"]); } else { cmd.args(["install", "marker_rustc_driver", "--version", version, "--force"]); From bc5935ff009b16c9727af5b1ccdec8ef4f4eb3d1 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:19:51 +0200 Subject: [PATCH 03/11] More comments --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9757afbb..65f1bd64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,4 +210,7 @@ jobs: # +stable is to force using the pre-installed `cargo` on the runner instead of # what's specified in `rust-toolchain.toml` - run: cargo +stable marker --version + + # There may be bugs in the release build of our binaries. For example, in the past + # we saw that LTO could lead to exit code: 0xc0000005, STATUS_ACCESS_VIOLATION crash - run: cargo marker From c5fced961e2b2b2aeb4c516f1e0afcc9e0a15d62 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:23:06 +0200 Subject: [PATCH 04/11] Fix --- .github/workflows/ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65f1bd64..fef46fe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: MARKER_ALLOW_DRIVER_BUILD=1 cargo build -p cargo_marker -p marker_rustc_driver --release - - run: - - run: cargo test --locked --all-features --all-targets - run: cargo test --locked --all-features --doc @@ -169,6 +166,19 @@ jobs: # Check that the release automation works as expected - run: scripts/release/test.sh + release-smoke-test: + runs-on: ${{ matrix.os }}-latest + + strategy: + matrix: + os: [ubuntu, windows, macos] + + steps: + - uses: actions/checkout@v4 + + - run: MARKER_ALLOW_DRIVER_BUILD=1 cargo build -p cargo_marker -p marker_rustc_driver --release + - run: PATH="$PWD/target/release:$PATH" cargo marker + # Check that the Github Action works github-action-test: runs-on: ${{ matrix.os }} From 675967c6223eb930d7202694917c3b59b7f63a32 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:26:52 +0200 Subject: [PATCH 05/11] Small fix --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fef46fe8..782a3ba6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -223,4 +223,5 @@ jobs: # There may be bugs in the release build of our binaries. For example, in the past # we saw that LTO could lead to exit code: 0xc0000005, STATUS_ACCESS_VIOLATION crash - - run: cargo marker + + - run: cargo marker -l 'marker_lints="*"' From 073667dbfcad58514f15070bdb2bf7d1669d8351 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:32:28 +0200 Subject: [PATCH 06/11] Fix --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 782a3ba6..20ac747b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,6 +166,10 @@ jobs: # Check that the release automation works as expected - run: scripts/release/test.sh + # This job performs a really simple smoke test that the release build of our binaries + # works well. We had to introduce this job after we saw that the release build on windows + # couldn't even work without crashing with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION + # due to some bug in LTO. release-smoke-test: runs-on: ${{ matrix.os }}-latest From 3c3bb905379eb8f1b12fb76907a2efd13427b532 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:36:43 +0200 Subject: [PATCH 07/11] Disable LTO --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e74eb2fa..25fee4dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ strip = false # ⚠️ Turns out there is some bug in LTO on Windows, because it leads to the # `marker_rustc_driver` crashing with "exit code: 0xc0000005, STATUS_ACCESS_VIOLATION" -lto = true +lto = false [workspace.package] edition = "2021" From 2ac442ef8545a731d816b25b4097c685110a2836 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 01:41:57 +0200 Subject: [PATCH 08/11] Don't fail fast. we want to know if other jobs are green or not --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20ac747b..e953090b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: + fail-fast: false matrix: os: [ubuntu, windows, macos] @@ -45,6 +46,7 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: + fail-fast: false matrix: os: [ubuntu, windows, macos] @@ -100,6 +102,7 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: + fail-fast: false matrix: os: [ubuntu, windows, macos] @@ -174,6 +177,7 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: + fail-fast: false matrix: os: [ubuntu, windows, macos] @@ -188,6 +192,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: # Make sure we cover all operating systems supported by Github Actions os: From d964a70b8bcee36eec3b36267f2746b1e6ae9747 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 14:50:47 +0200 Subject: [PATCH 09/11] Update the changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c454f0b..dc406c6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,12 @@ The following components are considered to be internal and they are excluded fro ## [Unreleased] +## [0.4.2] - 2023-11-25 + +[#320]: https://github.com/rust-marker/marker/pull/320 + +- [#320]: Disable LTO on release builds to fix the crash on Windows with `exit code: 0xc0000005, STATUS_ACCESS_VIOLATION` + ## [0.4.1] - 2023-11-24 [#319]: https://github.com/rust-marker/marker/pull/319 From eae645d282262cdc30363c1a05730d90065af8de Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 14:08:47 +0100 Subject: [PATCH 10/11] Fix cargo release --- .github/workflows/release-on-tag.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml index cbe34487..a78cf336 100644 --- a/.github/workflows/release-on-tag.yml +++ b/.github/workflows/release-on-tag.yml @@ -175,17 +175,19 @@ jobs: # For extra security we set the env variable with the token only # for the steps that require them. # - # There are two `cargo release` invocations here. One without the - # `cargo_marker` package, and one with it. + # We used to have two `cargo release` invocations here. One without the + # `cargo_marker` package, and one with it. This was done because there is + # an implicit dependency between `cargo_marker` and `marker_rustc_driver`, + # since the former installs the latter. However, this separation somehow + # resulted in the second `cargo release` invocation to fail with the error + # ``` + # the remote server responded with an error (status 403 Forbidden): + # must be logged in to perform that action + # ``` # - # Keep in mind that `cargo-marker` may install `marker_rustc_driver` - # from crates.io via `cargo install`. - # - # That being said, we will be extra safe if `cargo_marker` is published - # after `marker_rustc_driver`. - - run: cargo release publish --exclude cargo_marker --execute --no-confirm --no-verify --allow-branch '*' - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - run: cargo release publish --package cargo_marker --execute --no-confirm --no-verify --allow-branch '*' + # No idea why this happens, but let's just keep a single cargo release + # to avoid this issue and to simplify the workflow, because the problem + # we tried to protect against is not that likely to happen anyway. + - run: cargo release publish --no-confirm --no-verify --no-push --no-tag --allow-branch '*' env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} From 75fcdbc528c0165939a8001cda6785c815e6174e Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 25 Nov 2023 14:14:51 +0100 Subject: [PATCH 11/11] Reduce the timeout for ARM build --- .github/workflows/release-on-tag.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml index a78cf336..933fa2c1 100644 --- a/.github/workflows/release-on-tag.yml +++ b/.github/workflows/release-on-tag.yml @@ -128,6 +128,17 @@ jobs: env: artifact: marker_rustc_driver-aarch64-unknown-linux-gnu + # We've seen this job hang for 6 hours with the logs ending with + # ``` + # Compiling libloading v0.8.0 + # Compiling bumpalo v3.14.0 + # Error: The operation was canceled. + # ``` + # + # No idea how that happens. Maybe that's a bug with the compiler hang in rustc, + # but this bug seems flaky, and reruning the job if it hangs should help + timeout-minutes: 60 + steps: - uses: actions/checkout@v4