Skip to content

Commit 0f17e5a

Browse files
committed
Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiser
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: rust-lang/compiler-team#703 Tracking issue: #122532
2 parents cccf379 + d0dc943 commit 0f17e5a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/builder.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_span::Span;
3131
use rustc_target::abi::{
3232
self, call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange,
3333
};
34-
use rustc_target::spec::{HasTargetSpec, Target};
34+
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, WasmCAbi};
3535

3636
use crate::common::{type_is_pointer, SignType, TypeReflection};
3737
use crate::context::CodegenCx;
@@ -2352,6 +2352,12 @@ impl<'tcx> HasTargetSpec for Builder<'_, '_, 'tcx> {
23522352
}
23532353
}
23542354

2355+
impl<'tcx> HasWasmCAbiOpt for Builder<'_, '_, 'tcx> {
2356+
fn wasm_c_abi_opt(&self) -> WasmCAbi {
2357+
self.cx.wasm_c_abi_opt()
2358+
}
2359+
}
2360+
23552361
pub trait ToGccComp {
23562362
fn to_gcc_comparison(&self) -> ComparisonOp;
23572363
}

src/context.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_span::{source_map::respan, Span};
2020
use rustc_target::abi::{
2121
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
2222
};
23-
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
23+
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, TlsModel, WasmCAbi};
2424

2525
use crate::callee::get_fn;
2626
use crate::common::SignType;
@@ -557,6 +557,12 @@ impl<'gcc, 'tcx> HasTargetSpec for CodegenCx<'gcc, 'tcx> {
557557
}
558558
}
559559

560+
impl<'gcc, 'tcx> HasWasmCAbiOpt for CodegenCx<'gcc, 'tcx> {
561+
fn wasm_c_abi_opt(&self) -> WasmCAbi {
562+
self.tcx.sess.opts.unstable_opts.wasm_c_abi
563+
}
564+
}
565+
560566
impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
561567
type LayoutOfResult = TyAndLayout<'tcx>;
562568

0 commit comments

Comments
 (0)