Skip to content

Commit

Permalink
Refactor: unexposed __WASM_BINDGEN_GENERATED statics (#3035)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslihotzki authored Aug 17, 2022
1 parent 1e0d6c7 commit f197b0e
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use once_cell::sync::Lazy;
use proc_macro2::{Ident, Literal, Span, TokenStream};
use quote::{quote, ToTokens};
use std::collections::{HashMap, HashSet};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Mutex;
use wasm_bindgen_shared as shared;

Expand Down Expand Up @@ -82,14 +81,6 @@ impl TryToTokens for ast::Program {
// of the wasm executable. For now it's just a plain old static, but we'll
// eventually have it actually in its own section.

static CNT: AtomicUsize = AtomicUsize::new(0);

let generated_static_name = format!(
"__WASM_BINDGEN_GENERATED_{}",
ShortHash(CNT.fetch_add(1, Ordering::SeqCst)),
);
let generated_static_name = Ident::new(&generated_static_name, Span::call_site());

// See comments in `crates/cli-support/src/lib.rs` about what this
// `schema_version` is.
let prefix_json = format!(
Expand Down Expand Up @@ -125,14 +116,13 @@ impl TryToTokens for ast::Program {
(quote! {
#[cfg(target_arch = "wasm32")]
#[automatically_derived]
#[link_section = "__wasm_bindgen_unstable"]
#[doc(hidden)]
pub static #generated_static_name: [u8; #generated_static_length] = {
const _: () = {
static _INCLUDED_FILES: &[&str] = &[#(#file_dependencies),*];

*#generated_static_value
#[link_section = "__wasm_bindgen_unstable"]
pub static _GENERATED: [u8; #generated_static_length] =
*#generated_static_value;
};

})
.to_tokens(tokens);

Expand Down

0 comments on commit f197b0e

Please sign in to comment.