Skip to content
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

Cross will stop working in Rust 2024 Edition #1561

Open
4 of 11 tasks
sylv256 opened this issue Sep 26, 2024 · 5 comments
Open
4 of 11 tasks

Cross will stop working in Rust 2024 Edition #1561

sylv256 opened this issue Sep 26, 2024 · 5 comments

Comments

@sylv256
Copy link

sylv256 commented Sep 26, 2024

Checklist

Describe your issue

Cross will stop working in Rust 2024 because it uses an outdated feature.
Please migrate from mutable statics to support the latest Rust edition.

What target(s) are you cross-compiling for?

x86_64-pc-windows-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (ac4c11c 2024-09-24)

Example

Warnings like this are repeated multiple times while compiling.

warning: creating a shared reference to mutable static is discouraged
  --> src/temp.rs:91:8
   |
91 |     Ok(DIRS.last().expect("should not be empty").path())
   |        ^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

Additional information / notes

No response

@Emilgardis
Copy link
Member

I dont see how this is an issue, it will not stop working when Rust 2024 is released, we will still be on 2021 edition. When we update to 2024 we will have to move to the alternatives, but right now its fine

@sylv256
Copy link
Author

sylv256 commented Sep 26, 2024

The reason why it's being deprecated is quite important. I'd suggest reading that before deciding it's unnecessary to refactor for now.

@Emilgardis
Copy link
Member

Emilgardis commented Sep 27, 2024

Ok, that reason is more compelling. The current implementation shouldnt trigger immediate UB as we've reasoned about it (we do uphold the conditions), but we should change it to not chance it.

@Sewer56
Copy link

Sewer56 commented Nov 1, 2024

In some CI setups, running cargo install cross --git https://github.com/cross-rs/cross may fail actually.

Users of the very popular actions-rust-lang/setup-rust-toolchain which is often used transitively in CI setups would experience CI errors, because the action sets -D warnings by default.

I figured I'd give a heads up here.

Edit: In case it's not obvious, you can use RUSTFLAGS="" cargo install cross --git https://github.com/cross-rs/cross (bash) or similar as a temporary workaround.

@UebelAndre
Copy link
Contributor

UebelAndre commented Nov 28, 2024

I started seeing a ton of these warnings after upgrading to Rust 1.83.0

warning: creating a shared reference to mutable static is discouraged
   --> src/docker/local.rs:168:34
    |
168 |     let is_terminated = unsafe { crate::errors::TERMINATED.load(Ordering::SeqCst) };
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
    = note: `#[warn(static_mut_refs)]` on by default

warning: creating a shared reference to mutable static is discouraged
   --> src/docker/shared.rs:568:17
    |
568 |             if !CHILD_CONTAINER.exists.swap(true, Ordering::SeqCst) {
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a shared reference to mutable static is discouraged
   --> src/docker/shared.rs:592:18
    |
592 |         unsafe { CHILD_CONTAINER.exists() }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a mutable reference to mutable static is discouraged
   --> src/docker/shared.rs:604:13
    |
604 |             CHILD_CONTAINER.exit();
    |             ^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
   --> src/docker/shared.rs:630:13
    |
630 |             CHILD_CONTAINER.finish(is_tty, msg_info);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a shared reference to mutable static is discouraged
  --> src/errors.rs:27:9
   |
27 |     if !TERMINATED.swap(true, Ordering::SeqCst) && temp::has_tempfiles() {
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a mutable reference to mutable static is discouraged
   --> src/errors.rs:105:5
    |
105 |     docker::CHILD_CONTAINER.terminate();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a shared reference to mutable static is discouraged
  --> src/temp.rs:22:15
   |
22 |     unsafe { !FILES.is_empty() || !DIRS.is_empty() }
   |               ^^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a shared reference to mutable static is discouraged
  --> src/temp.rs:22:36
   |
22 |     unsafe { !FILES.is_empty() || !DIRS.is_empty() }
   |                                    ^^^^^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:31:5
   |
31 |     FILES.clear();
   |     ^^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:32:5
   |
32 |     DIRS.clear();
   |     ^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:41:5
   |
41 |     FILES.push(file);
   |     ^^^^^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:42:8
   |
42 |     Ok(FILES.last_mut().expect("file list should not be empty"))
   |        ^^^^^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:48:5
   |
48 |     FILES.pop()
   |     ^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:90:5
   |
90 |     DIRS.push(dir);
   |     ^^^^^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a shared reference to mutable static is discouraged
  --> src/temp.rs:91:8
   |
91 |     Ok(DIRS.last().expect("should not be empty").path())
   |        ^^^^^^^^^^^ shared reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives

warning: creating a mutable reference to mutable static is discouraged
  --> src/temp.rs:97:5
   |
97 |     DIRS.pop()
   |     ^^^^^^^^^^ mutable reference to mutable static
   |
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
   = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: `cross` (lib) generated 17 warnings
    Finished `release` profile [optimized] target(s) in 49.78s

github-merge-queue bot pushed a commit to bazelbuild/rules_rust that referenced this issue Nov 29, 2024
Bumping to latest now to reduce delta when
cross-rs/cross#1561 is fixed.
CramBL added a commit to luftkode/plotinator3000 that referenced this issue Dec 5, 2024
sergi0g added a commit to sergi0g/cup that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants