Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for powerpc-unknown-freebsd #87370

Merged
merged 1 commit into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ supported_targets! {
("armv6-unknown-freebsd", armv6_unknown_freebsd),
("armv7-unknown-freebsd", armv7_unknown_freebsd),
("i686-unknown-freebsd", i686_unknown_freebsd),
("powerpc-unknown-freebsd", powerpc_unknown_freebsd),
("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd),
("powerpc64le-unknown-freebsd", powerpc64le_unknown_freebsd),
("x86_64-unknown-freebsd", x86_64_unknown_freebsd),
Expand Down
27 changes: 27 additions & 0 deletions compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::abi::Endian;
use crate::spec::{LinkerFlavor, RelocModel, Target, TargetOptions};

pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
// Extra hint to linker that we are generating secure-PLT code.
base.pre_link_args
.entry(LinkerFlavor::Gcc)
.or_default()
.push("--target=powerpc-unknown-freebsd13.0".to_string());
base.max_atomic_width = Some(32);

Target {
llvm_target: "powerpc-unknown-freebsd13.0".to_string(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
arch: "powerpc".to_string(),
options: TargetOptions {
endian: Endian::Big,
features: "+secure-plt".to_string(),
relocation_model: RelocModel::Pic,
mcount: "_mcount".to_string(),
..base
},
}
}
9 changes: 9 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl Step for Llvm {
let idx = target.triple.find('-').unwrap();

format!("riscv{}{}", &target.triple[5..7], &target.triple[idx..])
} else if self.target.starts_with("powerpc") && self.target.ends_with("freebsd") {
// FreeBSD 13 had incompatible ABI changes on all PowerPC platforms.
// Set the version suffix to 13.0 so the correct target details are used.
format!("{}{}", self.target, "13.0")
} else {
target.to_string()
};
Expand Down Expand Up @@ -277,6 +281,11 @@ impl Step for Llvm {
}
}

// Workaround for ppc32 lld limitation
if target == "powerpc-unknown-freebsd" {
cfg.define("CMAKE_EXE_LINKER_FLAGS", "-fuse-ld=bfd");
}

// https://llvm.org/docs/HowToCrossCompileLLVM.html
if target != builder.config.build {
builder.ensure(Llvm { target: builder.config.build });
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ target | std | host | notes
`powerpc-wrs-vxworks` | ? | |
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
`powerpc-unknown-freebsd` | | | PowerPC FreeBSD
`powerpc64-unknown-linux-musl` | ? | |
`powerpc64-wrs-vxworks` | ? | |
`powerpc64le-unknown-linux-musl` | ? | |
Expand Down