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

Fix cargo integration-test for Nix flake #11881

Closed

Conversation

willbush
Copy link

@willbush willbush commented Oct 14, 2024

The rustflags set in the flake.nix is stomping on helix/.cargo/config.toml:

rustflags = ["--cfg", "tokio_unstable", "-C", "target-feature=-crt-static"]

Here is the error I was getting:

$ cargo integration-test
   Compiling helix-event v24.7.0 (/home/will/code/helix/helix-event)
   Compiling helix-lsp-types v0.95.1 (/home/will/code/helix/helix-lsp-types)
   Compiling toml v0.8.19
   Compiling gix-url v0.27.5
error[E0412]: cannot find type `Id` in module `tokio::runtime`
   --> helix-event/src/runtime.rs:45:64
    |
45  |         parking_lot::RwLock<hashbrown::HashMap<tokio::runtime::Id, &'static T, ahash::RandomState>>,
    |                                                                ^^ not found in `tokio::runtime`
    |
note: found an item that was configured out
   --> /home/will/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/mod.rs:371:21
    |
371 |         pub use id::Id;
    |                     ^^

error[E0599]: no method named `id` found for struct `Handle` in the current scope
  --> helix-event/src/runtime.rs:67:52
   |
67 |         let id = tokio::runtime::Handle::current().id();
   |                                                    ^^ method not found in `Handle`

   Compiling gix-submodule v0.14.0
Some errors have detailed explanations: E0412, E0599.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `helix-event` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Can temporarily fix this by running:

RUSTFLAGS="--cfg tokio_unstable" cargo integration-test

This fixes the error because https://docs.rs/tokio/1.40.0/tokio/runtime/struct.Id.html "Available on tokio_unstable and crate feature rt only."

So this PR moves the setting of flags for Linux under .cargo/config.toml.

I did some digging on the history of RUSTFLAGS in the nix files:

The rustflags set in the `flake.nix` is stomping on helix/.cargo/config.toml:

```
rustflags = ["--cfg", "tokio_unstable", "-C", "target-feature=-crt-static"]
```

Here is the error I was getting:

```
$ cargo integration-test
   Compiling helix-event v24.7.0 (/home/will/code/helix/helix-event)
   Compiling helix-lsp-types v0.95.1 (/home/will/code/helix/helix-lsp-types)
   Compiling toml v0.8.19
   Compiling gix-url v0.27.5
error[E0412]: cannot find type `Id` in module `tokio::runtime`
   --> helix-event/src/runtime.rs:45:64
    |
45  |         parking_lot::RwLock<hashbrown::HashMap<tokio::runtime::Id, &'static T, ahash::RandomState>>,
    |                                                                ^^ not found in `tokio::runtime`
    |
note: found an item that was configured out
   --> /home/will/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/mod.rs:371:21
    |
371 |         pub use id::Id;
    |                     ^^

error[E0599]: no method named `id` found for struct `Handle` in the current scope
  --> helix-event/src/runtime.rs:67:52
   |
67 |         let id = tokio::runtime::Handle::current().id();
   |                                                    ^^ method not found in `Handle`

   Compiling gix-submodule v0.14.0
Some errors have detailed explanations: E0412, E0599.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `helix-event` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
```

Can temporarily fix this by running:

```
RUSTFLAGS="--cfg tokio_unstable" cargo integration-test
```

I did some digging on the history of RUSTFLAGS in the nix files:

- helix-editor@f1539cc
- helix-editor@d5db892
- helix-editor@df0d58e
@willbush
Copy link
Author

willbush commented Oct 14, 2024

Note: seems to me nix isn't used in the github action when releasing so I would expect some change for GNU/Linux binary result compared to what flake.nix is doing (correct me if I'm wrong).

@@ -1,3 +1,7 @@
# https://github.com/flamegraph-rs/flamegraph
[target.x86_64-unknown-linux-gnu]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I have used [target.'cfg(target_os = "linux")']? due to different targets in GH action release.yaml? Perhaps also the linker should be explicit..

@the-mikedavis the-mikedavis added the A-packaging Area: Packaging and bundling label Oct 16, 2024
@willbush
Copy link
Author

Think the way I was trying to fix this was incorrect. Just looked at latest master and this fixed it

@willbush willbush closed this Oct 29, 2024
@willbush willbush deleted the fix-integration-tests-for-nix branch October 29, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-packaging Area: Packaging and bundling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants