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

编译rust-fractal-gui遇llvm_asm宏未找到错误求助

问题解决:parking_lot v0.11.2 编译报错(llvm_asm 未找到/未知特性)

问题原因

你使用的Rust nightly 1.64.0(2022-07-14)中,llvm_asm宏及对应的llvm_asm特性已被移除,替换为标准化的asm!宏。而parking_lot v0.11.2仍依赖旧的llvm_asm实现,导致版本不兼容引发编译失败。

解决方案

方案1:升级parking_lot到兼容版本

parking_lot v0.12及以上版本已适配asm!宏,可直接升级依赖:

  • 执行命令:cargo update parking_lot
  • 或手动在Cargo.toml中指定版本:
[dependencies]
parking_lot = "0.12"

方案2:禁用parking_lot的nightly特性

如果无法升级依赖,可强制关闭parking_lot的nightly特性,避免触发旧的汇编宏:
在项目的Cargo.toml中添加对应配置:

# 若为直接依赖
[dependencies]
parking_lot = { version = "0.11.2", default-features = false }

# 若为间接依赖,使用patch覆盖
[patch.crates-io]
parking_lot = { version = "0.11.2", default-features = false }

方案3:回退到支持llvm_asm的旧nightly版本

如果必须使用parking_lot v0.11.2且保留nightly特性,可回退到2022年6月之前的nightly版本(此时llvm_asm仍未被移除):

rustup override set nightly-2022-06-01

报错日志

$ cargo build --release

...

Compiling parking_lot v0.11.2
error: cannot find macro `llvm_asm` in this scope
  --> /home/riley/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.11.2/src/elision.rs:77:13
   |
77 |             llvm_asm!("xacquire; lock; cmpxchgq $2, $1"
   |             ^^^^^^^^

error: cannot find macro `llvm_asm` in this scope
   --> /home/riley/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.11.2/src/elision.rs:108:13
    |
108 |             llvm_asm!("xrelease; lock; xaddq $2, $1"
    |             ^^^^^^^^

error[E0635]: unknown feature `llvm_asm`
  --> /home/riley/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.11.2/src/lib.rs:14:42
   |
14 | #![cfg_attr(feature = "nightly", feature(llvm_asm))]
   |                                          ^^^^^^^^

For more information about this error, try `rustc --explain E0635`.
error: could not compile `parking_lot` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...

rustup show 输出

rustup home:  /home/riley/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
1.48.0-x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (directory override for '/home/riley/projects/rust-fractal-gui')
rustc 1.64.0-nightly (c2f428d2f 2022-07-14)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.25 20:24:23