Skip to content

Commit

Permalink
chore(s2n-quic): update MSRV to 1.74.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyRosenblum committed Sep 27, 2024
1 parent c561869 commit 5444d53
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 37 deletions.
6 changes: 6 additions & 0 deletions common/s2n-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ bolero-generator = "0.11"
[package.metadata.kani]
flags = { tests = true }
unstable = { stubbing = true }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(kani)',
]
1 change: 0 additions & 1 deletion common/s2n-codec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![allow(unexpected_cfgs)]
#![cfg_attr(not(any(test, feature = "std")), no_std)]

#[cfg(feature = "alloc")]
Expand Down
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
aws-lc-rs = "1"
criterion = { version = "0.4", features = ["html_reports"] }
criterion = { version = "0.5", features = ["html_reports"] }
s2n-codec = { path = "../../../common/s2n-codec" }
s2n-quic-dc = { path = "../../s2n-quic-dc", features = ["testing"] }

Expand Down
2 changes: 0 additions & 2 deletions dc/s2n-quic-dc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![allow(unexpected_cfgs)]

pub mod allocator;
pub mod clock;
pub mod congestion;
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false

[dependencies]
bytes = "1"
criterion = { version = "0.4", features = ["html_reports"] }
criterion = { version = "0.5", features = ["html_reports"] }
crossbeam-channel = { version = "0.5" }
internet-checksum = "0.2"
s2n-codec = { path = "../../common/s2n-codec", features = ["testing"] }
Expand Down
10 changes: 10 additions & 0 deletions quic/s2n-quic-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ loom = { version = "0.7", features = ["checkpoint", "futures"] }
[package.metadata.kani]
flags = { tests = true }
unstable = { stubbing = true }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(feature, values("thiserror"))',
'cfg(fuzzing)',
'cfg(loom)',
'cfg(kani)',
'cfg(target_pointer_width, values("8", "128"))',
]
1 change: 0 additions & 1 deletion quic/s2n-quic-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![allow(unexpected_cfgs)]
#![cfg_attr(not(any(test, feature = "std")), no_std)]

#[cfg(feature = "alloc")]
Expand Down
16 changes: 16 additions & 0 deletions quic/s2n-quic-platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@ tracing = { version = "0.1" }
[package.metadata.kani]
flags = { tests = true }
unstable = { stubbing = true }

# Remove once MSRV is 1.80.0, see https://github.com/aws/s2n-quic/issues/2334
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(fuzz)',
'cfg(kani)',
'cfg(s2n_quic_platform_cmsg)',
'cfg(s2n_quic_platform_socket_msg)',
'cfg(s2n_quic_platform_socket_mmsg)',
'cfg(s2n_quic_platform_mtu_disc)',
'cfg(s2n_quic_platform_gso)',
'cfg(s2n_quic_platform_gro)',
'cfg(s2n_quic_platform_pktinfo)',
'cfg(s2n_quic_platform_tos)',
]
114 changes: 90 additions & 24 deletions quic/s2n-quic-platform/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use crate::Feature::*;
use std::{fs::read_dir, io::Error, path::Path, process::Command};

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
enum Feature {
ControlMessage,
SocketMessage,
SocketMultiMessage,
MtuDiscovery,
GenericSegmentationOffload,
GenericReceiveOffload,
PacketInfo,
TypeOfService,
}

impl Feature {
fn name(&self) -> &str {
match self {
ControlMessage => "cmsg",
SocketMessage => "socket_msg",
SocketMultiMessage => "socket_mmsg",
MtuDiscovery => "mtu_disc",
GenericSegmentationOffload => "gso",
GenericReceiveOffload => "gro",
PacketInfo => "pktinfo",
TypeOfService => "tos",
}
}
}

impl From<&str> for Feature {
fn from(value: &str) -> Self {
for feature in ALL_FEATURES {
if feature.name() == value {
return feature;
}
}

panic!("unsupported feature: {value}");
}
}

const ALL_FEATURES: [Feature; 8] = [
ControlMessage,
SocketMessage,
SocketMultiMessage,
MtuDiscovery,
GenericSegmentationOffload,
GenericReceiveOffload,
PacketInfo,
TypeOfService,
];

fn main() -> Result<(), Error> {
let mut features = Features::default();

Expand All @@ -11,7 +62,7 @@ fn main() -> Result<(), Error> {
// iterate twice in case there is dependence on another feature that comes later
for _ in 0..2 {
for feature in list.split(',') {
features.insert(feature.trim());
features.insert(feature.trim().into());
}
}
return Ok(());
Expand All @@ -24,7 +75,7 @@ fn main() -> Result<(), Error> {
if let Some(name) = path.file_stem() {
println!("cargo:rerun-if-changed={}", path.display());
if env.check(&path)? {
features.insert(name.to_str().expect("valid feature name"));
features.insert(name.to_str().expect("valid feature name").into());
}
}
}
Expand All @@ -35,63 +86,78 @@ fn main() -> Result<(), Error> {
"linux" => {
// miri doesn't support the way we detect syscall support so override it
if is_miri {
features.insert("socket_msg");
features.insert("socket_mmsg");
features.insert(SocketMessage);
features.insert(SocketMultiMessage);
}

features.insert("mtu_disc");
features.insert("gso");
features.insert("gro");
features.insert("pktinfo");
features.insert("tos");
features.insert(MtuDiscovery);
features.insert(GenericSegmentationOffload);
features.insert(GenericReceiveOffload);
features.insert(PacketInfo);
features.insert(TypeOfService);
}
"macos" => {
// miri doesn't support the way we detect syscall support so override it
if is_miri {
features.insert("socket_msg");
features.insert(SocketMessage);
}

features.insert("pktinfo");
features.insert("tos");
features.insert(PacketInfo);
features.insert(TypeOfService);
}
"android" => {
features.insert("mtu_disc");
features.insert("pktinfo");
features.insert("tos");
features.insert(MtuDiscovery);
features.insert(PacketInfo);
features.insert(TypeOfService);
}
_ => {
// TODO others
}
}

// Uncomment once MSRV is 1.80.0, see https://github.com/aws/s2n-quic/issues/2334
// for name in ALL_FEATURES.iter().map(|f| f.name()) {
// println!("cargo::rustc-check-cfg=cfg(s2n_quic_platform_{name})");
// }
//
// println!("cargo::rustc-check-cfg=cfg(fuzz, kani, kani_slow)");

Ok(())
}

#[derive(Debug, Default)]
struct Features {
features: std::collections::HashSet<String>,
features: std::collections::HashSet<Feature>,
}

impl Features {
fn insert(&mut self, name: &str) {
fn insert(&mut self, feature: Feature) {
// supporting any kind message implies cmsg support
if name == "socket_msg" || name == "socket_mmsg" {
self.insert("cmsg");
if matches!(feature, SocketMessage | SocketMultiMessage) {
self.insert(ControlMessage);
}

// the following features only make sense if cmsg is supported
if ["gso", "gro", "pktinfo", "tos"].contains(&name) && !self.supports("cmsg") {
if [
GenericSegmentationOffload,
GenericReceiveOffload,
PacketInfo,
TypeOfService,
]
.contains(&feature)
&& !self.supports(ControlMessage)
{
return;
}

let newly_inserted = self.features.insert(name.to_string());
let newly_inserted = self.features.insert(feature);
if newly_inserted {
println!("cargo:rustc-cfg=s2n_quic_platform_{name}");
println!("cargo:rustc-cfg=s2n_quic_platform_{}", feature.name());
}
}

fn supports(&self, name: &str) -> bool {
self.features.contains(name)
fn supports(&self, feature: Feature) -> bool {
self.features.contains(&feature)
}
}

Expand Down
1 change: 0 additions & 1 deletion quic/s2n-quic-platform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! This module contains abstractions around the platform on which the
//! stack is running

#![allow(unexpected_cfgs)]
#![cfg_attr(not(any(test, feature = "std")), no_std)]

extern crate alloc;
Expand Down
7 changes: 7 additions & 0 deletions quic/s2n-quic-qns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ mimalloc = { version = "0.1", default-features = false }
s2n-quic = { path = "../s2n-quic", features = ["unstable_client_hello", "unstable_resumption"] }
[target.'cfg(s2n_internal_dev)'.dependencies]
s2n-quic = { path = "../s2n-quic", features = ["unstable-provider-packet-interceptor"] }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(s2n_internal_dev)',
'cfg(feature, values("unstable_client_hello"))',
]
2 changes: 0 additions & 2 deletions quic/s2n-quic-qns/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![allow(unexpected_cfgs)]

use structopt::StructOpt;

pub type Error = Box<dyn 'static + std::error::Error + Send + Sync>;
Expand Down
6 changes: 6 additions & 0 deletions quic/s2n-quic-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ s2n-quic-rustls = { path = "../s2n-quic-rustls" }
# we don't use openssl-sys directly; it's just here to pin and vendor in dev
[package.metadata.cargo-udeps.ignore]
development = [ "openssl-sys" ]

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(s2n_quic_enable_pq_tls)',
]
2 changes: 0 additions & 2 deletions quic/s2n-quic-tls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

#![allow(unexpected_cfgs)]

use s2n_quic_core::application::ServerName;

/// Ensure memory is correctly managed in tests
Expand Down
7 changes: 7 additions & 0 deletions quic/s2n-quic-transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ futures-test = "0.3" # For testing Waker interactions
insta = { version = "1", features = ["json"] }
s2n-codec = { path = "../../common/s2n-codec", features = ["testing"] }
s2n-quic-core = { path = "../s2n-quic-core", features = ["testing"] }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
'cfg(s2n_quic_dump_on_panic)',
'cfg(feature, values("testing"))',
]
1 change: 0 additions & 1 deletion quic/s2n-quic-transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! This module contains all main runtime components for receiving and sending
//! data via the QUIC protocol.

#![allow(unexpected_cfgs)]
#![deny(unused_must_use)]
extern crate alloc;

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.71.1"
channel = "1.74.1"
components = [ "rustc", "clippy", "rustfmt" ]

0 comments on commit 5444d53

Please sign in to comment.