Skip to content

Conversation

@sylvestre
Copy link
Contributor

No description provided.

@ChrisDryden
Copy link
Collaborator

ChrisDryden commented Jan 22, 2026

I'm not able to identify why this doesn't work in the CI, did you investigate using cfg-aliases? #9559

@ChrisDryden
Copy link
Collaborator

Did some further research, its failing because the #[cfg(...)] attribute evaluates based on the host machine (where the build script runs), not the target machine.

This should work:

  if let Ok(target_os) = env::var("CARGO_CFG_TARGET_OS") {
      if target_os == "linux" || target_os == "android" {
          println!("cargo:rustc-cfg=linux_android");
      }
  }

I would love to do something similar for all of the BSD os's, it would make stty much cleaner and easier to read

@ChrisDryden
Copy link
Collaborator

Actually two issues here, the cross compilation and that this will only set that config for the parent crate and you would need this in a build.rs for every crate to do this. How about adding this to the Cargo.toml instead?

[target.'cfg(any(target_os = "linux", target_os = "android"))']
rustflags = ["--cfg", "linux_android"]

@ChrisDryden
Copy link
Collaborator

Actually that Cargo.toml rustflags is not ideal either since it wont work for anyone that wants to use any of the utilities as a dependency. Not really any great options here.

@sylvestre
Copy link
Contributor Author

probably why we haven't done it before :)

@oech3
Copy link
Contributor

oech3 commented Jan 22, 2026

cfg-aliases is a dep of nix. No reason to avoid it (if works).

@xtqqczze
Copy link
Contributor

I know the name linux_android matches that in nix/nix-rust but I think it's a little unclear.

@oech3
Copy link
Contributor

oech3 commented Jan 23, 2026

linux_kernel?

@xtqqczze
Copy link
Contributor

linux_kernel?

That's what bytecodealliance/rustix uses and much clearer.

@xtqqczze
Copy link
Contributor

Other suggestions, linux-targets, linux-all, linux-abi or simplylinux?

@xtqqczze
Copy link
Contributor

linux_kernel?

That's what bytecodealliance/rustix uses and much clearer.

Might be worth considering that Android might not always use a linux kernel. For example, a future release of Android might be based on starnix which uses fuchsia.

So linux-abi might be the most technically correct option.

@xtqqczze
Copy link
Contributor

xtqqczze commented Jan 23, 2026

I'm leaning toward linux for simplicity and to align with the approach for bsd in #10443

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

Successfully merging this pull request may close these issues.

4 participants