简体   繁体   English

编译 rust-src 时的未知功能“llvm_asm”

[英]unknown feature `llvm_asm` when compile rust-src

I tried to compile rust-src using cargo xbuild but get this error:我尝试使用 cargo xbuild 编译 rust-src 但收到此错误:

error[E0635]: unknown feature `llvm_asm`
-> .cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.28/src/lib.rs:3:12
3 | #![feature(llvm_asm)]

How can I fix this error?我该如何解决这个错误? It's seem like xbuild tries to compile the new rust-src with an old rustc.似乎 xbuild 试图用旧的 rustc 编译新的 rust-src。 I want it to also use the old rust-src.我希望它也使用旧的 rust-src。

I can't update to a newer rustc version as it results in lots of "R_x86_32 relocation" errors, so I would prefer to use the 2020-03-24 version.我无法更新到较新的 rustc 版本,因为它会导致大量“R_x86_32 重定位”错误,因此我更愿意使用 2020-03-24 版本。

Minimal example最小的例子

command命令

cargo new --bin test

rustup component add rust-src

cargo install cargo-xbuild

cd test

ls test
Cargo.toml  rust-toolchain  src  x86_64-unknown-none.json

rust-toolchain生锈工具链

nightly-2020-03-24

x86_64-unknown-none.json x86_64-unknown-none.json

{
  "llvm-target": "x86_64-unknown-none",
  "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
  "arch": "x86_64",
  "target-endian": "little",
  "target-pointer-width": "64",
  "target-c-int-width": "32",
  "os": "none",
  "executables": true,
  "linker-flavor": "ld.lld",
  "linker": "rust-lld",
  "panic-strategy": "abort",
  "disable-redzone": true,
  "features": "-mmx,-sse,+soft-float"
}

src/main.rs src/main.rs

#![no_std]                // don't link the Rust standard library
#![no_main]               // disable all Rust-level entry points
#![allow(non_snake_case)] // disable non snake case name warning

use core::panic::PanicInfo;

#[no_mangle]
pub extern "C" fn _start() -> ! {
    loop {}
}

#[panic_handler]
pub fn MyPacnicHandler(_panicInfo: &PanicInfo) -> ! {
    loop {}
}

compile编译

cargo xbuild --target x86_64-unknown-none

rustc --version rustc --版本

rustc 1.44.0-nightly (1edd389cc 2020-03-23)

This is a bug in cargo-xbuild .这是cargo-xbuild中的一个错误。 Basically, cargo xbuild unconditionally fetches the latest compiler_builtins .基本上, cargo xbuild无条件地获取最新的compiler_builtins

A patch has been merged, but is not yet in the latest crates.io release.补丁已合并,但尚未在最新的crates.io版本中。 See this PR: https://github.com/rust-osdev/cargo-xbuild/pull/75/commits/eede1a1d4c08064763f1943c0920de2270260b33请参阅此 PR: https://github.com/rust-osdev/cargo-xbuild/pull/75/commits/eede1a1d4c08064763f1943c0920de2270260b33

Update your rust version by rustup update , which works for me.通过rustup update更新您的 rust 版本,这对我有用。

The reason may be the feature rename in new version: https://github.com/rust-lang/rust/pull/71007原因可能是新版本中的功能重命名: https://github.com/rust-lang/rust/pull/71007

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何安装旧版本的 rust-src? - How to install old version of rust-src? 货物构建失败:在此 scope 中找不到宏“llvm_asm” - Cargo build failed: could not find macro `llvm_asm` in this scope 如何在 Godbolt 中禁用 LLVM 优化以防止生锈(用于 asm 教育目的) - How to disable LLVM optimisations for rust in Godbolt (for asm education purposes) 如何将 Rust 编译为包含依赖项的 LLVM 位码? - How to compile Rust to LLVM bitcode including dependencies? 尝试在 Rust 中打印字符串内容时,编译时的大小未知 - Unknown size at compile time when trying to print string contents in Rust 无法使用 postgres 功能编译 Rust SQLx - Unable to compile Rust SQLx with postgres feature 如何编译Rust库以定位asm.js? - How can you compile a Rust library to target asm.js? 使用Rust内联asm设置非默认舍入模式不受LLVM优化器的限制? - Setting a non-default rounding mode with Rust inline asm isn't respected by the LLVM optimizer? 使用内联汇编读取 Rust 中 ebx 寄存器的值(“rbx 由 LLVM 内部使用,不能用作内联 asm 的操作数”) - Read value of ebx register in Rust with inline assembly ("rbx is used internally by LLVM and cannot be used as an operand for inline asm") 如何通过 Rust 中的模式匹配将编译时未知的 object 保存到变量中? - How to save an object unknown at compile time to a variable by pattern matching in Rust?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM