[前][次][番号順一覧][スレッド一覧]

ruby-changes:72362

From: Noah <ko1@a...>
Date: Thu, 30 Jun 2022 01:50:03 +0900 (JST)
Subject: [ruby-changes:72362] 118e3edc32 (master): Add a check-yjit-bindgen-unused target. Add to CI. (#6066)

https://git.ruby-lang.org/ruby.git/commit/?id=118e3edc32

From 118e3edc32c9d1768cd4f33ca18f2c40ce9ae333 Mon Sep 17 00:00:00 2001
From: Noah Gibbs <noah.gibbs@s...>
Date: Wed, 29 Jun 2022 17:49:46 +0100
Subject: 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.
---
 yjit/bindgen/Cargo.lock  | 1 +
 yjit/bindgen/Cargo.toml  | 1 +
 yjit/bindgen/src/main.rs | 6 ++++--
 yjit/yjit.mk             | 7 +++++--
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/yjit/bindgen/Cargo.lock b/yjit/bindgen/Cargo.lock
index cf23cbf783..b6ee5ae6f8 100644
--- a/yjit/bindgen/Cargo.lock
+++ b/yjit/bindgen/Cargo.lock
@@ -342,4 +342,5 @@ name = "yjit-bindgen" https://github.com/ruby/ruby/blob/trunk/yjit/bindgen/Cargo.lock#L342
 version = "0.1.0"
 dependencies = [
  "bindgen",
+ "env_logger",
 ]
diff --git a/yjit/bindgen/Cargo.toml b/yjit/bindgen/Cargo.toml
index 18a8fbc463..57fd874939 100644
--- a/yjit/bindgen/Cargo.toml
+++ b/yjit/bindgen/Cargo.toml
@@ -7,3 +7,4 @@ edition = "2021" https://github.com/ruby/ruby/blob/trunk/yjit/bindgen/Cargo.toml#L7
 
 [dependencies]
 bindgen = "0.59.2"
+env_logger = "0.9.0"
diff --git a/yjit/bindgen/src/main.rs b/yjit/bindgen/src/main.rs
index d8f3c98e89..5abd445dae 100644
--- a/yjit/bindgen/src/main.rs
+++ b/yjit/bindgen/src/main.rs
@@ -27,6 +27,9 @@ fn main() { https://github.com/ruby/ruby/blob/trunk/yjit/bindgen/src/main.rs#L27
         SRC_ROOT_ENV
     );
 
+    // We want Bindgen warnings printed to console
+    env_logger::init();
+
     // Remove this flag so rust-bindgen generates bindings
     // that are internal functions not public in libruby
     let filtered_clang_args = env::args().filter(|arg| arg != "-fvisibility=hidden");
@@ -145,8 +148,7 @@ fn main() { https://github.com/ruby/ruby/blob/trunk/yjit/bindgen/src/main.rs#L148
         .allowlist_var("rb_mKernel")
 
         // 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") // So instead we include the other enum and do the bit-shift ourselves.
+        .allowlist_type("vm_call_flag_bits")
         .allowlist_type("rb_call_data")
         .blocklist_type("rb_callcache.*")      // Not used yet - opaque to make it easy to import rb_call_data
         .opaque_type("rb_callcache.*")
diff --git a/yjit/yjit.mk b/yjit/yjit.mk
index 2c3a6b3af8..eb1f5d1fe1 100644
--- a/yjit/yjit.mk
+++ b/yjit/yjit.mk
@@ -46,11 +46,14 @@ miniruby$(EXEEXT): $(YJIT_LIBS) https://github.com/ruby/ruby/blob/trunk/yjit/yjit.mk#L46
 # Generate Rust bindings. See source for details.
 # Needs `./configure --enable-yjit=dev` and Clang.
 ifneq ($(strip $(CARGO)),) # if configure found Cargo
-.PHONY: yjit-bindgen
+.PHONY: yjit-bindgen yjit-bindgen-show-unused
 yjit-bindgen: yjit.$(OBJEXT)
 	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.
-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
 endif
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]