From e721d99ddfc7a75823c7e9536e5e42896e75ee84 Mon Sep 17 00:00:00 2001 From: Alexis ROBIN Date: Wed, 1 Apr 2026 22:57:56 +0200 Subject: [PATCH 1/2] fix(rust): sanitize export names for PGO compatibility Replace ':' and '#' characters with underscores in export names to make them compatible with native ELF linkers during PGO builds. Fixes #1509 --- crates/rust/src/interface.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 4f4f00471..58fccff19 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -1,8 +1,8 @@ use crate::bindgen::{FunctionBindgen, POINTER_SIZE_EXPRESSION}; use crate::{ - ConstructorReturnType, FnSig, Identifier, InterfaceName, Ownership, RuntimeItem, RustFlagsRepr, - RustWasm, TypeGeneration, classify_constructor_return_type, full_wit_type_name, int_repr, - to_rust_ident, to_upper_camel_case, wasm_type, + classify_constructor_return_type, full_wit_type_name, int_repr, to_rust_ident, + to_upper_camel_case, wasm_type, ConstructorReturnType, FnSig, Identifier, InterfaceName, + Ownership, RuntimeItem, RustFlagsRepr, RustWasm, TypeGeneration, }; use anyhow::Result; use heck::*; @@ -11,7 +11,7 @@ use std::fmt::Write as _; use std::mem; use wit_bindgen_core::abi::{self, AbiVariant, LiftLower}; use wit_bindgen_core::{ - AnonymousTypeGenerator, Source, TypeInfo, dealias, uwrite, uwriteln, wit_parser::*, + dealias, uwrite, uwriteln, wit_parser::*, AnonymousTypeGenerator, Source, TypeInfo, }; pub struct InterfaceGenerator<'a> { @@ -303,6 +303,7 @@ macro_rules! {macro_name} {{ unreachable!() } }; + let module = module.replace(':', "_").replace('#', "_"); let camel = name.to_upper_camel_case(); uwriteln!( self.src, @@ -1215,6 +1216,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) }; let export_prefix = self.r#gen.opts.export_prefix.as_deref().unwrap_or(""); let export_name = func.legacy_core_export_name(wasm_module_export_name.as_deref()); + let export_name = export_name.replace(':', "_").replace('#', "_"); let export_name = if async_ { format!("[async-lift]{export_name}") } else { From 868e8aa6a099fec8941edf673c3c08070144a7d3 Mon Sep 17 00:00:00 2001 From: Alexis ROBIN Date: Wed, 1 Apr 2026 23:13:39 +0200 Subject: [PATCH 2/2] fix(rust): sort imports in interface.rs --- crates/rust/src/interface.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index 58fccff19..ebfc6f9e1 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -1,8 +1,8 @@ use crate::bindgen::{FunctionBindgen, POINTER_SIZE_EXPRESSION}; use crate::{ - classify_constructor_return_type, full_wit_type_name, int_repr, to_rust_ident, - to_upper_camel_case, wasm_type, ConstructorReturnType, FnSig, Identifier, InterfaceName, - Ownership, RuntimeItem, RustFlagsRepr, RustWasm, TypeGeneration, + ConstructorReturnType, FnSig, Identifier, InterfaceName, Ownership, RuntimeItem, RustFlagsRepr, + RustWasm, TypeGeneration, classify_constructor_return_type, full_wit_type_name, int_repr, + to_rust_ident, to_upper_camel_case, wasm_type, }; use anyhow::Result; use heck::*; @@ -11,7 +11,7 @@ use std::fmt::Write as _; use std::mem; use wit_bindgen_core::abi::{self, AbiVariant, LiftLower}; use wit_bindgen_core::{ - dealias, uwrite, uwriteln, wit_parser::*, AnonymousTypeGenerator, Source, TypeInfo, + AnonymousTypeGenerator, Source, TypeInfo, dealias, uwrite, uwriteln, wit_parser::*, }; pub struct InterfaceGenerator<'a> {