Skip to content

build-std + link-dead-code=y cannot build custom target without sse #123494

@jzbor

Description

@jzbor

Hi,
I am trying to compile my Rust OS kernel for x86_64. As I don't want to implement SSE support for multiple reasons, I chose the +soft-float feature. This does not seem to work with build-std:

   Compiling compiler_builtins v0.1.108
   Compiling core v0.0.0 (/home/jzbor/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling mosk v0.1.0 (/home/jzbor/Programming/Rust/mosk)
   Compiling rustc-std-workspace-core v1.99.0 (/home/jzbor/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
rustc-LLVM ERROR: Do not know how to split this operator's operand!

error: could not compile `core` (lib)
warning: build failed, waiting for other jobs to finish...

For my features I currently use

"features": "-mmx,-sse,+soft-float"

I have also tried adding -sse2 and -avx with pretty much the same result.

Enabling SSE in the custom target works, but of course results in errors at runtime, as I don't actually implement SSE support.

I have found several related issues, but none of them seem to track this specific problem:
#63466 #92760 #62729

#63466 seems to also be referenced by official documentation as known issue, although it is closed and does not seem to track actually fixing the issue.

I have tried the workaround suggested in #62729 without success.

This is my full custom target:

{
	"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"
}

EDIT: Cargo version and rust version

cargo 1.79.0-nightly (499a61ce7 2024-03-26)
rustc 1.79.0-nightly (c9f8f3438 2024-03-27)

EDIT2: I found out this only happens with -C link-dead-code=y, which I require in order to link assembly code. If this option is not set the linker will remove some of the assembly sections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable Cargo option: Compile the standard library yourself.A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.O-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions