From 275d9213b9709f13424f3103d8cefba33eb6a066 Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 22:24:14 +0100 Subject: [PATCH 1/6] cranelift-isle: no_std support --- cranelift/isle/isle/src/codegen.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs index c215e1db74ea..e42ef1ae5a7c 100644 --- a/cranelift/isle/isle/src/codegen.rs +++ b/cranelift/isle/isle/src/codegen.rs @@ -166,7 +166,8 @@ impl<'a> Codegen<'a> { } writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap(); - writeln!(code, "use std::marker::PhantomData;").unwrap(); + writeln!(code, "use alloc::vec::Vec;").unwrap(); + writeln!(code, "use core::{{marker::PhantomData, ops}};").unwrap(); } fn generate_trait_sig(&self, code: &mut String, indent: &str, sig: &ExternalSig) { @@ -271,38 +272,38 @@ pub trait Length {{ fn len(&self) -> usize; }} -impl Length for std::vec::Vec {{ +impl Length for alloc::vec::Vec {{ fn len(&self) -> usize {{ - std::vec::Vec::len(self) + alloc::vec::Vec::len(self) }} }} pub struct ContextIterWrapper {{ iter: I, - _ctx: std::marker::PhantomData, + _ctx: core::marker::PhantomData, }} impl Default for ContextIterWrapper {{ fn default() -> Self {{ ContextIterWrapper {{ iter: I::default(), - _ctx: std::marker::PhantomData + _ctx: core::marker::PhantomData }} }} }} -impl std::ops::Deref for ContextIterWrapper {{ +impl core::ops::Deref for ContextIterWrapper {{ type Target = I; fn deref(&self) -> &I {{ &self.iter }} }} -impl std::ops::DerefMut for ContextIterWrapper {{ +impl core::ops::DerefMut for ContextIterWrapper {{ fn deref_mut(&mut self) -> &mut I {{ &mut self.iter }} }} impl From for ContextIterWrapper {{ fn from(iter: I) -> Self {{ - Self {{ iter, _ctx: std::marker::PhantomData }} + Self {{ iter, _ctx: core::marker::PhantomData }} }} }} impl ContextIter for ContextIterWrapper {{ @@ -322,7 +323,7 @@ impl IntoContextIter for ContextIterWrapper { fn into_context_iter(self) -> Self::IntoIter {{ ContextIterWrapper {{ iter: self.iter.into_iter(), - _ctx: std::marker::PhantomData + _ctx: core::marker::PhantomData }} }} }} From d7fc9576045c31884b9a342560dd57b9ad442b91 Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 22:36:36 +0100 Subject: [PATCH 2/6] add extern crate alloc, and remove unnessesary imports --- cranelift/isle/isle/src/codegen.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs index e42ef1ae5a7c..0607b875a350 100644 --- a/cranelift/isle/isle/src/codegen.rs +++ b/cranelift/isle/isle/src/codegen.rs @@ -166,8 +166,7 @@ impl<'a> Codegen<'a> { } writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap(); - writeln!(code, "use alloc::vec::Vec;").unwrap(); - writeln!(code, "use core::{{marker::PhantomData, ops}};").unwrap(); + writeln!(code, "extern crate alloc;").unwrap(); } fn generate_trait_sig(&self, code: &mut String, indent: &str, sig: &ExternalSig) { From 97b12418f252d33aa981853735426a9768b69a11 Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 22:39:55 +0100 Subject: [PATCH 3/6] allow unused imports --- cranelift/isle/isle/src/codegen.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs index 0607b875a350..997c1211dcbf 100644 --- a/cranelift/isle/isle/src/codegen.rs +++ b/cranelift/isle/isle/src/codegen.rs @@ -166,6 +166,7 @@ impl<'a> Codegen<'a> { } writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap(); + writeln!(code, "#[allow(unused_imports)]").unwrap(); writeln!(code, "extern crate alloc;").unwrap(); } From 442012089488622b152ed2a3df9dabc91d88b198 Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 23:37:35 +0100 Subject: [PATCH 4/6] remove extern crate alloc --- cranelift/isle/isle/src/codegen.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs index 997c1211dcbf..03ea578642bd 100644 --- a/cranelift/isle/isle/src/codegen.rs +++ b/cranelift/isle/isle/src/codegen.rs @@ -166,8 +166,6 @@ impl<'a> Codegen<'a> { } writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap(); - writeln!(code, "#[allow(unused_imports)]").unwrap(); - writeln!(code, "extern crate alloc;").unwrap(); } fn generate_trait_sig(&self, code: &mut String, indent: &str, sig: &ExternalSig) { From 7a516d9fb648152ab36b13720c130644f2dcde56 Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 23:44:07 +0100 Subject: [PATCH 5/6] add an import of core::marker::PhantomData --- cranelift/isle/isle/src/codegen.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cranelift/isle/isle/src/codegen.rs b/cranelift/isle/isle/src/codegen.rs index 03ea578642bd..78a8fee729e7 100644 --- a/cranelift/isle/isle/src/codegen.rs +++ b/cranelift/isle/isle/src/codegen.rs @@ -166,6 +166,7 @@ impl<'a> Codegen<'a> { } writeln!(code, "\nuse super::*; // Pulls in all external types.").unwrap(); + writeln!(code, "use core::marker::PhantomData;").unwrap(); } fn generate_trait_sig(&self, code: &mut String, indent: &str, sig: &ExternalSig) { From 6cfbebfe23e7771098e8bf79a8830b8c4b560e9e Mon Sep 17 00:00:00 2001 From: SSD Date: Thu, 1 Jan 2026 23:54:43 +0100 Subject: [PATCH 6/6] add extern crate alloc and core --- cranelift/isle/isle/isle_examples/link/borrows_main.rs | 3 +++ cranelift/isle/isle/isle_examples/link/iflets_main.rs | 3 +++ .../isle/isle/isle_examples/link/multi_constructor_main.rs | 3 +++ cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs | 3 +++ cranelift/isle/isle/isle_examples/link/test_main.rs | 3 +++ cranelift/isle/isle/isle_examples/run/iconst_main.rs | 3 +++ cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs | 3 +++ 7 files changed, 21 insertions(+) diff --git a/cranelift/isle/isle/isle_examples/link/borrows_main.rs b/cranelift/isle/isle/isle_examples/link/borrows_main.rs index 9de7d4ddded8..eaff4d9f918e 100644 --- a/cranelift/isle/isle/isle_examples/link/borrows_main.rs +++ b/cranelift/isle/isle/isle_examples/link/borrows_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod borrows; #[derive(Clone)] diff --git a/cranelift/isle/isle/isle_examples/link/iflets_main.rs b/cranelift/isle/isle/isle_examples/link/iflets_main.rs index 4c5717cbf407..ee974818f991 100644 --- a/cranelift/isle/isle/isle_examples/link/iflets_main.rs +++ b/cranelift/isle/isle/isle_examples/link/iflets_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod iflets; struct Context; diff --git a/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs b/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs index 3c05532ce077..c7bd08fd5bd1 100644 --- a/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs +++ b/cranelift/isle/isle/isle_examples/link/multi_constructor_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod multi_constructor; use multi_constructor::{ContextIter, IntoContextIter}; diff --git a/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs b/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs index ebfa38e30fdf..0554dd582976 100644 --- a/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs +++ b/cranelift/isle/isle/isle_examples/link/multi_extractor_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod multi_extractor; use multi_extractor::{ContextIter, IntoContextIter}; diff --git a/cranelift/isle/isle/isle_examples/link/test_main.rs b/cranelift/isle/isle/isle_examples/link/test_main.rs index 733e2a20193b..87f633e2ec6f 100644 --- a/cranelift/isle/isle/isle_examples/link/test_main.rs +++ b/cranelift/isle/isle/isle_examples/link/test_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod test; struct Context; diff --git a/cranelift/isle/isle/isle_examples/run/iconst_main.rs b/cranelift/isle/isle/isle_examples/run/iconst_main.rs index d53edea43831..275054993780 100644 --- a/cranelift/isle/isle/isle_examples/run/iconst_main.rs +++ b/cranelift/isle/isle/isle_examples/run/iconst_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod iconst; struct Context; diff --git a/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs b/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs index 37ddb0bcc50b..ec57de3383e1 100644 --- a/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs +++ b/cranelift/isle/isle/isle_examples/run/let_shadowing_main.rs @@ -1,3 +1,6 @@ +extern crate alloc; +extern crate core; + mod let_shadowing; struct Context;