port the runtime to `#[thread_local]`