Skip to content

Commit

Permalink
Add a hack to prevent proc_macro misopt in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Dec 7, 2023
1 parent 336fe8e commit cff15e8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/proc_macro/src/bridge/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ pub struct Buffer {
data: *mut u8,
len: usize,
capacity: usize,
reserve: extern "C" fn(Buffer, usize) -> Buffer,
drop: extern "C" fn(Buffer),
// HACK(nbdd0121): These should be `extern "C"` but LLVM < 17.0.4 will misoptimise if we do so.
// Remove this when we drop support for them or when we require patches to be present.
reserve: extern "C-unwind" fn(Buffer, usize) -> Buffer,
drop: extern "C-unwind" fn(Buffer),
}

unsafe impl Sync for Buffer {}
Expand Down Expand Up @@ -141,13 +143,13 @@ impl From<Vec<u8>> for Buffer {
}
}

extern "C" fn reserve(b: Buffer, additional: usize) -> Buffer {
extern "C-unwind" fn reserve(b: Buffer, additional: usize) -> Buffer {
let mut v = to_vec(b);
v.reserve(additional);
Buffer::from(v)
}

extern "C" fn drop(b: Buffer) {
extern "C-unwind" fn drop(b: Buffer) {
mem::drop(to_vec(b));
}

Expand Down

0 comments on commit cff15e8

Please sign in to comment.