Skip to content

Xous build failure due to naked_asm changes #134403

Closed

Description

@xobs

Code

I tried this code:

$ RUST_COMPILER_RT_ROOT="$(pwd)/src/llvm-project/compiler-rt" RUSTFLAGS="-Zforce-unstable-if-unmarked=yes" cargo +nightly build --target riscv32imac-unknown-xous-elf -Zbinary-dep-depinfo --release --features "panic-unwind" --manifest-path "library/sysroot/Cargo.toml"

I expected to see this happen: Rust should build libstd for Xous

Instead, this happened: Rust errored out with could not compile 'unwinding':

   Compiling unwinding v0.2.4
   Compiling unwind v0.0.0 (/opt/Xous/rust-nightly/rust/library/unwind)
   Compiling panic_unwind v0.0.0 (/opt/Xous/rust-nightly/rust/library/panic_unwind)
error: <inline asm>:11:1: this directive must appear between .cfi_startproc and .cfi_endproc directives
.cfi_def_cfa_offset 0x90
^

error: could not compile `unwinding` (lib)

Version it worked on

It most recently worked on: Rust nightly 2024-12-11

Version with regression

rustc --version --verbose:

rustc 1.85.0-nightly (6d9f6ae36 2024-12-16)
binary: rustc
commit-hash: 6d9f6ae36ae1299d6126ba40c15191f7aa3b79d8
commit-date: 2024-12-16
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

More information

I have filed an issue in unwinding. This error likely appeared as a result of #128004. However, I am unable to merge PR 41 because CI is failing due to issue #80608.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Dec 17, 2024
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    and removed
    regression-untriagedUntriaged performance or correctness regression.
    on Dec 17, 2024
  3. xobs commented on Dec 17, 2024

    @xobs
    ContributorAuthor

    I've created this Issue because Xous is now unable to build. There are several factors at play:

  4. workingjubilee commented on Dec 17, 2024

    @workingjubilee
    Member

    unwinding depends on #[cfg(target_feature)] which doesn't work in --release mode on RISC-V

    hm. that should not be the case, to my knowledge? can you elaborate?

  5. xobs commented on Dec 17, 2024

    @xobs
    ContributorAuthor

    Sure.

    #![feature(naked_functions)]
    
    #[naked]
    pub extern "C-unwind" fn example() {
        #[cfg(target_feature = "d")]
        unsafe {
            core::arch::naked_asm!("fsd fs0, 0x140(sp)");
        }
    }
    

    If you build this with cargo +nightly build --target riscv64gc-unknown-linux-gnu --release it fails with the following error:

    error: <inline asm>:6:1: instruction requires the following: 'D' (Double-Precision Floating-Point)
    fsd fs0, 0x140(sp)
    ^
    

    Even though it's gated by the d flag that should only be active when the d target feature is present.

  6. added
    O-xousOS: A microkernel OS for privacy in computing
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 17, 2024
  7. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Dec 17, 2024
  8. 26 remaining items

  9. added 7 commits that reference this issue on Feb 20, 2025
    172cbee
    ded0310
    d4ed292
    23d674e
    d56545f
    9578530
    08e8d05
  10. added 8 commits that reference this issue on Mar 3, 2025
    5635206
    8736a22
    4a4b7a1
    08fde92
    76e9ed6
    5affff2
    c7f76b0
    727f7a9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-nakedArea: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzSC-discussionCategory: Discussion or questions that doesn't represent real issues.F-naked_functions`#![feature(naked_functions)]`O-xousOS: A microkernel OS for privacy in computingT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions