commit b7fde7089b54342acff6bb178121332428b8c557 Author: Brandon Bergren Date: Thu May 6 18:32:06 2021 -0500 ppc32 updates! diff --git a/lang/rust/Makefile b/lang/rust/Makefile index 4ea776e93437..7f6bda87542f 100644 --- a/lang/rust/Makefile +++ b/lang/rust/Makefile @@ -24,7 +24,6 @@ LICENSE_COMB= dual LICENSE_FILE_APACHE20= ${WRKSRC}/LICENSE-APACHE LICENSE_FILE_MIT= ${WRKSRC}/LICENSE-MIT -BROKEN_powerpc= fails to link IGNORE_FreeBSD_11_powerpc64= is missing a bootstrap for FreeBSD 11.x powerpc64 IGNORE_FreeBSD_11_powerpc= is missing a bootstrap for FreeBSD 11.x powerpc IGNORE_FreeBSD_12_powerpc= is missing a bootstrap for FreeBSD 12.x powerpc @@ -74,7 +73,7 @@ _RUST_ARCH_amd64= x86_64 _RUST_ARCH_i386= i686 _RUST_TARGET= ${_RUST_ARCH_${ARCH}:U${ARCH}}-unknown-${OPSYS:tl} _RUST_TARGETS= ${_RUST_TARGET} -_RUST_TOOLS= analysis cargo clippy rls rustfmt +_RUST_TOOLS= analysis cargo clippy rustfmt _RUSTC_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${_RUST_TARGET} _RUST_STD_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${_RUST_TARGET} @@ -82,10 +81,20 @@ _CARGO_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/cargo-${RUST_BO .include +# Build rls on all platforms that have 64-bit atomics. +.if (${ARCH} != powerpc) +_RUST_TOOLS+= rls +.endif + .if exists(${PATCHDIR}/${ARCH}${BOOTSTRAPS_SUFFIX}) EXTRA_PATCHES+= ${PATCHDIR}/${ARCH}${BOOTSTRAPS_SUFFIX} .endif +.if ${ARCH} == powerpc +# Pull in bfd to link rustc_driver, as lld currently can't. +BUILD_DEPENDS+= ld.bfd:devel/binutils +.endif + .if defined(PPC_ABI) && ${PPC_ABI} == ELFv1 # The bootstrap is hardcoded to use gcc9 # but we can build with a newer or older compiler as provided by USE_GCC=yes @@ -162,14 +171,31 @@ do-configure: # fails to link with base ld.bfd: rustc_codegen_llvm.e2557spx-cgu.11:(.text._ZN89_$LT$rustc_target..abi..call..CastTarget$u20$as$u20$rustc_codegen_llvm..abi..LlvmType$GT$9llvm_type17h1296210ab461fc57E+0x54): relocation truncated to fit: R_ARM_CALL against symbol `__aeabi_uldivmod' defined in .text.__aeabi_uldivmod section in /tmp/rustcdnGbao/libcompiler_builtins-ee65b414e4115a8f.rlib(compiler_builtins-ee65b414e4115a8f.compiler_builtins.ay8p39ey-cgu.13.rcgu.o) @${PRINTF} '#!/bin/sh\nexec ${CC} -fuse-ld=lld "$$@"' > ${WRKDIR}/cc-wrapper @${CHMOD} +x ${WRKDIR}/cc-wrapper +.elif ${ARCH} == powerpc +# Rust doesn't call the system compiler with the full version of the target. +# This makes powerpc miscompile due to the secure-plt ABI change. +# Additionally, force using ld.bfd to work around a linking problem in rustc_mir + @${PRINTF} '#!/bin/sh\nexec ${CC} "$$@" --target=powerpc-unknown-freebsd13.0' > ${WRKDIR}/cc-wrapper + @${CHMOD} +x ${WRKDIR}/cc-wrapper + @${PRINTF} '#!/bin/sh\nexec ${CXX} "$$@" --target=powerpc-unknown-freebsd13.0' > ${WRKDIR}/cxx-wrapper + @${CHMOD} +x ${WRKDIR}/cxx-wrapper + @${PRINTF} '#!/bin/sh\nexec ${CC} -fuse-ld=bfd "$$@" --target=powerpc-unknown-freebsd13.0' > ${WRKDIR}/ld-wrapper + @${CHMOD} +x ${WRKDIR}/ld-wrapper .endif .for _target in ${_RUST_TARGETS} @${ECHO_CMD} '[target.${_target}]' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'ar="${AR}"' >> ${WRKSRC}/config.toml +.if ${ARCH} == powerpc + @${ECHO_CMD} 'cc="${WRKDIR}/cc-wrapper"' >> ${WRKSRC}/config.toml + @${ECHO_CMD} 'cxx="${WRKDIR}/cxx-wrapper"' >> ${WRKSRC}/config.toml +.else @${ECHO_CMD} 'cc="${CC}"' >> ${WRKSRC}/config.toml @${ECHO_CMD} 'cxx="${CXX}"' >> ${WRKSRC}/config.toml +.endif .if ${ARCH} == armv6 @${ECHO_CMD} 'linker="${WRKDIR}/cc-wrapper"' >> ${WRKSRC}/config.toml +.elif ${ARCH} == powerpc + @${ECHO_CMD} 'linker="${WRKDIR}/ld-wrapper"' >> ${WRKSRC}/config.toml .else @${ECHO_CMD} 'linker="${CC}"' >> ${WRKSRC}/config.toml .endif diff --git a/lang/rust/files/powerpc/patch-compiler_rustc__target_src_spec_powerpc__unknown__freebsd.rs b/lang/rust/files/powerpc/patch-compiler_rustc__target_src_spec_powerpc__unknown__freebsd.rs index 8c49456804e6..87af3d8ea723 100644 --- a/lang/rust/files/powerpc/patch-compiler_rustc__target_src_spec_powerpc__unknown__freebsd.rs +++ b/lang/rust/files/powerpc/patch-compiler_rustc__target_src_spec_powerpc__unknown__freebsd.rs @@ -2,11 +2,12 @@ +++ compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs 2021-04-24 17:00:25.903298000 -0500 @@ -0,0 +1,24 @@ +use crate::abi::Endian; -+use crate::spec::{CodeModel, LinkerFlavor, RelocModel, Target, TargetOptions}; ++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); + @@ -17,7 +18,6 @@ + arch: "powerpc".to_string(), + options: TargetOptions { + endian: Endian::Big, -+ code_model: Some(CodeModel::Large), + features: "+secure-plt".to_string(), + relocation_model: RelocModel::Pic, + mcount: "_mcount".to_string(), diff --git a/lang/rust/files/powerpc/patch-src_bootstrap_native.rs b/lang/rust/files/powerpc/patch-src_bootstrap_native.rs new file mode 100644 index 000000000000..025a4e7b2182 --- /dev/null +++ b/lang/rust/files/powerpc/patch-src_bootstrap_native.rs @@ -0,0 +1,25 @@ +--- src/bootstrap/native.rs.orig 2021-05-03 20:57:16.000000000 +0000 ++++ src/bootstrap/native.rs 2021-05-06 20:37:55.448200000 +0000 +@@ -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() + }; +@@ -274,6 +278,11 @@ impl Step for Llvm { + if num_linkers > 0 { + cfg.define("LLVM_PARALLEL_LINK_JOBS", num_linkers.to_string()); + } ++ } ++ ++ // Workaround for ppc32 lld limitation ++ if target == "powerpc-unknown-freebsd" { ++ cfg.define("CMAKE_EXE_LINKER_FLAGS", "-fuse-ld=bfd"); + } + + // http://llvm.org/docs/HowToCrossCompileLLVM.html diff --git a/lang/rust/files/powerpc/patch-vendor_rustc__ap__rustc__target_src_spec_powerpc__unknown__freebsd.rs b/lang/rust/files/powerpc/patch-vendor_rustc__ap__rustc__target_src_spec_powerpc__unknown__freebsd.rs index 63b83f74ff6c..cdaaef7f84f6 100644 --- a/lang/rust/files/powerpc/patch-vendor_rustc__ap__rustc__target_src_spec_powerpc__unknown__freebsd.rs +++ b/lang/rust/files/powerpc/patch-vendor_rustc__ap__rustc__target_src_spec_powerpc__unknown__freebsd.rs @@ -2,11 +2,12 @@ +++ vendor/rustc-ap-rustc_target/src/spec/powerpc_unknown_freebsd.rs 2021-04-24 17:00:25.903298000 -0500 @@ -0,0 +1,24 @@ +use crate::abi::Endian; -+use crate::spec::{CodeModel, LinkerFlavor, RelocModel, Target, TargetOptions}; ++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); + @@ -17,7 +18,6 @@ + arch: "powerpc".to_string(), + options: TargetOptions { + endian: Endian::Big, -+ code_model: Some(CodeModel::Large), + features: "+secure-plt".to_string(), + relocation_model: RelocModel::Pic, + mcount: "_mcount".to_string(),