You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决WSL中出现的‘ld terminated with signal 9 [Killed]’错误?

WSL编译py-polars时链接器被终止的解决方法

问题背景

环境信息

  • Python 3.11
  • rustc 1.74.0-nightly
  • 运行环境:Windows 11 下的 WSL(Ubuntu 20.04)

触发操作

git clone git@github.com:<username>/polars.git
cd polars
rustup toolchain install nightly --component miri
cd py-polars
make test

核心错误日志

Compiling py-polars v0.19.6 (/home/user/projects/polars/py-polars)
error: linking with `cc` failed: exit status: 1
...
  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.

error: could not compile `py-polars` (lib) due to previous error
💥 maturin failed
...
make: *** [Makefile:23: build] Error 1

解决步骤

1. 扩容WSL内存

链接器被杀死(signal 9)通常是内存不足导致,修改WSL配置提升内存:

  • 在Windows用户目录(C:\Users\<你的用户名>)创建/编辑.wslconfig:
[wsl2]
memory=8GB
swap=4GB
  • 执行wsl --shutdown重启WSL生效。

2. 启用Cargo增量编译

降低单次编译的内存占用,编辑py-polars/Cargo.toml的[profile.dev]段:

[profile.dev]
incremental = true
# 保留原有配置,新增上述行

3. 限制并行编译任务数

减少同时编译的任务量,缓解内存压力:

export CARGO_BUILD_JOBS=2
make test

4. 补全系统编译依赖

确保Ubuntu环境的编译工具完整:

sudo apt update && sudo apt install build-essential libssl-dev pkg-config

内容的提问来源于stack exchange,提问作者OES

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 17:46:04