Skip to content

Post 2: error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enabled in target spec.Β #1387

@dumbpandabear

Description

@dumbpandabear

Problem

I'm up to post 2 - A Minimal Rust Kernel and it seems the latest nightly rust build nightly-2025-02-04 is a breaking change, where the previous nightly-2025-02-03 build was working.

After a cargo build, I get the error:
"error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enable
d in target spec. Run rustc --print target-list for a list of built-in targets"

My rustc version:
Image

After some digging, it looks like a similar issue was brought up in the rust repo here

Solution

To fix the build/compilation error of the Rust OS crate, adding "rustc-abi": "x86-softfloat" to the end of the x86_64-blog_os.json file should fix the issue.

But the same issue arises when trying to run the kernel with cargo run which uses the bootimage runner that first builds the bootloader dependency. Due to the same target spec configuration issue in the crate, you can fix this issue the same way locally by modifying the source code of the bootloader crate and adding "rustc-abi": "x86-softfloat" to the end of the x86_64-bootloader.json file.

I found the location of my x86_64-bootloader.json file in ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.29/x86_64-bootloader.json.

From what I understand, rust now requires an explicit declaration of the intended ABI for the "soft-float" spec.

A working x86_64-blog_os.json target configuration in the Rust OS crate with this change:

{
    "llvm-target": "x86_64-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": "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",
    "rustc-abi": "x86-softfloat"
}

A working change to the ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.29/x86_64-bootloader.json:

{
    "llvm-target": "x86_64-unknown-none-gnu",
    "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",
    "linker-flavor": "ld.lld",
    "linker": "rust-lld",
    "pre-link-args": {
        "ld.lld": [
            "--script=linker.ld",
            "--gc-sections"
        ]
    },
    "target-endian": "little",
    "target-pointer-width": "64",
    "target-c-int-width": "32",
    "arch": "x86_64",
    "os": "none",
    "features": "-mmx,-sse,+soft-float",
    "disable-redzone": true,
    "panic-strategy": "abort",
    "executables": true,
    "relocation-model": "static",
    "rustc-abi": "x86-softfloat"
}

I assume a change to the configurations in the rust OS blog+ rust OS code repo + bootloader repo will be needed? I'd love to work on a PR if these observations are correct. Hope this helps other people running across the same issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions