惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
S
Security Affairs
T
Tor Project blog
T
Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
A
Arctic Wolf
K
Kaspersky official blog
O
OpenAI News
Spread Privacy
Spread Privacy
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
Simon Willison's Weblog
Simon Willison's Weblog
雷峰网
雷峰网
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
量子位
博客园_首页
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
V2EX - 技术
V2EX - 技术
S
Schneier on Security
博客园 - 叶小钗
Attack and Defense Labs
Attack and Defense Labs
AI
AI
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 【当耐特】
Jina AI
Jina AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
V
V2EX
S
SegmentFault 最新的问题
V
Visual Studio Blog
PCI Perspectives
PCI Perspectives
Microsoft Security Blog
Microsoft Security Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Why Pure Rust WASM Is Harder Than It Looks
kent-tokyo · 2026-05-21 · via DEV Community

Most Rust developers expect the pitch to hold: compile to WebAssembly, ship to the browser, no C required. Add the wasm32-unknown-unknown target, run wasm-pack build, and you're done.

Then you try it on a real project. Four traps, none of them in the getting-started docs: a deprecated allocator with a memory leak, hidden C dependencies scattered through the ecosystem, a random number crate that silently misbehaves, and bundle sizes that balloon from Emscripten glue.


The Problem with "Just Use Rust"

The core appeal of Rust for WASM is real: no garbage collector, predictable memory, and — in theory — no need for the C/C++ toolchain that browser WASM has historically required.

But the Rust crate ecosystem has C dependencies scattered throughout it, often invisible until compile time. A project that builds fine on Linux will fail on wasm32-unknown-unknown because three levels down in the dependency tree, something links to libz, openssl, or a system RNG.

When I built chem-wasm-lens — a molecular analysis library for the browser — I needed to stay completely C-free. The alternative, RDKit (the standard C++ cheminformatics toolkit), compiles to a ~40MB WASM bundle via Emscripten. My target was under 200KB gzipped. Getting there meant systematically hunting down every C dependency.


The Allocator Story

Every WASM tutorial from a few years ago recommended wee_alloc: a tiny allocator that shrank bundle size and was the default in wasm-pack new.

wee_alloc was archived in August 2025. It has a known memory leak and is no longer maintained. If you have it in an existing project, remove it:

# Cargo.toml — remove this line
wee_alloc = "0.4"

Enter fullscreen mode Exit fullscreen mode

// lib.rs — remove these lines
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

Enter fullscreen mode Exit fullscreen mode

The current state of WASM allocators:

  • Default (dlmalloc): Rust's wasm32-unknown-unknown target uses dlmalloc as the default global allocator. It's a pure Rust implementation — no C, no system calls. For most browser WASM projects, this is fine.
  • lol_alloc: Written as a wee_alloc replacement. Smaller than dlmalloc, but the author documents it as not production-ready.
  • talc: A newer allocator, benchmarked as smaller and faster than dlmalloc. Worth watching for size-critical projects.

For most projects: just use the default and move on. The allocator is no longer the interesting problem. The interesting problem is transitive C deps.


The Hidden C Dependency Tree

The most common wasm-pack build failure isn't your code — it's a crate three levels deep that silently links to C. The build error typically looks like:

error: failed to run custom build command for `openssl-sys v0.9.x`
  ...
  Could not find directory of OpenSSL installation.

Enter fullscreen mode Exit fullscreen mode

Or for ring:

error: failed to run custom build command for `ring v0.17.x`
  ...
  the target `wasm32-unknown-unknown` is not supported

Enter fullscreen mode Exit fullscreen mode

-sys crates are the signal. Any crate with a -sys suffix wraps a native library:

  • openssl-sys — OpenSSL
  • libz-sys — zlib
  • bzip2-sys — libbz2
  • libsqlite3-sys — SQLite
  • ring — cryptography (C code for performance-critical paths)

You probably didn't add any of these directly. reqwest pulls in openssl-sys by default. flate2 uses libz-sys by default. sqlx brings in libsqlite3-sys.

How to detect them:

cargo tree --target wasm32-unknown-unknown | grep "\-sys"

Enter fullscreen mode Exit fullscreen mode

Example output from a project using reqwest and flate2:

├── flate2 v1.0.x
│   └── libz-sys v1.1.x (*)       ← C dependency
├── reqwest v0.12.x
│   └── openssl-sys v0.9.x (*)    ← C dependency

Enter fullscreen mode Exit fullscreen mode

Any -sys crate in the output is a potential blocker.

Common replacements:

C-dependent crate Pure Rust alternative
openssl / openssl-sys rustls
flate2 (default features) flate2 with default-features = false, features = ["miniz"]
image (old versions) image 0.25+ (mostly pure Rust)
reqwest with system TLS reqwest with default-features = false, features = ["rustls-tls"]

Here's what a typical fix looks like in Cargo.toml:

[dependencies]
# Before (pulls in openssl-sys):
# reqwest = "0.12"

# After (pure Rust TLS):
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }

# Before (uses libz-sys by default):
# flate2 = "1.0"

# After (pure Rust miniz backend):
flate2 = { version = "1.0", default-features = false, features = ["miniz"] }

Enter fullscreen mode Exit fullscreen mode

The ring situation deserves a specific note. ring powers most TLS stacks in the Rust ecosystem, and it contains C code for performance-critical paths. On wasm32-unknown-unknown, it fails to compile.

For browser WASM, this is usually not a problem — the browser's fetch API handles TLS transparently, so Rust code never touches it. For non-browser WASM runtimes (WASI, Wasmtime), look at RustCrypto crates, which provide pure Rust cryptographic primitives, or aws-lc-rs, which has better WASM support than ring.


The getrandom Footgun

Many crates need random numbers — UUID generation, HashMap initialization, cryptographic primitives. They all end up depending on getrandom.

On wasm32-unknown-unknown, getrandom doesn't know where it is. The target name alone says nothing about whether you're in a browser, a WASI runtime, or a bare-metal environment. Without explicit configuration, the build fails or panics at runtime, depending on the version.

First, find which version is in your tree:

cargo tree | grep getrandom

Enter fullscreen mode Exit fullscreen mode

The fix depends on the version:

getrandom 0.2.x — add the js feature:

# Cargo.toml
[dependencies]
getrandom = { version = "0.2", features = ["js"] }

Enter fullscreen mode Exit fullscreen mode

getrandom 0.3.x — feature flag plus a backend declaration:

In 0.3.x, getrandom introduced a "backend" model that separates feature flags from backend selection. Both are required:

# Cargo.toml
[dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }

Enter fullscreen mode Exit fullscreen mode

# .cargo/config.toml
[target.wasm32-unknown-unknown]
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]

Enter fullscreen mode Exit fullscreen mode

The transitive dependency trap. You can't set feature flags for indirect dependencies directly. If uuid depends on getrandom and you don't use getrandom yourself, you still need to declare it explicitly so Cargo's feature unification propagates the flag:

[dependencies]
uuid = { version = "1", features = ["v4"] }
# Explicitly declare getrandom to force the js feature through the tree
getrandom = { version = "0.2", features = ["js"] }

Enter fullscreen mode Exit fullscreen mode

The getrandom docs also recommend against enabling js/wasm_js in libraries — it breaks non-browser WASM builds. For a browser-only library like chem-wasm-lens, enabling it unconditionally is the right call, but the documentation buries this distinction.


Bundle Size

This is where C dependencies have their most visible cost.

C libraries compiled to WASM via Emscripten carry significant overhead: libc, libc++, a malloc implementation, and Emscripten runtime glue — regardless of how much of it you actually use. Tree shaking doesn't cross the FFI boundary. The result:

  • RDKit.js: ~40MB (Emscripten-compiled C++ cheminformatics)
  • OpenSSL compiled to WASM: ~1–2MB just for the crypto primitives

Pure Rust compiles lean. chem-wasm-lens ships at 411KB uncompressed, ~200KB gzipped — and that includes SMILES parsing, 2D coordinate generation, SVG rendering, ECFP4 fingerprint similarity, and PDB parsing. The size difference isn't magic; it's the absence of Emscripten glue, Rust's dead code elimination working cleanly across #[wasm_bindgen] exports, and wasm-opt running automatically on release builds.

Check your own binary size after building:

wasm-pack build --release
ls -lh pkg/*.wasm

Enter fullscreen mode Exit fullscreen mode

If the .wasm is unexpectedly large, profile it with Twiggy to see what's taking up space:

cargo install twiggy
twiggy top pkg/your_crate_bg.wasm

Enter fullscreen mode Exit fullscreen mode


The Current Ecosystem State

Where things stand, mid-2025:

Task Pure Rust option Status
Memory allocation dlmalloc (default) Solid
Compression flate2 with default-features = false, features = ["miniz"] Solid
Serialization serde + serde-wasm-bindgen Solid
HTTP (browser) gloo-net or JS fetch via web-sys Solid
Random numbers getrandom with js/wasm_js feature Works, requires explicit config
Cryptographic primitives RustCrypto crates Solid for most algorithms
TLS (non-browser WASM) Gap — ring doesn't build cleanly; aws-lc-rs has better WASM support
Image processing image 0.25+ Mostly pure Rust; some format decoders still use C
Date/time web-time or js-sys::Date Solid

Practical Checklist

Before shipping a Rust WASM project:

  1. Audit with cargo tree
   cargo tree --target wasm32-unknown-unknown | grep "\-sys"

Enter fullscreen mode Exit fullscreen mode

Any -sys crate is a potential blocker.

  1. Remove wee_alloc — archived in August 2025, has a memory leak. The default dlmalloc is fine.

  2. Handle getrandom explicitly — run cargo tree | grep getrandom to find the version, then add it explicitly to [dependencies] with the right feature flag, even if you don't use it directly.

  3. Replace system TLS — swap openssl/openssl-sys for rustls, or use reqwest with default-features = false, features = ["rustls-tls"].

  4. Fix flate2 — use default-features = false, features = ["miniz"] to disable the libz-sys backend.

  5. Build with --releasewasm-pack build --release runs wasm-opt automatically. Debug builds skip optimization and are typically 3–5x larger.


Closing Thought

The Rust-to-WASM path is genuinely good, and it's improving. The C ABI for wasm32-unknown-unknown is being standardized (Rust blog, April 2025), wee_alloc's archival simplified the allocator story, and wasm-pack keeps getting better.

Most popular Rust crates predate WASM as a real target, and they picked up C dependencies along the way. The audit is tedious but a one-time fix — once you know which -sys crates to watch for and what replaces them, it doesn't keep coming back.


I hit all four of these problems building chem-wasm-lens, a pure Rust + WASM molecular analysis library for the browser. The table above is what I found trying to go from a ~40MB Emscripten-compiled baseline down to ~200KB gzipped.