Skip to content

[ICE]: Compiler error with faulty JSON target (nightly) #157401

@will-maclean

Description

@will-maclean

I'm playing with compiling for custom JSON targets and got the following compiler error, which requested that I make a bug report here. I'm just playing with fields in the JSON file so I fully expect the values themselves to be incorrect or even nonsensical.

Code

Cargo.toml

[package]
name = "my_project"
version = "0.1.0"
edition = "2024"

[dependencies]
bootloader = "0.9.0"
volatile = "0.2.6"
spin = "0.5.2"

[dependencies.lazy_static]
version = "1.0"
features = ["spin_no_std"]

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

[[bin]]
name = "my_project"
test = false
bench = false

.cargo/config.toml

[unstable]
json-target-spec = true
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]

[build]
target = "riscv_blog_os.json"

[target.'cfg(target_os = "none")']
runner = "bootimage runner"

riscv_blog_os.json

{
    "llvm-target": "riscv-unknown-none",
    "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
    "arch": "riscv",
    "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"
}

Meta

rustc +nightly --version --verbose:

rustc 1.98.0-nightly (d595fce01 2026-06-02)
binary: rustc
commit-hash: d595fce01043347bf7f80e85b76dcc41b59a3e6e
commit-date: 2026-06-02
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6

Error output

RUST_BACKTRACE=1 cargo +nightly build

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/willmaclean/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --target /home/willmaclean/code/billbox/riscv_blog_os.json -Zunstable-options --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 101)
  --- stderr
  error: internal compiler error: the following error was constructed but not emitted

  error: could not create LLVM TargetMachine for triple: riscv-unknown-none


  thread 'rustc' (6909) panicked at /rustc-dev/d595fce01043347bf7f80e85b76dcc41b59a3e6e/compiler/rustc_errors/src/diagnostic.rs:1345:17:
  error was constructed but not emitted
  stack backtrace:
     0:     0x7f8899ca2979 - <<std[1366fca4f297d3fd]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[87bef54ee67ce5c6]::fmt::Display>::fmt
     1:     0x7f889a42a388 - core[87bef54ee67ce5c6]::fmt::write
     2:     0x7f8899cb9476 - <std[1366fca4f297d3fd]::sys::stdio::unix::Stderr as std[1366fca4f297d3fd]::io::Write>::write_fmt
     3:     0x7f8899c78bae - std[1366fca4f297d3fd]::panicking::default_hook::{closure#0}
     4:     0x7f8899c962b3 - std[1366fca4f297d3fd]::panicking::default_hook
     5:     0x7f8898a88341 - std[1366fca4f297d3fd]::panicking::update_hook::<alloc[f46483d6ef71ba19]::boxed::Box<rustc_driver_impl[ae9bb86051dc8331]::install_ice_hook::{closure#1}>>::{closure#0}
     6:     0x7f8899c96592 - std[1366fca4f297d3fd]::panicking::panic_with_hook
     7:     0x7f8899c78ca4 - std[1366fca4f297d3fd]::panicking::panic_handler::{closure#0}
     8:     0x7f8899c6d199 - std[1366fca4f297d3fd]::sys::backtrace::__rust_end_short_backtrace::<std[1366fca4f297d3fd]::panicking::panic_handler::{closure#0}, !>
     9:     0x7f8899c7a6dd - __rustc[86d9947c1805072e]::rust_begin_unwind
    10:     0x7f889674678c - core[87bef54ee67ce5c6]::panicking::panic_fmt
    11:     0x7f889882fc24 - core[87bef54ee67ce5c6]::ptr::drop_glue::<rustc_errors[b8284e369e60ce83]::diagnostic::Diag<rustc_errors[b8284e369e60ce83]::diagnostic::FatalAbort>>
    12:     0x7f889887cd4f - <rustc_codegen_llvm[dc2a80d68158b1bf]::errors::ParseTargetMachineConfig as rustc_errors[b8284e369e60ce83]::diagnostic::Diagnostic<rustc_errors[b8284e369e60ce83]::diagnostic::FatalAbort>>::into_diag
    13:     0x7f889b424e85 - rustc_codegen_llvm[dc2a80d68158b1bf]::back::write::target_machine_factory::{closure#0}
    14:     0x7f889b424b1e - rustc_codegen_llvm[dc2a80d68158b1bf]::back::write::create_informational_target_machine
    15:     0x7f889b422b33 - <rustc_codegen_llvm[dc2a80d68158b1bf]::LlvmCodegenBackend as rustc_codegen_ssa[e6558756312ba2fa]::traits::backend::CodegenBackend>::target_config
    16:     0x7f889b5833a5 - rustc_interface[f6433d282e9a1ed1]::util::add_configuration
    17:     0x7f889b5ea7dd - rustc_interface[f6433d282e9a1ed1]::interface::run_compiler::<(), rustc_driver_impl[ae9bb86051dc8331]::run_compiler::{closure#0}>::{closure#1}
    18:     0x7f889b5915ba - std[1366fca4f297d3fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f6433d282e9a1ed1]::util::run_in_thread_with_globals<rustc_interface[f6433d282e9a1ed1]::util::run_in_thread_pool_with_globals<rustc_interface[f6433d282e9a1ed1]::interface::run_compiler<(), rustc_driver_impl[ae9bb86051dc8331]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
    19:     0x7f889b591cad - <std[1366fca4f297d3fd]::thread::lifecycle::spawn_unchecked<rustc_interface[f6433d282e9a1ed1]::util::run_in_thread_with_globals<rustc_interface[f6433d282e9a1ed1]::util::run_in_thread_pool_with_globals<rustc_interface[f6433d282e9a1ed1]::interface::run_compiler<(), rustc_driver_impl[ae9bb86051dc8331]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[87bef54ee67ce5c6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
    20:     0x7f889b592aac - <std[1366fca4f297d3fd]::sys::thread::unix::Thread>::new::thread_start
    21:     0x7f8894c7f3c4 - start_thread
    22:     0x7f8894d0256c - __clone3
    23:                0x0 - <unknown>

  error: the compiler unexpectedly panicked. This is a bug

  note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

  note: please make sure that you have updated to the latest nightly

  note: please attach the file at `/home/willmaclean/code/billbox/rustc-ice-2026-06-03T21_03_17-6907.txt` to your bug report

  note: rustc 1.98.0-nightly (d595fce01 2026-06-02) running on x86_64-unknown-linux-gnu

  note: compiler flags: -Z unstable-options --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro

  query stack during panic:
  end of query stack

This is my first time interacting with the rustc community - if there's anything this bug report is missing, please let me know and I'll be happy to provide.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions