为什么我在向 rust (arm-unknown-linux-uclibceabihf) 添加自定义目标时得到 VFP 寄存器参数?

Why am I getting a VFP register arguments while adding a custom target to rust (arm-unknown-linux-uclibceabihf)?

我正在按照上一期 Rust 时事通讯的指南进行操作:https://rust-embedded.github.io/embedonomicon/custom-target.html 并遇到了与 soft/hard 浮动配置相关的问题。

我通过将 mipsel-unknown-linux-uclibc.json 与 arm-unknown-linux-gnueabihf.json 合并来创建我的新目标,以获得以下结果:

{
  "arch": "arm",
  "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
  "dynamic-linking": true,
  "env": "uclibc",
  "executables": true,
  "features": "+strict-align,+v6,+vfp2",
  "has-elf-tls": true,
  "has-rpath": true,
  "is-builtin": false,
  "linker-flavor": "gcc",
  "linker-is-gnu": true,
  "linker": "/home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc",
  "llvm-target": "arm-unknown-linux-uclibceabihf",
  "max-atomic-width": 64,
  "os": "linux",
  "position-independent-executables": true,
  "pre-link-args": {
    "gcc": [
      "-Wl,--as-needed",
      "-Wl,-z,noexecstack"
    ]
  },
  "relro-level": "full",
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-family": "unix",
  "target-mcount": "_mcount",
  "target-pointer-width": "32",
  "vendor": "unknown"
}

当我使用新的自定义目标编译带有 cargo 的非标准应用程序时:

cargo build -Z build-std=core --target arm-unknown-linux-uclibceabihf.json

我收到以下错误:

   Compiling app v0.1.0 (/home/ykoehler/work/app)
error: linking with `/home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc` failed: exit code: 1
  |
  = note: "/home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-L" "/home/ykoehler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-uclibceabihf/lib" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/app-92459304df1651f0.app.2jjler86-cgu.0.rcgu.o" "-o" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/app-92459304df1651f0" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps" "-L" "/home/ykoehler/work/app/target/release/deps" "-L" "/home/ykoehler/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/arm-unknown-linux-uclibceabihf/lib" "-Wl,-Bstatic" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/librustc_std_workspace_core-375ea25c872246b5.rlib" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/libcore-34e07d1b528fc142.rlib" "/home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/libcompiler_builtins-a34a2e58700fb5e5.rlib" "-Wl,-Bdynamic"
  = note: /home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabihf/5.3.0/../../../../arm-buildroot-linux-uclibcgnueabihf/bin/ld: error: /home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/app-92459304df1651f0 uses VFP register arguments, /home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/app-92459304df1651f0.app.2jjler86-cgu.0.rcgu.o does not
          /home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabihf/5.3.0/../../../../arm-buildroot-linux-uclibcgnueabihf/bin/ld: failed to merge target specific data of file /home/ykoehler/work/app/target/arm-unknown-linux-uclibceabihf/release/deps/app-92459304df1651f0.app.2jjler86-cgu.0.rcgu.o
          /home/ykoehler/work/tools/arm-5.3-uclibc-1.0.12/usr/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib/Scrt1.o: In function `_start':
          /var/tmp/tool-chains/buildroot-2016.02-5.3-arm/src/buildroot-2016.02/output/build/uclibc-1.0.12/libc/sysdeps/linux/arm/crt1.S:217: undefined reference to `__uClibc_main'
          /var/tmp/tool-chains/buildroot-2016.02-5.3-arm/src/buildroot-2016.02/output/build/uclibc-1.0.12/libc/sysdeps/linux/arm/crt1.S:235: undefined reference to `abort'
          /var/tmp/tool-chains/buildroot-2016.02-5.3-arm/src/buildroot-2016.02/output/build/uclibc-1.0.12/libc/sysdeps/linux/arm/crt1.S:235: undefined reference to `main'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: could not compile `app`.

To learn more, run the command again with --verbose.

此错误表明当其他部分使用硬浮点数时,某些代码是使用软浮点数编译的,通过网络阅读有关错误消息。然而,错误指定的两个文件似乎都是由 rust 生成的,我不清楚为什么 rust 会根据我在自定义目标定义文件中提供的信息生成任何软浮动代码。

感谢任何帮助。

我相信您只需要为 llvm-target 使用 arm-unknown-linux-gnueabihf。 VFP 错误与可用的 floating-point 指令集有关(即 eabihf 中的 hf 代表 Hard Float)。我正在努力让 armv7-unknown-linux-uclibceabihf 目标在 Rust 中工作。我在让 armv7-unknown-linux-uclibceabihf 目标在 Rust 中工作时收到了相同的 VFP 错误,结果我只需要为 llvm-target.

使用 armv7-unknown-linux-gnueabihf

此外,这是我的 armv7-unknown-linux-uclibceabihf 规格文件以供比较:

{
  "abi-blacklist": [
    "stdcall",
    "fastcall",
    "vectorcall",
    "thiscall",
    "win64",
    "sysv64"
  ],
  "arch": "arm",
  "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
  "dynamic-linking": true,
  "env": "uclibc",
  "executables": true,
  "features": "+v7,+vfp3,-d32,+thumb2,-neon",
  "has-elf-tls": true,
  "has-rpath": true,
  "linker-flavor": "gcc",
  "linker-is-gnu": true,
  "llvm-target": "armv7-unknown-linux-gnueabihf",
  "max-atomic-width": 64,
  "os": "linux",
  "position-independent-executables": true,
  "pre-link-args": {
    "gcc": [
      "-Wl,--as-needed",
      "-Wl,-z,noexecstack"
    ]
  },
  "relro-level": "full",
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-family": "unix",
  "target-mcount": "\u0001__gnu_mcount_nc",
  "target-pointer-width": "32",
  "vendor": "unknown"
}

干杯