From ee051b3c4443cabfb571ddb406d5a15d1f45c5d0 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 13 Jul 2022 02:20:20 -0600 Subject: backend: explain why cdecl is treated differently ... ... when setting up the ABIs Signed-off-by: Zixing Liu --- gcc/rust/backend/rust-compile-base.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 5bf64cc..28f3941 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -304,6 +304,12 @@ HIRCompileBase::setup_abi_options (tree fndecl, ABI abi) case Rust::ABI::INTRINSIC: case Rust::ABI::C: case Rust::ABI::CDECL: + // `decl_attributes` function (not the macro) has the side-effect of + // actually switching the codegen backend to use the ABI we annotated. + // However, since `cdecl` is the default ABI GCC will be using, explicitly + // specifying that ABI will cause GCC to emit a warning saying the + // attribute is useless (which is confusing to the user as the attribute + // is added by us). DECL_ATTRIBUTES (fndecl) = tree_cons (get_identifier ("cdecl"), NULL, DECL_ATTRIBUTES (fndecl)); -- cgit v1.1