<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2" -->

---
title: Why compiling Rust to WebAssembly is slow | daily.dev
description: Compiling Rust to WebAssembly with debug info enabled (debug = 2) can be dramatically slower than release builds without it, sometimes by 40x or more. The root...
canonical: https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why compiling Rust to WebAssembly is slow | daily.dev
og:description: Compiling Rust to WebAssembly with debug info enabled (debug = 2) can be dramatically slower than release builds without it, sometimes by 40x or more. The root...
og:url: https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2
og:image: https://api.daily.dev/og/posts/qsbck0KU2.png
og:image:alt: Why compiling Rust to WebAssembly is slow
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why compiling Rust to WebAssembly is slow

**[Lobsters](https://daily.dev/sources/lobsters)** · 11 min read · 1 upvotes · 0 comments

## Summary

Compiling Rust to WebAssembly with debug info enabled (debug = 2) can be dramatically slower than release builds without it, sometimes by 40x or more. The root cause is a known LLVM bug affecting the WebAssembly backend's Register Stackify pass, which handles DBG_VALUE debug records inefficiently, turning what should be linear work into quadratic scans. A 40-line reproducer takes 50 seconds to build with debug info versus 1.5 seconds without. An existing LLVM fix for clang doesn't fully solve the Rust case because copies made during register stackification can leave debug records pointing to registers in ways a forward-only scan can't detect. A proposed three-part patch (making the scan bidirectional, skipping unnecessary position-number lookups, and using cheaper instruction-ordering checks) cuts the reproducer's build time from 50.56s to 2.72s and speeds up real crates like ed25519-compact by up to 39x, with no runtime behavior changes. Even after Rust updates its LLVM fork to the upstream clang fix, the author's patch still performs substantially better.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://00f.net/2026/08/19/why-compiling-rust-to-webassembly-is-slow>

## Questions this post answers

### Why does compiling Rust to WebAssembly with debug info enabled take so much longer than without it?

It is caused by a quadratic-time bug in LLVM's WebAssembly Register Stackify pass, which repeatedly rescans a growing list of DBG_VALUE debug records every time it moves a value onto the operand stack. With debug = 2, heavy inlining can create hundreds of thousands of these records in one function, turning a 1.5-second build into a 50-second one on a small reproducer. Only debug = 2 is affected; debug = 1 is not.

_Track compiler and toolchain gotchas like this Rust-to-WebAssembly slowdown on daily.dev before they blindside a build pipeline._

### Does the existing LLVM fix for the DBG_VALUE clang bug (issue 168326) also fix slow Rust WebAssembly debug builds?

Only partially. The upstream fix counts DBG_VALUE uses via a use list and stops a forward scan once all uses are found, but Register Stackify can repoint an existing DBG_VALUE at a register defined later in the block without moving the record itself, so a forward-only scan can never reach it and the counter never reaches zero, leaving most of the slowdown intact for Rust.

_Developers weighing an LLVM upgrade against a targeted patch for wasm build times can follow fixes like this on daily.dev._

### How much faster does compiling the ed25519-compact Rust crate to WebAssembly get with the proposed LLVM Register Stackify patch?

Code generation for ed25519-compact 2.4.0 dropped from 1884.9 seconds (about 31 minutes) to 48.2 seconds, a roughly 39x speedup, with the Register Stackify pass itself falling from 1683.4s to 23.2s. The three-part patch adds a backward scan alongside the forward one, avoids building unneeded hash keys, and skips useless position-number lookups for debug records, with no change to generated code behavior.

_Rust and WebAssembly developers chasing slow release builds can watch patches like this compiler fix on daily.dev._

## Similar posts on daily.dev

- [How to speed up the Rust compiler in July 2026](https://daily.dev/posts/how-to-speed-up-the-rust-compiler-in-july-2026-rsrjhr5xg) · Lobsters · 2 upvotes · 0 comments
- [I made a build visualizer to understand Bun’s compile times](https://daily.dev/posts/i-made-a-build-visualizer-to-understand-bun-s-compile-times-hp1lyuwkm) · Lobsters · 1 upvotes · 0 comments
- [When O3 is 2x slower than O2](https://daily.dev/posts/when-o3-is-2x-slower-than-o2-dbidslo2u) · Hacker News · 2 upvotes · 1 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#rust](https://daily.dev/tags/rust), [#webassembly](https://daily.dev/tags/webassembly), [#compiler-optimization](https://daily.dev/tags/compiler-optimization)

[View this post on daily.dev](https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why compiling Rust to WebAssembly is slow","url":"https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2"},"datePublished":"2026-08-20T20:10:29.660Z","dateModified":"2026-09-13T19:08:25.816Z","description":"Compiling Rust to WebAssembly with debug info enabled (debug = 2) can be dramatically slower than release builds without it, sometimes by 40x or more. The root...","image":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","thumbnailUrl":"https://media.daily.dev/image/upload/s--ZrL_HSsR--/f_auto/v1722860399/public/Placeholder%2006","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,rust,webassembly,compiler-optimization","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Why compiling Rust to WebAssembly is slow"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/why-compiling-rust-to-webassembly-is-slow-qsbck0ku2#faq","mainEntity":[{"@type":"Question","name":"Why does compiling Rust to WebAssembly with debug info enabled take so much longer than without it?","acceptedAnswer":{"@type":"Answer","text":"It is caused by a quadratic-time bug in LLVM's WebAssembly Register Stackify pass, which repeatedly rescans a growing list of DBG_VALUE debug records every time it moves a value onto the operand stack. With debug = 2, heavy inlining can create hundreds of thousands of these records in one function, turning a 1.5-second build into a 50-second one on a small reproducer. Only debug = 2 is affected; debug = 1 is not. Track compiler and toolchain gotchas like this Rust-to-WebAssembly slowdown on daily.dev before they blindside a build pipeline."}},{"@type":"Question","name":"Does the existing LLVM fix for the DBG_VALUE clang bug (issue 168326) also fix slow Rust WebAssembly debug builds?","acceptedAnswer":{"@type":"Answer","text":"Only partially. The upstream fix counts DBG_VALUE uses via a use list and stops a forward scan once all uses are found, but Register Stackify can repoint an existing DBG_VALUE at a register defined later in the block without moving the record itself, so a forward-only scan can never reach it and the counter never reaches zero, leaving most of the slowdown intact for Rust. Developers weighing an LLVM upgrade against a targeted patch for wasm build times can follow fixes like this on daily.dev."}},{"@type":"Question","name":"How much faster does compiling the ed25519-compact Rust crate to WebAssembly get with the proposed LLVM Register Stackify patch?","acceptedAnswer":{"@type":"Answer","text":"Code generation for ed25519-compact 2.4.0 dropped from 1884.9 seconds (about 31 minutes) to 48.2 seconds, a roughly 39x speedup, with the Register Stackify pass itself falling from 1683.4s to 23.2s. The three-part patch adds a backward scan alongside the forward one, avoids building unneeded hash keys, and skips useless position-number lookups for debug records, with no change to generated code behavior. Rust and WebAssembly developers chasing slow release builds can watch patches like this compiler fix on daily.dev."}}]}
```

