Add a check-yjit-bindgen-unused target. Add to CI. (#6066)
This fails if there are any unused rust-bindgen "allow" entries. For that target we turn on Rust warnings (there are a lot) and grep for the ones that correspond to unused allow entries. I've added check-yjit-bindgen-unused as a dependency of check-yjit-bindings, so unused allow entries will now fail CI. This change also removes our single unused allow entry (VM_CALL.*) which was known to be bad.
This commit is contained in:
parent
b340d566e5
commit
118e3edc32
Notes:
git
2022-06-30 01:50:08 +09:00
Merged-By: maximecb <maximecb@ruby-lang.org>
1
yjit/bindgen/Cargo.lock
generated
1
yjit/bindgen/Cargo.lock
generated
@ -342,4 +342,5 @@ name = "yjit-bindgen"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
|
"env_logger",
|
||||||
]
|
]
|
||||||
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bindgen = "0.59.2"
|
bindgen = "0.59.2"
|
||||||
|
env_logger = "0.9.0"
|
||||||
|
@ -27,6 +27,9 @@ fn main() {
|
|||||||
SRC_ROOT_ENV
|
SRC_ROOT_ENV
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// We want Bindgen warnings printed to console
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
// Remove this flag so rust-bindgen generates bindings
|
// Remove this flag so rust-bindgen generates bindings
|
||||||
// that are internal functions not public in libruby
|
// that are internal functions not public in libruby
|
||||||
let filtered_clang_args = env::args().filter(|arg| arg != "-fvisibility=hidden");
|
let filtered_clang_args = env::args().filter(|arg| arg != "-fvisibility=hidden");
|
||||||
@ -145,8 +148,7 @@ fn main() {
|
|||||||
.allowlist_var("rb_mKernel")
|
.allowlist_var("rb_mKernel")
|
||||||
|
|
||||||
// From vm_callinfo.h
|
// From vm_callinfo.h
|
||||||
.allowlist_type("VM_CALL.*") // This doesn't work, possibly due to the odd structure of the #defines
|
.allowlist_type("vm_call_flag_bits")
|
||||||
.allowlist_type("vm_call_flag_bits") // So instead we include the other enum and do the bit-shift ourselves.
|
|
||||||
.allowlist_type("rb_call_data")
|
.allowlist_type("rb_call_data")
|
||||||
.blocklist_type("rb_callcache.*") // Not used yet - opaque to make it easy to import rb_call_data
|
.blocklist_type("rb_callcache.*") // Not used yet - opaque to make it easy to import rb_call_data
|
||||||
.opaque_type("rb_callcache.*")
|
.opaque_type("rb_callcache.*")
|
||||||
|
@ -46,11 +46,14 @@ miniruby$(EXEEXT): $(YJIT_LIBS)
|
|||||||
# Generate Rust bindings. See source for details.
|
# Generate Rust bindings. See source for details.
|
||||||
# Needs `./configure --enable-yjit=dev` and Clang.
|
# Needs `./configure --enable-yjit=dev` and Clang.
|
||||||
ifneq ($(strip $(CARGO)),) # if configure found Cargo
|
ifneq ($(strip $(CARGO)),) # if configure found Cargo
|
||||||
.PHONY: yjit-bindgen
|
.PHONY: yjit-bindgen yjit-bindgen-show-unused
|
||||||
yjit-bindgen: yjit.$(OBJEXT)
|
yjit-bindgen: yjit.$(OBJEXT)
|
||||||
YJIT_SRC_ROOT_PATH='$(top_srcdir)' $(CARGO) run --manifest-path '$(top_srcdir)/yjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS)
|
YJIT_SRC_ROOT_PATH='$(top_srcdir)' $(CARGO) run --manifest-path '$(top_srcdir)/yjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS)
|
||||||
|
|
||||||
|
check-yjit-bindgen-unused: yjit.$(OBJEXT)
|
||||||
|
RUST_LOG=warn YJIT_SRC_ROOT_PATH='$(top_srcdir)' $(CARGO) run --manifest-path '$(top_srcdir)/yjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) 2>&1 | (! grep "unused option: --allow")
|
||||||
|
|
||||||
# For CI, check whether YJIT's FFI bindings are up-to-date.
|
# For CI, check whether YJIT's FFI bindings are up-to-date.
|
||||||
check-yjit-bindings: yjit-bindgen
|
check-yjit-bindings: check-yjit-bindgen-unused
|
||||||
git -C "$(top_srcdir)" diff --exit-code yjit/src/cruby_bindings.inc.rs
|
git -C "$(top_srcdir)" diff --exit-code yjit/src/cruby_bindings.inc.rs
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user