rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.77k stars 12.77k forks source link

Cannot build bare metal mach-o binaries #131427

Open theoparis opened 1 month ago

theoparis commented 1 month ago

I tried to compile a bare metal aarch64 Rust Mach-O binary with the following target json spec:

{
  "abi": "softfloat",
  "arch": "aarch64",
  "crt-objects-fallback": "false",
  "data-layout": "e-m:o-i64:64-i128:128-n32:64-S128-Fn32",
  "disable-redzone": true,
  "features": "+v8a,+strict-align,-neon,-fp-armv8",
  "is-builtin": false,
  "linker": "ld64.lld",
  "linker-flavor": "gnu-lld",
  "llvm-target": "aarch64-unknown-none-macho",
  "max-atomic-width": 128,
  "metadata": {
    "description": "Bare ARM64, softfloat",
    "host_tools": false,
    "std": false,
    "tier": 2
  },
  "panic-strategy": "abort",
  "relocation-model": "static",
  "stack-probes": {
    "kind": "inline"
  },
  "target-pointer-width": "64"
}

I expected to see this happen: No errors

Instead, this happened:

rustc-LLVM ERROR: Global variable '__rustc_debug_gdb_scripts_section__' has an invalid section specifier '.debug_gdb_scripts': mach-o section specifier requires a segment and section separated by a comma.

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (6f4ae0f34 2024-10-08)
binary: rustc
commit-hash: 6f4ae0f34503601e54680a137c1db0b81b56cc3d
commit-date: 2024-10-08
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Unfortunately RUST_BACKTRACE=1 doesn't change anything so I cannot give backtrace at the moment. I will look into building rustc if needed.

workingjubilee commented 1 month ago

You are guessing... incorrectly in at least one case... as to what the fields mean and how they should be used.

You should try to base your target spec on https://github.com/rust-lang/rust/blob/18deb53874ac4701ba10ebc016cb8cde7a049b82/compiler/rustc_target/src/spec/base/apple/mod.rs

workingjubilee commented 1 month ago

In order for this bug report to be useful, you also will need to create a much more complete description of build steps. You have not actually named the command that you ran or other build parameters.

bjorn3 commented 1 month ago

You should try to base your target spec on https://github.com/rust-lang/rust/blob/18deb53874ac4701ba10ebc016cb8cde7a049b82/compiler/rustc_target/src/spec/base/apple/mod.rs

In particular you are missing "emit-debug-gdb-scripts": false.