Bug 1866608 - Update bindgen with fix from https://github.com/rust-lang/rust-bindgen/pull/2689. r=emilio,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D195060
This commit is contained in:
Mike Hommey 2023-11-30 21:43:21 +00:00
Родитель 630511a83a
Коммит b69bf725b8
9 изменённых файлов: 74 добавлений и 159 удалений

Просмотреть файл

@ -100,6 +100,11 @@ git = "https://github.com/rust-diplomat/diplomat"
rev = "8d125999893fedfdf30595e97334c21ec4b18da9" rev = "8d125999893fedfdf30595e97334c21ec4b18da9"
replace-with = "vendored-sources" replace-with = "vendored-sources"
[source."git+https://github.com/rust-lang/rust-bindgen?rev=86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"]
git = "https://github.com/rust-lang/rust-bindgen"
rev = "86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"
replace-with = "vendored-sources"
[source."git+https://github.com/servo/rust-cssparser?rev=aaa966d9d6ae70c4b8a62bb5e3a14c068bb7dff0"] [source."git+https://github.com/servo/rust-cssparser?rev=aaa966d9d6ae70c4b8a62bb5e3a14c068bb7dff0"]
git = "https://github.com/servo/rust-cssparser" git = "https://github.com/servo/rust-cssparser"
rev = "aaa966d9d6ae70c4b8a62bb5e3a14c068bb7dff0" rev = "aaa966d9d6ae70c4b8a62bb5e3a14c068bb7dff0"

7
Cargo.lock сгенерированный
Просмотреть файл

@ -438,8 +438,7 @@ dependencies = [
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.69.1" version = "0.69.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/rust-lang/rust-bindgen?rev=86f3dbe846020e2ba573d6eb38d1434d0cbcbb40#86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"
checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2"
dependencies = [ dependencies = [
"bitflags 2.4.0", "bitflags 2.4.0",
"cexpr", "cexpr",
@ -3957,7 +3956,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c17aec6d4e1822c023689899f09311592a36cbf6de8f85dfaf5f01976790d8d" checksum = "4c17aec6d4e1822c023689899f09311592a36cbf6de8f85dfaf5f01976790d8d"
dependencies = [ dependencies = [
"bindgen 0.66.999", "bindgen 0.69.1",
"mozbuild", "mozbuild",
"once_cell", "once_cell",
"pkcs11-bindings", "pkcs11-bindings",
@ -4323,7 +4322,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0fabbdbe64b22820753da90995b3a73d02907eaeeac6f2414962a566aaa18ea" checksum = "d0fabbdbe64b22820753da90995b3a73d02907eaeeac6f2414962a566aaa18ea"
dependencies = [ dependencies = [
"bindgen 0.66.999", "bindgen 0.69.1",
] ]
[[package]] [[package]]

Просмотреть файл

@ -144,6 +144,8 @@ backtrace = { path = "build/rust/backtrace" }
bindgen_0_63 = { package = "bindgen", path = "build/rust/bindgen-0.63" } bindgen_0_63 = { package = "bindgen", path = "build/rust/bindgen-0.63" }
bindgen_0_64 = { package = "bindgen", path = "build/rust/bindgen-0.64" } bindgen_0_64 = { package = "bindgen", path = "build/rust/bindgen-0.64" }
bindgen = { path = "build/rust/bindgen" } bindgen = { path = "build/rust/bindgen" }
# 0.69.1 + https://github.com/rust-lang/rust-bindgen/pull/2689
bindgen_0_69 = { package = "bindgen", git = "https://github.com/rust-lang/rust-bindgen", rev = "86f3dbe846020e2ba573d6eb38d1434d0cbcbb40" }
# Patch nix 0.24 to 0.27 # Patch nix 0.24 to 0.27
nix = { path = "build/rust/nix" } nix = { path = "build/rust/nix" }

Просмотреть файл

@ -686,6 +686,11 @@ who = "Andreas Pehrson <apehrson@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
delta = "0.68.1 -> 0.69.1" delta = "0.68.1 -> 0.69.1"
[[audits.bindgen]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.69.1 -> 0.69.1@git:86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"
[[audits.bit-set]] [[audits.bit-set]]
who = "Aria Beingessner <a.beingessner@gmail.com>" who = "Aria Beingessner <a.beingessner@gmail.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

Просмотреть файл

@ -23,6 +23,10 @@ url = "https://raw.githubusercontent.com/mozilla/supply-chain/main/audits.toml"
audit-as-crates-io = true audit-as-crates-io = true
notes = "This is the upstream code plus a few local fixes, see bug 1685697." notes = "This is the upstream code plus a few local fixes, see bug 1685697."
[policy."bindgen:0.69.1@git:86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"]
audit-as-crates-io = true
notes = "This is 0.69.1 + https://github.com/rust-lang/rust-bindgen/pull/2689."
[policy.chardetng] [policy.chardetng]
audit-as-crates-io = true audit-as-crates-io = true
notes = "This is a crate Henri wrote which is also published. We should probably update Firefox to tip and certify that." notes = "This is a crate Henri wrote which is also published. We should probably update Firefox to tip and certify that."

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

32
third_party/rust/bindgen/Cargo.toml поставляемый
Просмотреть файл

@ -24,7 +24,7 @@ build = "build.rs"
description = "Automatically generates Rust FFI bindings to C and C++ libraries." description = "Automatically generates Rust FFI bindings to C and C++ libraries."
homepage = "https://rust-lang.github.io/rust-bindgen/" homepage = "https://rust-lang.github.io/rust-bindgen/"
documentation = "https://docs.rs/bindgen" documentation = "https://docs.rs/bindgen"
readme = "README.md" readme = "../README.md"
keywords = [ keywords = [
"bindings", "bindings",
"ffi", "ffi",
@ -64,34 +64,28 @@ search = "# Unreleased"
name = "bindgen" name = "bindgen"
path = "lib.rs" path = "lib.rs"
[dependencies]
bitflags = "2.2.1"
cexpr = "0.6"
lazy_static = "1"
lazycell = "1"
peeking_take_while = "0.1.2"
rustc-hash = "1.0.1"
shlex = "1"
[dependencies.annotate-snippets] [dependencies.annotate-snippets]
version = "0.9.1" version = "0.9.1"
features = ["color"] features = ["color"]
optional = true optional = true
[dependencies.bitflags]
version = "2.2.1"
[dependencies.cexpr]
version = "0.6"
[dependencies.clang-sys] [dependencies.clang-sys]
version = "1" version = "1"
features = ["clang_6_0"] features = ["clang_6_0"]
[dependencies.lazy_static]
version = "1"
[dependencies.lazycell]
version = "1"
[dependencies.log] [dependencies.log]
version = "0.4" version = "0.4"
optional = true optional = true
[dependencies.peeking_take_while]
version = "0.1.2"
[dependencies.prettyplease] [dependencies.prettyplease]
version = "0.2.7" version = "0.2.7"
features = ["verbatim"] features = ["verbatim"]
@ -113,12 +107,6 @@ features = [
] ]
default-features = false default-features = false
[dependencies.rustc-hash]
version = "1.0.1"
[dependencies.shlex]
version = "1"
[dependencies.syn] [dependencies.syn]
version = "2.0" version = "2.0"
features = [ features = [

89
third_party/rust/bindgen/README.md поставляемый
Просмотреть файл

@ -1,89 +0,0 @@
[![crates.io](https://img.shields.io/crates/v/bindgen.svg)](https://crates.io/crates/bindgen)
[![docs.rs](https://docs.rs/bindgen/badge.svg)](https://docs.rs/bindgen/)
# `bindgen`
**`bindgen` automatically generates Rust FFI bindings to C (and some C++) libraries.**
For example, given the C header `doggo.h`:
```c
typedef struct Doggo {
int many;
char wow;
} Doggo;
void eleven_out_of_ten_majestic_af(Doggo* pupper);
```
`bindgen` produces Rust FFI code allowing you to call into the `doggo` library's
functions and use its types:
```rust
/* automatically generated by rust-bindgen 0.99.9 */
#[repr(C)]
pub struct Doggo {
pub many: ::std::os::raw::c_int,
pub wow: ::std::os::raw::c_char,
}
extern "C" {
pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
}
```
## Users Guide
[📚 Read the `bindgen` users guide here! 📚](https://rust-lang.github.io/rust-bindgen)
## MSRV
The `bindgen` minimum supported Rust version is **1.60.0**.
The `bindgen-cli` minimum supported Rust version is **1.64.0**.
No MSRV bump policy has been established yet, so MSRV may increase in any release.
The MSRV is the minimum Rust version that can be used to *compile* each crate. However, `bindgen` and `bindgen-cli` can generate bindings that are compatible with Rust versions below the current MSRV.
Most of the time, the `bindgen-cli` crate will have a more recent MSRV than `bindgen` as crates such as `clap` require it.
## API Reference
[API reference documentation is on docs.rs](https://docs.rs/bindgen)
## Environment Variables
In addition to the [library API](https://docs.rs/bindgen) and [executable command-line API][bindgen-cmdline],
`bindgen` can be controlled through environment variables.
End-users should set these environment variables to modify `bindgen`'s behavior without modifying the source code of direct consumers of `bindgen`.
- `BINDGEN_EXTRA_CLANG_ARGS`: extra arguments to pass to `clang`
- Arguments are whitespace-separated
- Use shell-style quoting to pass through whitespace
- Examples:
- Specify alternate sysroot: `--sysroot=/path/to/sysroot`
- Add include search path with spaces: `-I"/path/with spaces"`
- `BINDGEN_EXTRA_CLANG_ARGS_<TARGET>`: similar to `BINDGEN_EXTRA_CLANG_ARGS`,
but used to set per-target arguments to pass to clang. Useful to set system include
directories in a target-specific way in cross-compilation environments with multiple targets.
Has precedence over `BINDGEN_EXTRA_CLANG_ARGS`.
Additionally, `bindgen` uses `libclang` to parse C and C++ header files.
To modify how `bindgen` searches for `libclang`, see the [`clang-sys` documentation][clang-sys-env].
For more details on how `bindgen` uses `libclang`, see the [`bindgen` users guide][bindgen-book-clang].
## Releases
We don't follow a specific release calendar, but if you need a release please
file an issue requesting that (ping `@emilio` for increased effectiveness).
## Contributing
[See `CONTRIBUTING.md` for hacking on `bindgen`!](./CONTRIBUTING.md)
[bindgen-cmdline]: https://rust-lang.github.io/rust-bindgen/command-line-usage.html
[clang-sys-env]: https://github.com/KyleMayes/clang-sys#environment-variables
[bindgen-book-clang]: https://rust-lang.github.io/rust-bindgen/requirements.html#clang

87
third_party/rust/bindgen/ir/item.rs поставляемый
Просмотреть файл

@ -1432,57 +1432,58 @@ impl Item {
} }
} }
// Guess how does clang treat extern "C" blocks? match cursor.kind() {
if cursor.kind() == CXCursor_UnexposedDecl { // On Clang 18+, extern "C" is reported accurately as a LinkageSpec.
Err(ParseError::Recurse) // Older LLVM treat it as UnexposedDecl.
} else { CXCursor_LinkageSpec | CXCursor_UnexposedDecl => {
Err(ParseError::Recurse)
}
// We allowlist cursors here known to be unhandled, to prevent being // We allowlist cursors here known to be unhandled, to prevent being
// too noisy about this. // too noisy about this.
match cursor.kind() { CXCursor_MacroDefinition |
CXCursor_MacroDefinition | CXCursor_MacroExpansion |
CXCursor_MacroExpansion | CXCursor_UsingDeclaration |
CXCursor_UsingDeclaration | CXCursor_UsingDirective |
CXCursor_UsingDirective | CXCursor_StaticAssert |
CXCursor_StaticAssert | CXCursor_FunctionTemplate => {
CXCursor_FunctionTemplate => { debug!(
debug!( "Unhandled cursor kind {:?}: {:?}",
cursor.kind(),
cursor
);
Err(ParseError::Continue)
}
CXCursor_InclusionDirective => {
let file = cursor.get_included_file_name();
match file {
None => {
warn!("Inclusion of a nameless file in {:?}", cursor);
}
Some(included_file) => {
for cb in &ctx.options().parse_callbacks {
cb.include_file(&included_file);
}
ctx.add_dep(included_file.into_boxed_str());
}
}
Err(ParseError::Continue)
}
_ => {
// ignore toplevel operator overloads
let spelling = cursor.spelling();
if !spelling.starts_with("operator") {
warn!(
"Unhandled cursor kind {:?}: {:?}", "Unhandled cursor kind {:?}: {:?}",
cursor.kind(), cursor.kind(),
cursor cursor
); );
} }
CXCursor_InclusionDirective => { Err(ParseError::Continue)
let file = cursor.get_included_file_name();
match file {
None => {
warn!(
"Inclusion of a nameless file in {:?}",
cursor
);
}
Some(included_file) => {
for cb in &ctx.options().parse_callbacks {
cb.include_file(&included_file);
}
ctx.add_dep(included_file.into_boxed_str());
}
}
}
_ => {
// ignore toplevel operator overloads
let spelling = cursor.spelling();
if !spelling.starts_with("operator") {
warn!(
"Unhandled cursor kind {:?}: {:?}",
cursor.kind(),
cursor
);
}
}
} }
Err(ParseError::Continue)
} }
} }