Skip to content

Commit

Permalink
Add binary_format to rustc target specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyr0de committed Feb 6, 2025
1 parent c753cb9 commit a372c5c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,16 @@ enum TargetKind {
Builtin,
}

#[derive(PartialEq, Clone, Debug)]
pub enum BinaryFormat {
Coff,
Elf,
MachO,
Pe,
Wasm,
Xcoff,
}

/// Everything `rustc` knows about how to compile for a specific target.
///
/// Every field here must be specified, and has no default value.
Expand All @@ -2099,6 +2109,8 @@ pub struct Target {
pub arch: StaticCow<str>,
/// [Data layout](https://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
pub data_layout: StaticCow<str>,
///
pub binary_format: BinaryFormat,
/// Optional settings with defaults.
pub options: TargetOptions,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{Arch, TargetAbi, base};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
use crate::spec::{BinaryFormat, FramePointer, SanitizerSet, Target, TargetOptions};

pub(crate) fn target() -> Target {
let (opts, llvm_target, arch) = base("macos", Arch::Arm64, TargetAbi::Normal);
Expand All @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
.into(),
arch,
binary_format: BinaryFormat::MachO,
options: TargetOptions {
mcount: "\u{1}mcount".into(),
frame_pointer: FramePointer::NonLeaf,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{Arch, TargetAbi, base};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
use crate::spec::{BinaryFormat, FramePointer, SanitizerSet, Target, TargetOptions};

pub(crate) fn target() -> Target {
let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetAbi::Normal);
Expand All @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
.into(),
arch,
binary_format: BinaryFormat::MachO,
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::base::apple::{Arch, TargetAbi, base};
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
use crate::spec::{BinaryFormat, FramePointer, SanitizerSet, Target, TargetOptions};

pub(crate) fn target() -> Target {
let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetAbi::MacCatalyst);
Expand All @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
.into(),
arch,
binary_format: BinaryFormat::MachO,
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a12".into(),
max_atomic_width: Some(128),
Expand Down

0 comments on commit a372c5c

Please sign in to comment.