]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Set the default ABI to C for extern blocks and extern functions
authorNobel Singh <nobel2073@gmail.com>
Fri, 19 Jan 2024 15:06:34 +0000 (20:51 +0545)
committerPhilip Herron <philip.herron@embecosm.com>
Sat, 3 Feb 2024 15:51:51 +0000 (15:51 +0000)
Previously, the default ABI was set to Rust, which is not correct for
extern blocks and extern functions. This patch changes the default
ABI to C for these cases.

gcc/rust/ChangeLog:

* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_qualifiers):
Change default ABI to C for extern functions
(ASTLoweringBase::lower_extern_block): Likewise

Signed-off-by: Nobel Singh <nobel2073@gmail.com>
gcc/rust/hir/rust-ast-lower-base.cc

index ddfda091fa32ad26988751844c117109d9e49c8f..36188d59b80811a5c3cf18b58ddbcc7c8194e7b9 100644 (file)
@@ -718,8 +718,8 @@ ASTLoweringBase::lower_qualifiers (const AST::FunctionQualifiers &qualifiers)
   Unsafety unsafety
     = qualifiers.is_unsafe () ? Unsafety::Unsafe : Unsafety::Normal;
   bool has_extern = qualifiers.is_extern ();
+  ABI abi = has_extern ? ABI::C : ABI::RUST;
 
-  ABI abi = ABI::RUST;
   if (qualifiers.has_abi ())
     {
       const std::string &extern_abi = qualifiers.get_extern_abi ();
@@ -965,7 +965,7 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
       extern_items.push_back (std::unique_ptr<HIR::ExternalItem> (lowered));
     }
 
-  ABI abi = ABI::RUST;
+  ABI abi = ABI::C;
   if (extern_block.has_abi ())
     {
       const std::string &extern_abi = extern_block.get_abi ();