Skip to content

Using dynamic_linking on Windows breaks cargo test --doc #14129

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

Closed
janhohenheim opened this issue Jul 4, 2024 · 1 comment
Closed

Using dynamic_linking on Windows breaks cargo test --doc #14129

janhohenheim opened this issue Jul 4, 2024 · 1 comment
Labels
A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior C-Docs An addition or correction to our documentation C-Testing A change that impacts how we test Bevy or how users test their apps O-Windows Specific to the Windows desktop operating system P-Crash A sudden unexpected crash

Comments

@janhohenheim
Copy link
Member

janhohenheim commented Jul 4, 2024

originally discovered in #13553

Bevy version

0.14.0

Relevant system information

  • Rust version: 1.80.0
  • OS: Windows 11
`AdapterInfo { name: "NVIDIA GeForce GTX 1080 Ti", vendor: 4318, device: 6918, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.99", backend: Vulkan }`

What you did

Cargo.toml
[package]
name = "minimal_doctest_fail"
version = "0.1.0"
edition = "2021"

[dependencies]
# remove the `dynamic_linking` feature to fix the issue.
bevy = { version = "0.14.0", features = ["dynamic_linking"] }

# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
lib.rs
/// ```
/// use bevy::prelude::*;
/// ```
pub struct Foo;

What went wrong

Running cargo test --doc results in a failure:

Test executable failed (exit code: 0xc0000135)

That exit code means that a dynamic library was not found. Indeed, removing the dynamic_linking feature fixes this.

Additional information

Quoting @SkiFire13 here:

@janhohenheim I can confirm that this results in the Test executable failed (exit code: 0xc0000135) error for me as well (tested with an empty .cargo/config.toml and no RUSTFLAGS or RUSTDOCFLAGS set).

I've also managed to further minimize the issue to remove the dependency on Bevy. You only need a crate depending on a dylib crate, and a doctest that uses any item from the dylib crate. SkiFire13/minimal_dylib_doctest_fail

I've also found this rust issue which seems to fit the problem rust-lang/rust#39487. It has been closed in favour of rust-lang/rustup#893, where it's mentioned that the issue is with the stdilb dll not being added to the path when running the test. Indeed if I either add %RUSTUP_HOME%\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\ to the PATH or copy the std-****.dll file in that directory to the directory where I'm running cargo test --doc then it works. However I wonder why this issue doesn't appear on Linux (I've tested on WSL and the same minimalized reproduction works fine without the workaround).

Since this breaks doctests for Windows users following Bevy's recommended settings, we should probably make readers aware of this. I opened bevyengine/bevy-website#1522 to add a little mention to the dynamic-on-Windows disclaimer we have anyways.

@janhohenheim janhohenheim added C-Bug An unexpected or incorrect behavior A-Build-System Related to build systems or continuous integration P-Crash A sudden unexpected crash O-Windows Specific to the Windows desktop operating system C-Testing A change that impacts how we test Bevy or how users test their apps labels Jul 4, 2024
@janhohenheim janhohenheim added the C-Docs An addition or correction to our documentation label Jul 4, 2024
@janhohenheim
Copy link
Member Author

Closing this as we correctly warn about it now on the website and there's probably nothing else we can do about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior C-Docs An addition or correction to our documentation C-Testing A change that impacts how we test Bevy or how users test their apps O-Windows Specific to the Windows desktop operating system P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

1 participant