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

Use consistent cfg attributes #1655

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

Thomasdezeeuw
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw commented Feb 13, 2023

No description provided.

@taiki-e
Copy link
Member

taiki-e commented Feb 13, 2023

Note that there is a proposal to deprecate target_vendor: rust-lang/rust#100343 / rust-lang/lang-team#102

@Thomasdezeeuw
Copy link
Collaborator Author

Note that there is a proposal to deprecate target_vendor: rust-lang/rust#100343 / rust-lang/lang-team#102

Well that's great... I guess we shouldn't go with this this then.

I've pushed another commit to clean up the remaining attributes which I've found while doing the previous work.

@Thomasdezeeuw Thomasdezeeuw changed the title Prefer to use target_vendor = "apple" everywhere Use consistent cfg attributes Feb 13, 2023
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

This looks good to me. However, I did notice while reading rust-lang/lang-team#102 that there's also a target_family = "apple" cfg that's set for both iOS and macOS. Would it be a bit simpler to use that rather than testing for both target_os cfgs?

))]
let socket_type = socket_type | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;

let socket = syscall!(socket(domain, socket_type, 0))?;

// Mimick `libstd` and set `SO_NOSIGPIPE` on apple systems.
#[cfg(target_vendor = "apple")]
#[cfg(any(target_os = "ios", target_os = "macos"))]
Copy link
Member

Choose a reason for hiding this comment

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

Nit, take it or leave it: rust-lang/lang-team#102 also mentions the existence of target_family = "apple", which is set in addition to target_family = "unix" when building for both iOS and macOS. It might be a little bit simpler to use target_family = "apple" here instead?

Comment on lines +24 to +32
#[cfg(any(target_os = "ios", target_os = "macos"))]
type Filter = i16;
#[cfg(target_os = "netbsd")]
type Filter = u32;

// Type of the `flags` field in the `kevent` structure.
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
type Flags = libc::c_ushort;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
Copy link
Member

Choose a reason for hiding this comment

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

similarly, would target_family="apple" make sense for these?

Comment on lines +252 to +254
#[cfg(any(target_os = "ios", target_os = "macos"))]
libc::SO_LINGER_SEC,
#[cfg(not(target_vendor = "apple"))]
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I believe we could use target_family = "apple" here?

@taiki-e
Copy link
Member

taiki-e commented Feb 13, 2023

@hawkw

target_family = "apple"

This has not yet been implemented.

$ rustc --print cfg --target x86_64-apple-darwin | grep target_family
target_family="unix"
$ rustc -V
rustc 1.69.0-nightly (5b8f28453 2023-02-12)

@Thomasdezeeuw
Copy link
Collaborator Author

This looks good to me. However, I did notice while reading rust-lang/lang-team#102 that there's also a target_family = "apple" cfg that's set for both iOS and macOS. Would it be a bit simpler to use that rather than testing for both target_os cfgs?

I agree I would prefer to use target_family = "apple", but as @taiki-e pointed it doesn't exists yet. So for now let's make it consistent and when the rustc side of things are resolved we can rethink this.

@Thomasdezeeuw Thomasdezeeuw merged commit 98915ad into tokio-rs:master Feb 13, 2023
@Thomasdezeeuw Thomasdezeeuw deleted the target-apple branch February 13, 2023 18:20
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.

3 participants