Fix too many locals in wasm binary (#1159)

Split function into smaller non-inlinable ones

this fixes the issue that rust creates too many wasm locals in non-optimized
builds. That lead to a compile error in such builds.

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
nat-rix
2023-04-24 12:44:06 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 415b79652d
commit b0a3632868
@@ -68,7 +68,16 @@ macro_rules! register_node {
}; };
} }
macro_rules! raster_node { macro_rules! raster_node {
($path:ty, params: [$($type:ty),*]) => { ($path:ty, params: [$($type:ty),*]) => {{
// this function could also be inlined but serves as a workaround for
// [wasm-pack#981](https://github.com/rustwasm/wasm-pack/issues/981).
// The non-inlining function leads to fewer locals in the resulting
// wasm binary. This issue currently only applies to debug builds, so
// we guard inlining to only happen on production builds for
// optimization purposes.
#[cfg_attr(debug_assertions, inline(never))]
#[cfg_attr(not(debug_assertions), inline)]
fn generate_triples() -> Vec<(NodeIdentifier, NodeConstructor, NodeIOTypes)> {
vec![ vec![
( (
NodeIdentifier::new(stringify!($path)), NodeIdentifier::new(stringify!($path)),
@@ -110,6 +119,8 @@ macro_rules! raster_node {
) )
] ]
} }
generate_triples()
}};
} }
//TODO: turn into hashmap //TODO: turn into hashmap