Repository: rust-lang/rust-bindgen (rust)

Issue:
Feature request: add "system" ABI
It isn't a bug but a feature requested instead.

The enum [https://docs.rs/bindgen/latest/bindgen/enum.Abi.html](https://docs.rs/bindgen/latest/bindgen/enum.Abi.html) doesn't have the `"system"` ABI, while it is sometimes required. I suggest to make the bindgen crate more suitable for all purposes, we add the "system" ABI too, so that we can use the [Builder::override_abi](https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.override_abi) with it.

Pull request description:
account for system abi
Closes #2576

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46872f6f..7727787a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -171,6 +171,7 @@
 # Unreleased
 
 ## Added
+- The `system` ABI is now supported as an option for the `--override-abi` flag.
 ## Changed
 - The `Clone` implementation for `_BindgenUnionField` has been changed to pass
   the `incorrect_clone_impl_on_copy_type` Clippy lint.
diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs
index a0781a3c..5bfb70ef 100644
--- a/bindgen/ir/function.rs
+++ b/bindgen/ir/function.rs
@@ -190,6 +190,8 @@ pub enum Abi {
     Win64,
     /// The "C-unwind" ABI.
     CUnwind,
+    /// The "system" ABI.
+    System,
 }
 
 impl FromStr for Abi {
@@ -206,6 +208,7 @@ impl FromStr for Abi {
             "aapcs" => Ok(Self::Aapcs),
             "win64" => Ok(Self::Win64),
             "C-unwind" => Ok(Self::CUnwind),
+            "system" => Ok(Self::System),
             _ => Err(format!("Invalid or unknown ABI {:?}", s)),
         }
     }
@@ -223,6 +226,7 @@ impl std::fmt::Display for Abi {
             Self::Aapcs => "aapcs",
             Self::Win64 => "win64",
             Self::CUnwind => "C-unwind",
+            Abi::System => "system",
         };
 
         s.fmt(f)


Test patch:
diff --git a/bindgen-tests/tests/expectations/tests/abi-override.rs b/bindgen-tests/tests/expectations/tests/abi-override.rs
index 7853efbb..13132f9c 100644
--- a/bindgen-tests/tests/expectations/tests/abi-override.rs
+++ b/bindgen-tests/tests/expectations/tests/abi-override.rs
@@ -8,5 +8,8 @@ extern "stdcall" {
 extern "C" {
     pub fn baz();
 }
+extern "system" {
+    pub fn qux();
+}
 pub type boo = ::std::option::Option<unsafe extern "efiapi" fn()>;
 pub type foobar = ::std::option::Option<unsafe extern "efiapi" fn(boo: boo)>;
diff --git a/bindgen-tests/tests/headers/abi-override.h b/bindgen-tests/tests/headers/abi-override.h
index bbfe82c2..57865973 100644
--- a/bindgen-tests/tests/headers/abi-override.h
+++ b/bindgen-tests/tests/headers/abi-override.h
@@ -1,8 +1,9 @@
-// bindgen-flags: --override-abi=foo=fastcall --override-abi=bar=stdcall --override-abi=boo=efiapi --override-abi=foobar=efiapi
+// bindgen-flags: --override-abi=foo=fastcall --override-abi=bar=stdcall --override-abi=boo=efiapi --override-abi=foobar=efiapi --override-abi qux=system
 
 void foo();
 void bar();
 void baz();
+void qux();
 
 typedef void (*boo)();
 typedef void (*foobar)(boo boo);