Skip to content

xbuild ignores .cargo/config for sysroot crates. #27

Closed
@andre-richter

Description

@andre-richter

Hi,

for the following description please refer to an example uploaded to https://github.com/rust-embedded/rust-raspi3-tutorial/tree/no_float/float_reg_emission

This example should be buildable with a recent nightly rust and just executing make.

The project uses the aarch64-unknown-none target, and has additional rustflags in .cargo/config. However, it seems that xbuild is ignoring the contents of .cargo/config when it builds the sysroot crates.

In the example uploaded, it is set that no hard-float code should be emitted (-fp-armv8). This is honored for the actual crate being compiled, but not for the sysroot.

Here's a dissasembly of the emitted code where you can see that with xbuild, an ARM floating point register (q0) is being emitted:

core::panicking::panic_fmt::h7472082024a4b065:
   80218:       20 00 c0 3d     ldr     q0, [x1]
   8021c:       28 08 40 f9     ldr     x8, [x1, #0x10]
   80220:       09 00 00 b0     adrp    x9, #0x1000
   80224:       0a 00 00 b0     adrp    x10, #0x1000
   80228:       29 a1 15 91     add     x9, x9, #0x568
   8022c:       4a a1 15 91     add     x10, x10, #0x568
   80230:       e9 2b bd a9     stp     x9, x10, [sp, #-0x30]!
   80234:       e0 0b 00 f9     str     x0, [sp, #0x10]
   80238:       e0 03 00 91     mov     x0, sp
   8023c:       e0 83 81 3c     stur    q0, [sp, #0x18]
   80240:       e8 17 00 f9     str     x8, [sp, #0x28]
   80244:       58 00 00 94     bl      #0x160 <rust_begin_unwind>
   80248:       20 00 20 d4     brk     #0x1

Using xargo within the same example, this doesn't happen:

xargo build --target=aarch64-unknown-none --release
cp target/aarch64-unknown-none/release/kernel8 .
make objdump

No float regs here:

core::panicking::panic_fmt::h4f28b4483e5ece01:
   80224:       08 00 00 b0     adrp    x8, #0x1000
   80228:       08 21 16 91     add     x8, x8, #0x588
   8022c:       e8 0f 1d f8     str     x8, [sp, #-0x30]!
   80230:       0a 00 00 b0     adrp    x10, #0x1000
   80234:       4a 21 16 91     add     x10, x10, #0x588
   80238:       28 24 40 a9     ldp     x8, x9, [x1]
   8023c:       ea 83 00 a9     stp     x10, x0, [sp, #0x8]
   80240:       e0 03 00 91     mov     x0, sp
   80244:       2a 2c 42 29     ldp     w10, w11, [x1, #0x10]
   80248:       e8 a7 01 a9     stp     x8, x9, [sp, #0x18]
   8024c:       ea 2f 05 29     stp     w10, w11, [sp, #0x28]
   80250:       59 00 00 94     bl      #0x164 <rust_begin_unwind>
   80254:       20 00 20 d4     brk     #0x1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions