Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EricLi-Dev opened this issue Feb 5, 2025 · 3 comments

Comments

@EricLi-Dev
Copy link

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!

@EricLi-Dev EricLi-Dev changed the title error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enable d in target spec. Post 2: error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enable d in target spec. Feb 5, 2025
@EricLi-Dev EricLi-Dev changed the title Post 2: error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enable d in target spec. Post 2: error: Error loading target specification: target feature soft-float is incompatible with the ABI but gets enabled in target spec. Feb 5, 2025
@Hello-world150
Copy link

I have some questions, assuming this PR is going to be submitted, which version of bootloader should the code part about bootloader be submitted to? The current blog uses the bootloader version 0.9, and there is an updated version now. Does crate.io allow modification of the published version?

@bjorn3
Copy link
Contributor

bjorn3 commented Feb 7, 2025

It is still possible to publish an update for the 0.9.x series even though 0.11.x has already been released. You can't modify an existing version, but you can upload a new semver compatible one.

@Hello-world150
Copy link

It is still possible to publish an update for the 0.9.x series even though 0.11.x has already been released. You can't modify an existing version, but you can upload a new semver compatible one.

Thank you for answering my confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants