Skip to content

Commit 3131289

Browse files
committed
Rework core to be ABI-safe
1 parent 3e54e3a commit 3131289

File tree

29 files changed

+427
-199
lines changed

29 files changed

+427
-199
lines changed

.github/workflows/asan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
matrix:
2121
# TODO: enable windows, macos
2222
os: [ubuntu-latest]
23-
toolchain: ["nightly-2023-10-01"]
23+
toolchain: ["nightly-2024-11-22"]
2424
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
2525
steps:
2626
- uses: actions/checkout@v2
@@ -51,7 +51,7 @@ jobs:
5151
matrix:
5252
# TODO: enable windows, macos
5353
os: [ubuntu-latest]
54-
toolchain: ["nightly-2023-10-01"]
54+
toolchain: ["nightly-2024-11-22"]
5555
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
5656
steps:
5757
- uses: actions/checkout@v2

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [macos-latest, ubuntu-latest, windows-latest]
18-
toolchain: ["1.74", "stable"]
18+
toolchain: ["1.84", "stable"]
1919
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
2020
steps:
2121
- uses: actions/checkout@v2
@@ -35,7 +35,7 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
os: [macos-latest, ubuntu-latest, windows-latest]
38-
toolchain: ["1.74", "stable", "nightly-2023-10-01"]
38+
toolchain: ["1.84", "stable", "nightly-2024-11-22"]
3939
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
4040
steps:
4141
- uses: actions/checkout@v2
@@ -57,7 +57,7 @@ jobs:
5757
strategy:
5858
fail-fast: false
5959
matrix:
60-
toolchain: ["1.74", "stable"]
60+
toolchain: ["1.84", "stable"]
6161
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
6262
steps:
6363
- uses: actions/checkout@v2

.github/workflows/coverage.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ jobs:
1717
- uses: actions-rs/toolchain@v1
1818
with:
1919
profile: minimal
20-
toolchain: nightly-2023-10-01
20+
toolchain: nightly-2024-11-22
2121
override: true
22+
components: llvm-tools-preview
2223
- run: cargo install grcov
2324
- name: Run tests with coverage
2425
run: |
2526
cd mfio-repo
2627
export CARGO_INCREMENTAL=0
27-
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
28+
export RUSTFLAGS="-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
2829
export RUSTDOCFLAGS="-Cpanic=abort"
30+
export LLVM_PROFILE_FILE="your_name-%p-%m.profraw"
2931
cargo build --workspace --exclude mfio-derive --all-features
3032
cargo test --workspace --exclude mfio-derive --all-features
31-
grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o ./target/debug/coverage
32-
bash <(curl -s https://codecov.io/bash) -f ./target/debug/coverage -t ${{ secrets.CODECOV_TOKEN }};
33+
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
34+
bash <(curl -s https://codecov.io/bash) -f lcov.info -t ${{ secrets.CODECOV_TOKEN }};
3335

.github/workflows/miri.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
env:
66
CARGO_TERM_COLOR: always
77
CARGO_NET_GIT_FETCH_WITH_CLI: true
8-
DEFAULT_MIRI_FLAGS: -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows -Zmiri-track-raw-pointers
8+
DEFAULT_MIRI_FLAGS: -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows
99

1010
jobs:
1111
miri:
@@ -14,7 +14,7 @@ jobs:
1414
RUSTFLAGS: --cfg tokio_unstable ${{matrix.rustflags}}
1515
strategy:
1616
matrix:
17-
toolchain: ["nightly-2023-10-01"]
17+
toolchain: ["nightly-2024-11-22"]
1818
seed: [1, 2, 3, 4, 5, 6, 7, 8]
1919
rustflags: ["", "--cfg mfio_assume_linear_types"]
2020
steps:

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [macos-latest, ubuntu-latest, windows-latest]
20-
toolchain: ["1.74", "stable"]
20+
toolchain: ["1.84", "stable"]
2121
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
2222
steps:
2323
- uses: actions/checkout@v2
@@ -38,7 +38,7 @@ jobs:
3838
fail-fast: false
3939
matrix:
4040
os: [macos-latest, ubuntu-latest, windows-latest]
41-
toolchain: ["1.74", "stable", "nightly-2023-10-01"]
41+
toolchain: ["1.84", "stable", "nightly-2024-11-22"]
4242
rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"]
4343
steps:
4444
- uses: actions/checkout@v2

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ members = [
1010
"mfio-rt",
1111
"mfio-derive",
1212
"mfio-netfs",
13+
"version-hack"
1314
]
1415

1516
default-members = [
1617
"mfio",
1718
"mfio-rt",
1819
"mfio-derive",
1920
"mfio-netfs",
21+
"version-hack"
2022
]
2123

24+
[patch.crates-io]
25+
abi_stable = { version = "0.11", git = "https://github.com/h33p/abi_stable_crates", branch = "c-unwind" }
26+
abi_stable_derive = { version = "0.11", git = "https://github.com/h33p/abi_stable_crates", branch = "c-unwind" }
27+
cglue = { version = "0.3", git = "https://github.com/h33p/cglue" }

mfio-netfs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ required-features = ["bin-deps"]
2121
[dependencies]
2222
mfio = { version = "0.1", path = "../mfio", default-features = false }
2323
mfio-rt = { version = "0.1", path = "../mfio-rt", default-features = false }
24-
cglue = { version = "0.2", features = ["task_unstable"], default-features = false }
24+
cglue = { version = "0.3", features = ["task"], default-features = false }
2525

2626
log = "0.4"
2727
bytemuck = { version = "1", features = ["derive"] }

mfio-netfs/src/net/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct Senders {
182182
}
183183

184184
pub struct NetworkFs {
185-
backend: BackendContainer<DynBackend>,
185+
backend: BackendContainer,
186186
cwd: NetworkFsDir,
187187
fs: Arc<mfio_rt::NativeRt>,
188188
cancel_ops_on_drop: bool,
@@ -617,13 +617,11 @@ impl NetworkFs {
617617
}
618618

619619
impl IoBackend for NetworkFs {
620-
type Backend = DynBackend;
621-
622620
fn polling_handle(&self) -> Option<PollingHandle> {
623621
self.fs.polling_handle()
624622
}
625623

626-
fn get_backend(&self) -> BackendHandle<Self::Backend> {
624+
fn get_backend(&self) -> BackendHandle {
627625
self.backend.acquire_nested(self.fs.get_backend())
628626
}
629627
}

mfio-netfs/src/net/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ struct ReadPacket {
7070

7171
impl ReadPacket {
7272
pub fn new(capacity: u64) -> Self {
73-
unsafe extern "C" fn len(pkt: &Packet<Write>) -> u64 {
73+
unsafe extern "C-unwind" fn len(pkt: &Packet<Write>) -> u64 {
7474
unsafe {
7575
let this = &*(pkt as *const Packet<Write> as *const ReadPacket);
7676
this.len
7777
}
7878
}
7979

80-
unsafe extern "C" fn get_mut(
80+
unsafe extern "C-unwind" fn get_mut(
8181
_: &mut ManuallyDrop<BoundPacketView<Write>>,
8282
_: usize,
8383
_: &mut MaybeUninit<WritePacketObj>,
8484
) -> bool {
8585
false
8686
}
8787

88-
unsafe extern "C" fn transfer_data(obj: &mut PacketView<'_, Write>, src: *const ()) {
88+
unsafe extern "C-unwind" fn transfer_data(obj: &mut PacketView<'_, Write>, src: *const ()) {
8989
let this = &*(obj.pkt() as *const Packet<Write> as *const ReadPacket);
9090
let len = obj.len();
9191
let idx = obj.start();

mfio-rt/src/native/impls/io_uring/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl IoUringState {
357357
pub struct Runtime {
358358
// NOTE: this must be before `state`, because `backend` contains references to data, owned by
359359
// `state`.
360-
backend: BackendContainer<DynBackend>,
360+
backend: BackendContainer,
361361
state: BaseArc<Mutex<IoUringState>>,
362362
waker: FdWakerOwner<RawFd>,
363363
}
@@ -623,8 +623,6 @@ impl Runtime {
623623
}
624624

625625
impl IoBackend for Runtime {
626-
type Backend = DynBackend;
627-
628626
fn polling_handle(&self) -> Option<PollingHandle> {
629627
static READ: PollingFlags = PollingFlags::new().read(true);
630628
Some(PollingHandle {
@@ -635,7 +633,7 @@ impl IoBackend for Runtime {
635633
})
636634
}
637635

638-
fn get_backend(&self) -> BackendHandle<Self::Backend> {
636+
fn get_backend(&self) -> BackendHandle {
639637
self.backend.acquire(Some(self.waker.flags()))
640638
}
641639
}

0 commit comments

Comments
 (0)