From 5bbd4b2038f612218895e2ceb6c80ae80ea8a6b6 Mon Sep 17 00:00:00 2001 From: Donald Hoskins Date: Mon, 18 Jul 2022 01:07:17 +0000 Subject: rust: Updste to 1.62.0 --- lang/rust/Config.in | 118 ++++++++++++++++++++ lang/rust/Makefile | 132 ++++++++++++++++++++++ lang/rust/patches/03-add_mips.patch | 30 +++++ lang/rust/patches/04-add_mipsel.patch | 29 +++++ lang/rust/patches/05-add_aarch64.patch | 27 +++++ lang/rust/patches/06-add_armv7.patch | 38 +++++++ lang/rust/patches/07-add_armv7hf.patch | 37 +++++++ lang/rust/patches/08-add_powerpc64.patch | 30 +++++ lang/rust/patches/09-add_x86_64.patch | 38 +++++++ lang/rust/patches/10-add_arm.patch | 34 ++++++ lang/rust/patches/11-add_armhf.patch | 34 ++++++ lang/rust/patches/12-add_armv5tej.patch | 36 ++++++ lang/rust/patches/13-add_armv6k.patch | 36 ++++++ lang/rust/patches/14-add_powerpc.patch | 29 +++++ lang/rust/rust_config.mk | 120 ++++++++++++++++++++ lang/rust/rustc_environment.mk | 30 +++++ lang/rust/rustc_targets.mk | 100 +++++++++++++++++ lang/rust_host/Makefile | 151 ++++++++++++++++++++++++++ lang/rust_host/patches/03-add_mips.patch | 30 +++++ lang/rust_host/patches/04-add_mipsel.patch | 29 +++++ lang/rust_host/patches/05-add_aarch64.patch | 27 +++++ lang/rust_host/patches/06-add_armv7.patch | 38 +++++++ lang/rust_host/patches/07-add_armv7hf.patch | 37 +++++++ lang/rust_host/patches/08-add_powerpc64.patch | 30 +++++ lang/rust_host/patches/09-add_x86_64.patch | 38 +++++++ lang/rust_host/patches/10-add_arm.patch | 34 ++++++ lang/rust_host/patches/11-add_armhf.patch | 34 ++++++ lang/rust_host/patches/12-add_armv5tej.patch | 36 ++++++ lang/rust_host/patches/13-add_armv6k.patch | 34 ++++++ lang/rust_host/patches/14-add_powerpc.patch | 29 +++++ 30 files changed, 1445 insertions(+) create mode 100644 lang/rust/Config.in create mode 100644 lang/rust/Makefile create mode 100644 lang/rust/patches/03-add_mips.patch create mode 100644 lang/rust/patches/04-add_mipsel.patch create mode 100644 lang/rust/patches/05-add_aarch64.patch create mode 100644 lang/rust/patches/06-add_armv7.patch create mode 100644 lang/rust/patches/07-add_armv7hf.patch create mode 100644 lang/rust/patches/08-add_powerpc64.patch create mode 100644 lang/rust/patches/09-add_x86_64.patch create mode 100644 lang/rust/patches/10-add_arm.patch create mode 100644 lang/rust/patches/11-add_armhf.patch create mode 100644 lang/rust/patches/12-add_armv5tej.patch create mode 100644 lang/rust/patches/13-add_armv6k.patch create mode 100644 lang/rust/patches/14-add_powerpc.patch create mode 100644 lang/rust/rust_config.mk create mode 100644 lang/rust/rustc_environment.mk create mode 100644 lang/rust/rustc_targets.mk create mode 100644 lang/rust_host/Makefile create mode 100644 lang/rust_host/patches/03-add_mips.patch create mode 100644 lang/rust_host/patches/04-add_mipsel.patch create mode 100644 lang/rust_host/patches/05-add_aarch64.patch create mode 100644 lang/rust_host/patches/06-add_armv7.patch create mode 100644 lang/rust_host/patches/07-add_armv7hf.patch create mode 100644 lang/rust_host/patches/08-add_powerpc64.patch create mode 100644 lang/rust_host/patches/09-add_x86_64.patch create mode 100644 lang/rust_host/patches/10-add_arm.patch create mode 100644 lang/rust_host/patches/11-add_armhf.patch create mode 100644 lang/rust_host/patches/12-add_armv5tej.patch create mode 100644 lang/rust_host/patches/13-add_armv6k.patch create mode 100644 lang/rust_host/patches/14-add_powerpc.patch diff --git a/lang/rust/Config.in b/lang/rust/Config.in new file mode 100644 index 0000000..685fa45 --- /dev/null +++ b/lang/rust/Config.in @@ -0,0 +1,118 @@ +# Rust Language Options +menu "Compiler Options" + visible if PACKAGE_rust + + config RUST_DEBUG + bool "Enables Debugging Environment (--enable-debug)" + default n + + config RUST_DOCS + bool "Build standard library documentation (--enable-docs)" + default n + + config RUST_COMPILER_DOCS + bool "Build compiler documentation (--enable-compiler-docs)" + default n + + config RUST_OPTIMIZE_TESTS + bool "Build tests with optimizations (--enable-optimized-tests)" + default n + + config RUST_PARALLEL + bool "Build with multi-threaded support (--enable-parallel-compiler)" + default n + + config RUST_VERBOSE_TESTS + bool "Enable verbose output when running tests (--enable-verbose-tests)" + default n + + config RUST_CCACHE + bool "Build with ccache enabled (--enable-ccache)" + default n + + config RUST_LLVM_STATIC + bool "Statically link to libstdc++ to LLVM (--enable-llvm-static-stdccp)" + default n + + config RUST_LLVM_SHARED + bool "Prefer shared linking to LLVM (--enable-llvm-link-shared)" + default n + + config RUST_CODEGEN_TESTS + bool "Run the src/test/codegen tests (--enable-codegen-tests)" + default n + + config RUST_OPTION_CHECKING + bool "Complain about unrecognized options in this configure script (--enable-option-checking)" + default y + + config RUST_ENABLE_NINJA + bool "Build LLVM using the Ninja generator (--enable-ninja)" + default y + + config RUST_LOCKED_DEPS + bool "Force Cargo.lock to be up to date (--enable-locked-deps)" + default n + + config RUST_VENDOR + bool "Enable usage of vendored Rust crates (--enable-vendor)" + default n + + config RUST_SANITIZERS + bool "Build the sanitizer runtimes (asan, lsan, msan, tsan) (--enable-sanitizers)" + default n + + config RUST_DIST_SRC + bool "When building tarballs enables building a source tarball (--enable-dist-src)" + default n + + config RUST_CARGO_NATIVE_STATIC + bool "Build static native libraries in Cargo (--enable-cargo-native-static)" + default n + + config RUST_PROFILER + bool "Build the profiler runtime (--enable-profiler)" + default n + + config RUST_FULL_TOOLS + bool "Build all tools (--enable-full-tools)" + default n + + config RUST_MISSING_TOOLS + bool "Allow failures when building tools (--enable-missing-tools)" + default y + + config RUST_USE_LIBCXX + bool "Build LLVM with libc++ (--enable-use-libcxx)" + default n + + config RUST_CONTROL_FLOW_GUARD + bool "Enable Control Flow Guard (--enable-control-flow-guard)" + default n + + config RUST_OPTIMIZE_LLVM + bool "Build optimized LLVM (--enable-optimize-llvm)" + default y + + config RUST_LLVM_ASSERTIONS + bool "Build LLVM with assertions (--enable-llvm-assertions)" + default n + + config RUST_DEBUG_ASSERTIONS + bool "Build with debugging assertions (--enable-debug-assertions)" + default n + + config RUST_LLVM_RELEASE_DEBUGINFO + bool "Build LLVM with debugger metadata (--enable-llvm-release-debuginfo)" + default n + + config RUST_MANAGE_SUBMODULES + bool "Let the build manage the git submodules (--enable-manage-submodules)" + default y + + config RUST_FULL_BOOTSTRAP + bool "Full Bootstrap - Build three compilers instead of two (--enable-full-bootstrap)" + default n + +endmenu + diff --git a/lang/rust/Makefile b/lang/rust/Makefile new file mode 100644 index 0000000..3a2cf9a --- /dev/null +++ b/lang/rust/Makefile @@ -0,0 +1,132 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +include $(TOPDIR)/rules.mk + +PKG_NAME:=rust + +PKG_VERSION:=1.62.0 +PKG_RELEASE:=1 + +PKG_LICENSE:=Apache-2.0 MIT +PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/rust-lang/rust.git +PKG_SOURCE_DATE:=2022-06-29 +PKG_SOURCE_VERSION:=a8314ef7d0ec7b75c336af2c9857bfaf43002bfc +PKG_MIRROR_HASH:=09f933ee7a449751bc6d7ad6364dd44163439f029061daf158d7bfaf3a726184 + +HOST_BUILD_PARALLEL:=1 +HOST_USE_NINJA:=1 +PKG_HOST_ONLY:=1 +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rust-$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk +include ./rustc_environment.mk + +HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared_$(RUSTC_TARGET_ARCH) +HOST_STAMP_BUILT=$(HOST_BUILD_DIR)/.built_$(RUSTC_TARGET_ARCH) +HOST_STAMP_CONFIGURED=$(HOST_BUILD_DIR)/.configured_$(RUSTC_TARGET_ARCH) +HOST_STAMP_INSTALLED=$(CARGO_HOME)/.rust_$(RUSTC_TARGET_ARCH)_installed + +# Requires Python3 to build +HOST_BUILD_DEPENDS:=python3/host rust_host/host + +# Use External rust-lang specific LLVM +RUST_UNINSTALL:=$(STAGING_DIR_HOST)/lib/rustlib/uninstall.sh +RUST_TMP_DIR:=$(TMP_DIR)/rust-install + +# Set Configure Environmentals +HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)" + +# The Flags are Common between HOST and TARGET +RUST_COMMON_ARGS := \ + --build=$(RUSTC_HOST_ARCH) \ + --host=$(RUSTC_HOST_ARCH) \ + --dist-compression-formats=xz \ + --enable-llvm-link-shared \ + --enable-llvm-plugins \ + --enable-missing-tools \ + --enable-ninja \ + --enable-optimize \ + --enable-optimize-llvm \ + --enable-parallel-compiler \ + --enable-sanitizers \ + --release-channel=nightly \ + --prefix=$(STAGING_DIR_HOST) \ + --bindir=$(STAGING_DIR_HOST)/bin \ + --libdir=$(STAGING_DIR_HOST)/lib \ + --sysconfdir=$(STAGING_DIR_HOST)/etc \ + --datadir=$(STAGING_DIR_HOST)/share \ + --mandir=$(STAGING_DIR_HOST)/man \ + --set=build.extended=true \ + --llvm-root=$(LLVM_DIR) \ + --set=target.$(RUSTC_TARGET_ARCH).llvm-config=$(LLVM_DIR)/bin/llvm-config + +# MUSL Targets need additional flags +MUSL_ARGS = \ + --set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \ + --set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR) \ + --set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) + +## +# Because OpenWrt uses default configure flags that are not recognized +# we override the default and set our own. +# +# Rust HOST Configuration Arguments +HOST_CONFIGURE_ARGS = \ + --target=$(RUSTC_TARGET_ARCH) \ + ${RUST_COMMON_ARGS} \ + $(MUSL_ARGS) \ + --set=build.cargo=$(STAGING_DIR_HOST)/bin/cargo \ + --set=build.rustc=$(STAGING_DIR_HOST)/bin/rustc + +HOST_CXXFLAGS += -DLLVM_RUSTLLVM + +define Host/Uninstall + rm -rf $(HOST_STAMP_INSTALLED) +endef + +# Installation is done via Host/Compile +define Host/Install +endef + +define Host/Compile + cd $(HOST_BUILD_DIR) && \ + CARGO_HOME='$(CARGO_HOME)' \ + CXXFLAGS='$(HOST_CXXFLAGS)' \ + LD_LIBRARY_PATH=$(LLVM_DIR)/lib:$(STAGING_DIR_HOST)/lib \ + $(PYTHON) x.py install --config ./config.toml --stage 1 library/std +endef + +define Package/rust + TITLE:=Rust programming language + CATEGORY:=Languages + SECTION:=lang + DEPENDS:= +endef + +define Package/rust/description + Rust Programming Language +endef + +define Package/rust/install + true +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,rust)) diff --git a/lang/rust/patches/03-add_mips.patch b/lang/rust/patches/03-add_mips.patch new file mode 100644 index 0000000..db48710 --- /dev/null +++ b/lang/rust/patches/03-add_mips.patch @@ -0,0 +1,30 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1016,6 +1016,7 @@ + ("x86_64-unknown-none", x86_64_unknown_none), + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), ++ ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mips_openwrt_linux_musl.rs +@@ -0,0 +1,17 @@ ++use crate::abi::Endian; ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "mips32r2".into(); ++ base.features = "+mips32r2,+soft-float".into(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mips-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), ++ arch: "mips".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} diff --git a/lang/rust/patches/04-add_mipsel.patch b/lang/rust/patches/04-add_mipsel.patch new file mode 100644 index 0000000..b64f1ea --- /dev/null +++ b/lang/rust/patches/04-add_mipsel.patch @@ -0,0 +1,29 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mipsel_openwrt_linux_musl.rs +@@ -0,0 +1,16 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "mips32r2".into(); ++ base.features = "+mips32r2,+soft-float".into(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mipsel-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), ++ arch: "mips".into(), ++ options: TargetOptions { mcount: "_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1015,6 +1015,7 @@ + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), ++ ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/05-add_aarch64.patch b/lang/rust/patches/05-add_aarch64.patch new file mode 100644 index 0000000..0d21d6f --- /dev/null +++ b/lang/rust/patches/05-add_aarch64.patch @@ -0,0 +1,27 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/aarch64_openwrt_linux_musl.rs +@@ -0,0 +1,14 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.max_atomic_width = Some(128); ++ ++ Target { ++ llvm_target: "aarch64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), ++ arch: "aarch64".into(), ++ options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1016,6 +1016,7 @@ + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), ++ ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/06-add_armv7.patch b/lang/rust/patches/06-add_armv7.patch new file mode 100644 index 0000000..e00aa61 --- /dev/null +++ b/lang/rust/patches/06-add_armv7.patch @@ -0,0 +1,38 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv7_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,25 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++// This target is for musl Linux on ARMv7 without thumb-mode, NEON or ++// hardfloat. ++ ++pub fn target() -> Target { ++ // Most of these settings are copied from the armv7_unknown_linux_gnueabi ++ // target. ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "armv7-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ ++ options: TargetOptions { ++ abi: "eabi".into(), ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1017,6 +1017,7 @@ + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), ++ ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/07-add_armv7hf.patch b/lang/rust/patches/07-add_armv7hf.patch new file mode 100644 index 0000000..f06f799 --- /dev/null +++ b/lang/rust/patches/07-add_armv7hf.patch @@ -0,0 +1,37 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv7_openwrt_linux_muslgnueabihf.rs +@@ -0,0 +1,24 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++// This target is for musl Linux on ARMv7 without thumb-mode or NEON. ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and LLVM ++ // doesn't support the "musleabihf" value. ++ llvm_target: "armv7-unknown-linux-gnueabihf".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ ++ // Most of these settings are copied from the armv7_unknown_linux_gnueabihf ++ // target. ++ options: TargetOptions { ++ abi: "eabihf".into(), ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1018,6 +1018,7 @@ + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), ++ ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/08-add_powerpc64.patch b/lang/rust/patches/08-add_powerpc64.patch new file mode 100644 index 0000000..1d73df4 --- /dev/null +++ b/lang/rust/patches/08-add_powerpc64.patch @@ -0,0 +1,30 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/powerpc64_openwrt_linux_musl.rs +@@ -0,0 +1,17 @@ ++use crate::abi::Endian; ++use crate::spec::{LinkerFlavor, Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "ppc64".into(); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); ++ base.max_atomic_width = Some(64); ++ ++ Target { ++ llvm_target: "powerpc64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), ++ arch: "powerpc64".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1019,6 +1019,7 @@ + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), ++ ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/09-add_x86_64.patch b/lang/rust/patches/09-add_x86_64.patch new file mode 100644 index 0000000..b1e2b4b --- /dev/null +++ b/lang/rust/patches/09-add_x86_64.patch @@ -0,0 +1,38 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/x86_64_openwrt_linux_musl.rs +@@ -0,0 +1,25 @@ ++use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "x86-64".into(); ++ base.max_atomic_width = Some(64); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); ++ // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved ++ base.stack_probes = StackProbeType::Call; ++ base.static_position_independent_executables = true; ++ base.supported_sanitizers = SanitizerSet::ADDRESS ++ | SanitizerSet::CFI ++ | SanitizerSet::LEAK ++ | SanitizerSet::MEMORY ++ | SanitizerSet::THREAD; ++ ++ Target { ++ llvm_target: "x86_64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" ++ .into(), ++ arch: "x86_64".into(), ++ options: base, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1020,6 +1020,7 @@ + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), ++ ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/10-add_arm.patch b/lang/rust/patches/10-add_arm.patch new file mode 100644 index 0000000..e5580ce --- /dev/null +++ b/lang/rust/patches/10-add_arm.patch @@ -0,0 +1,34 @@ +--- /dev/null 2022-04-12 18:46:38.250000000 -0400 ++++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "arm-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabi ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1030,6 +1030,7 @@ supported_targets! { + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), ++ ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/11-add_armhf.patch b/lang/rust/patches/11-add_armhf.patch new file mode 100644 index 0000000..9ccddbd --- /dev/null +++ b/lang/rust/patches/11-add_armhf.patch @@ -0,0 +1,34 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_muslgnueabihf.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and it ++ // doesn't support the "musleabihf" value. ++ llvm_target: "arm-unknown-linux-gnueabihf".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabihf".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabihf ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1031,6 +1031,7 @@ supported_targets! { + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), ++ ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/12-add_armv5tej.patch b/lang/rust/patches/12-add_armv5tej.patch new file mode 100644 index 0000000..750d432 --- /dev/null +++ b/lang/rust/patches/12-add_armv5tej.patch @@ -0,0 +1,36 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv5tej_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,23 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // FIXME: this comment below does not seem applicable? ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and LLVM ++ // doesn't support the "musleabihf" value. ++ llvm_target: "armv5tej-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Atomic operations provided by compiler-builtins ++ max_atomic_width: None, ++ atomic_cas: false, ++ mcount: "\u{1}mcount".into(), ++ has_thumb_interworking: true, ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1032,6 +1032,7 @@ supported_targets! { + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), ++ ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/13-add_armv6k.patch b/lang/rust/patches/13-add_armv6k.patch new file mode 100644 index 0000000..79b82c8 --- /dev/null +++ b/lang/rust/patches/13-add_armv6k.patch @@ -0,0 +1,36 @@ +--- /dev/null ++++ rust-1.60.0/compiler/rustc_target/src/spec/armv6k_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "armv6k-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabi ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +Index: rust-1.60.0/compiler/rustc_target/src/spec/mod.rs +=================================================================== +--- rust-1.60.0.orig/compiler/rustc_target/src/spec/mod.rs ++++ rust-1.60.0/compiler/rustc_target/src/spec/mod.rs +@@ -1033,6 +1033,7 @@ supported_targets! { + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), ++ ("armv6k-openwrt-linux-muslgnueabi", armv6k_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust/patches/14-add_powerpc.patch b/lang/rust/patches/14-add_powerpc.patch new file mode 100644 index 0000000..5ad20d4 --- /dev/null +++ b/lang/rust/patches/14-add_powerpc.patch @@ -0,0 +1,29 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1034,6 +1034,7 @@ supported_targets! { + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), + ("armv6k-openwrt-linux-muslgnueabi", armv6k_openwrt_linux_muslgnueabi), ++ ("powerpc-openwrt-linux-musl", powerpc_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/powerpc_openwrt_linux_musl.rs +@@ -0,0 +1,16 @@ ++use crate::abi::Endian; ++use crate::spec::{LinkerFlavor, Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); ++ base.max_atomic_width = Some(32); ++ ++ Target { ++ llvm_target: "powerpc-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "E-m:e-p:32:32-i64:64-n32".into(), ++ arch: "powerpc".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} diff --git a/lang/rust/rust_config.mk b/lang/rust/rust_config.mk new file mode 100644 index 0000000..7c33069 --- /dev/null +++ b/lang/rust/rust_config.mk @@ -0,0 +1,120 @@ + +ifeq ($(CONFIG_RUST_DEBUG),y) +CONFIGURE_ARGS += --enable-debug +endif + +ifeq ($(CONFIG_RUST_DOCS),y) +CONFIGURE_ARGS += --enable-docs +else +CONFIGURE_ARGS += --disable-docs +endif + +ifeq ($(CONFIG_RUST_COMPILER_DOCS),y) +CONFIGURE_ARGS += --enable-compiler-docs +else +CONFIGURE_ARGS += --disable-compiler-docs +endif + +ifeq ($(CONFIG_RUST_OPTIMIZE_TESTS),y) +CONFIGURE_ARGS += --enable-optimize-tests +endif + +ifeq ($(CONFIG_RUST_PARALLEL),y) +CONFIGURE_ARGS += --enable-parallel-compiler +endif + +ifeq ($(CONFIG_RUST_VERBOSE_TESTS),y) +CONFIGURE_ARGS += --enable-verbose-tests +endif + +ifeq ($(filter $(CONFIG_RUST_CCACHE) $(CCACHE),y),) +CONFIGURE_ARGS += --enable-ccache +endif + +ifeq ($(CONFIG_RUST_CCACHE),y) +CONFIGURE_ARGS += --enable-ccache +endif + +ifeq ($(CONFIG_RUST_LLVM_STATIC),y) +CONFIGURE_ARGS += --enable-llvm-static-stdcpp +endif + +ifeq ($(CONFIG_RUST_LLVM_SHARED),y) +CONFIGURE_ARGS += --enable-llvm-link-shared +endif + +ifeq ($(CONFIG_RUST_CODEGEN_TESTS),y) +CONFIGURE_ARGS += --enable-codegen-tests +endif + +ifeq ($(CONFIG_RUST_OPTION_CHECKING),y) +CONFIGURE_ARGS += --enable-option-checking +endif + +ifeq ($(CONFIG_RUST_ENABLE_NINJA),y) +CONFIGURE_ARGS += --enable-ninja +endif + +ifeq ($(CONFIG_RUST_LOCKED_DEPS),y) +CONFIGURE_ARGS += --enable-locked-deps +endif + +ifeq ($(CONFIG_RUST_VENDOR),y) +CONFIGURE_ARGS += --enable-vendor +endif + +ifeq ($(CONFIG_RUST_SANITIZERS),y) +CONFIGURE_ARGS += --enable-sanitizers +endif + +ifeq ($(CONFIG_RUST_DIST_SRC),y) +CONFIGURE_ARGS += --enable-dist-src +endif + +ifeq ($(CONFIG_RUST_CARGO_NATIVE_STATIC),y) +CONFIGURE_ARGS += --enable-cargo-native-static +endif + +ifeq ($(CONFIG_RUST_PROFILER),y) +CONFIGURE_ARGS += --enable-profiler +endif + +ifeq ($(CONFIG_RUST_FULL_TOOLS),y) +CONFIGURE_ARGS += --enable-full-tools +endif + +ifeq ($(CONFIG_RUST_MISSING_TOOLS),y) +CONFIGURE_ARGS += --enable-missing-tools +endif + +ifeq ($(CONFIG_RUST_USE_LIBCXX),y) +CONFIGURE_ARGS += --enable-use-libcxx +endif + +ifeq ($(CONFIG_RUST_CONTROL_FLOW_GUARD),y) +CONFIGURE_ARGS += --enable-control-flow-guard +endif + +ifeq ($(CONFIG_RUST_OPTIMIZE_LLVM),y) +CONFIGURE_ARGS += --enable-optimize-llvm +endif + +ifeq ($(CONFIG_RUST_LLVM_ASSERTIONS),y) +CONFIGURE_ARGS += --enable-llvm-assertions +endif + +ifeq ($(CONFIG_RUST_DEBUG_ASSERTIONS),y) +CONFIGURE_ARGS += --enable-debug-assertions +endif + +ifeq ($(CONFIG_RUST_LLVM_RELEASE_DEBUGINFO),y) +CONFIGURE_ARGS += --enable-llvm-release-debuginfo +endif + +ifeq ($(CONFIG_RUST_MANAGE_SUBMODULES),y) +CONFIGURE_ARGS += --enable-manage-submodules +endif + +ifeq ($(CONFIG_RUST_FULL_BOOTSTRAP),y) +CONFIGURE_ARGS += --enable-full-bootstrap +endif diff --git a/lang/rust/rustc_environment.mk b/lang/rust/rustc_environment.mk new file mode 100644 index 0000000..db0e350 --- /dev/null +++ b/lang/rust/rustc_environment.mk @@ -0,0 +1,30 @@ +-include $(TOPDIR)/package/feeds/packages/rust/rustc_targets.mk + +# These RUSTFLAGS are common across all TARGETs +RUSTFLAGS += \ + -C linker=$(TOOLCHAIN_DIR)/bin/$(TARGET_CC_NOCACHE) \ + -C ar=$(TOOLCHAIN_DIR)/bin/$(TARGET_AR) \ + -C target-cpu=$(RUSTC_CPU_TYPE) + +ifneq ($(RUST_TARGET_FEATURES),) +RUSTFLAGS += -C target-feature=$(RUST_TARGET_FEATURES) +endif + +# Common Build Flags +CARGO_BUILD_FLAGS = \ + RUSTFLAGS="$(RUSTFLAGS)" \ + CARGO_HOME="$(CARGO_HOME)" + +# This adds the rust environmental variables to Make calls +# MAKE_FLAGS += $(RUST_BUILD_FLAGS) + +define RustPackage/Cargo/Update + cd $(PKG_BUILD_DIR) && \ + $(CARGO_BUILD_FLAGS) cargo update $(1) +endef + +define RustPackage/Cargo/Compile + cd $(PKG_BUILD_DIR) && \ + $(CARGO_BUILD_FLAGS) cargo build -v --release \ + --target $(RUSTC_TARGET_ARCH) $(1) +endef diff --git a/lang/rust/rustc_targets.mk b/lang/rust/rustc_targets.mk new file mode 100644 index 0000000..c2b02be --- /dev/null +++ b/lang/rust/rustc_targets.mk @@ -0,0 +1,100 @@ +# Pull target info so we can type the CPU/CPU_SUBTYPE +target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) +PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) +SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir)))) +PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET)) +include $(PLATFORM_DIR)/Makefile +ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR)) + -include $(PLATFORM_SUBDIR)/target.mk +endif + +# Rust Environmental Vars +CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)") +RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX) +RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME) +CARGO_HOME:=$(STAGING_DIR_HOST)/.cargo +LLVM_DIR:=$(STAGING_DIR_HOST)/llvm-rust +RUSTC_CPU_TYPE=$(CPU_TYPE) +RUSTFLAGS= +$(warning CPU_TYPE is $(RUSTC_CPU_TYPE)) + +# ARM Logic +ifeq ($(ARCH),arm) +$(warning Entering ARM) + # Split out ARMv7 + ifeq ($(CONFIG_arm_v7),y) + $(warning Target is ARMv7) + RUSTC_TARGET_ARCH:=$(subst arm,armv7,$(RUSTC_TARGET_ARCH)) + # Set ARMv7 Soft-Float vs Hard-Float Instruction Sets + ifeq ($(CONFIG_HAS_FPU),y) + RUST_FEATURES += +v7 -d32 +thumb2 + else + RUST_FEATURES += +v7 +thumb2 +soft-float + endif + endif + + # ARMv5 + ifeq ($(RUSTC_CPU_TYPE),arm926ej-s) + RUSTC_TARGET_ARCH:=$(subst arm,armv5tej,$(RUSTC_TARGET_ARCH)) + RUST_FEATURES += +soft-float +strict-align + endif + + # ARMv6 uses arm-openwrt-linux + ifeq ($(RUSTC_CPU_TYPE),arm1176jzf-s) + $(warning Target is ARMv6) + RUST_FEATURES += +v6 +vfp2 -d32 + endif + + ifeq ($(RUSTC_CPU_TYPE),mpcore) + $(warning Target is mpcore) + RUSTC_TARGET_ARCH:=$(subst arm,armv6k,$(RUSTC_TARGET_ARCH)) + RUST_FEATURES += +v6 +soft-float +strict-align + endif + + # Set Hard-Float ABI if TARGET has FPU + ifeq ($(CONFIG_HAS_FPU),y) + RUSTC_TARGET_ARCH:=$(RUSTC_TARGET_ARCH:muslgnueabi=muslgnueabihf) + endif + + # CPU_SUBTYPE carries instruction flags in OpenWrt + ifneq ($(CPU_SUBTYPE),) + # NEON Support + ifneq ($(findstring neon,$(CPU_SUBTYPE)),) + RUST_FEATURES += +neon + else + RUST_FEATURES += -neon + endif + + ### + # vfpv prefix is not recognized by LLVM - convert to vfp and remove the + # hyphen. This is important for CPU_SUBTYPE that use hyphenated CPU_SUBTYPE + # like neon-vfpv4 and vfpv3-d16 + RUST_FEATURES += +$(lastword $(subst neon,,$(subst vfpv,vfp,$(subst -,,$(CPU_SUBTYPE))))) + endif + + ### + # If the RUST_FEATURES is empty or a single word, use as is, otherwise + # split it into a Comma-delimited format for use with target-features + ifneq ($(words $(RUST_FEATURES)),1) + RUST_TARGET_FEATURES = $(subst $(space),$(comma),$(RUST_FEATURES)) + else + RUST_TARGET_FEATURES = $(RUST_FEATURES) + endif + + ifeq ($(RUSTC_CPU_TYPE),fa526) + RUSTC_TARGET_ARCH:=$(subst arm,armv7,$(RUSTC_TARGET_ARCH)) + RUSTC_CPU_TYPE := generic + endif +endif + +# ARM Logic +ifeq ($(ARCH),mips64) + RUSTC_CPU_TYPE := octeon+ +endif + +# AArch64 Flags +ifeq ($(ARCH),aarch64) + RUSTFLAGS += -C link-arg=-lgcc +endif + +$(warning RUST_TARGET_FEATURES is $(RUST_TARGET_FEATURES)) \ No newline at end of file diff --git a/lang/rust_host/Makefile b/lang/rust_host/Makefile new file mode 100644 index 0000000..4b0266c --- /dev/null +++ b/lang/rust_host/Makefile @@ -0,0 +1,151 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +include $(TOPDIR)/rules.mk + +PKG_NAME:=rust_host +PKG_VERSION:=1.62.0 +PKG_RELEASE:=1 + +PKG_LICENSE:=Apache-2.0 MIT +PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/rust-lang/rust.git +G_SOURCE_DATE:=2022-06-29 +PKG_SOURCE_VERSION:=a8314ef7d0ec7b75c336af2c9857bfaf43002bfc +PKG_MIRROR_HASH:=09f933ee7a449751bc6d7ad6364dd44163439f029061daf158d7bfaf3a726184 + + +PKG_SOURCE_SUBDIR:=rust-$(PKG_VERSION) +PKG_HOST_ONLY:=1 + +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rust_host-$(PKG_VERSION) +HOST_BUILD_PARALLEL:=1 +HOST_USE_NINJA:=1 + +HOST_BUILD_DEPENDS:=python3/host + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk + +TAR_CMD=$(HOST_TAR) --strip=1 -C $(1) $(TAR_OPTIONS) +HOST_STAMP_PREPARED=$(HOST_BUILD_DIR)/.prepared_$(RUSTC_HOST_ARCH) +HOST_STAMP_BUILT=$(HOST_BUILD_DIR)/.built_$(RUSTC_HOST_ARCH) +HOST_STAMP_CONFIGURED=$(HOST_BUILD_DIR)/.configured_$(RUSTC_HOST_ARCH) +HOST_STAMP_INSTALLED=$(STAGING_DIR_HOST)/stamp/.rust_$(RUSTC_HOST_ARCH)_installed + +# Rust Environmental Vars +CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)") +RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX) +RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME) +CARGO_HOME:=$(STAGING_DIR_HOST)/.cargo + +# Common Build Flags +RUST_BUILD_FLAGS = \ + LD_LIBRARY_PATH=$(LLVM_DIR)/lib \ + CARGO_HOME="$(CARGO_HOME)" \ + CXXFLAGS=-DLLVM_RUSTLLVM + +# Use External rust-lang specific LLVM +RUST_UNINSTALL:=$(STAGING_DIR_HOST)/lib/rustlib/uninstall.sh +RUST_TMP_DIR:=$(TMP_DIR)/rust-install + +# Set Configure Environmentals +HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)" + +# The Flags are Common between HOST and TARGET +RUST_COMMON_ARGS := \ + --build=$(RUSTC_HOST_ARCH) \ + --host=$(RUSTC_HOST_ARCH) \ + --dist-compression-formats=xz \ + --enable-llvm-link-shared \ + --enable-llvm-plugins \ + --enable-missing-tools \ + --enable-ninja \ + --enable-optimize \ + --enable-optimize-llvm \ + --enable-parallel-compiler \ + --enable-sanitizers \ + --release-channel=nightly \ + --prefix=$(STAGING_DIR_HOST) \ + --bindir=$(STAGING_DIR_HOST)/bin \ + --libdir=$(STAGING_DIR_HOST)/lib \ + --sysconfdir=$(STAGING_DIR_HOST)/etc \ + --datadir=$(STAGING_DIR_HOST)/share \ + --mandir=$(STAGING_DIR_HOST)/man \ + --set=build.extended=true + +ifeq ($(CONFIG_CCACHE),y) +RUST_COMMON_ARGS += --set=llvm.ccache=true +endif + +## +# Because OpenWrt uses default configure flags that are not recognized +# we override the default and set our own. +# +# Rust HOST Configuration Arguments +HOST_CONFIGURE_ARGS = \ + --target=$(RUSTC_HOST_ARCH) \ + $(RUST_COMMON_ARGS) \ + --set=llvm.targets="AArch64;ARM;Mips;PowerPC;X86" \ + --set=llvm.experimental-targets='' \ + --set=llvm.version-suffix='' \ + --set=llvm.link-jobs=0 + + +define Host/Uninstall + # Call the Uninstall script + [ -f $(RUST_UNINSTALL) ] && \ + $(BASH) $(RUST_UNINSTALL) || echo No Uninstall + + rm -rf $(RUST_TMP_DIR) $(CARGO_HOME) + rm -rf $(STAGING_DIR_HOST)/llvm-rust* $(STAGING_DIR_HOST)/lib/libLLVM-14.so $(STAGING_DIR_HOST)/lib/libLLVM.so \ + $(STAGING_DIR_HOST)/lib/libLLVM-14.0.1.so $(STAGING_DIR_HOST)/lib/libLTO.so $(STAGING_DIR_HOST)/lib/libRemarks.so +endef + +LLVM_DIR:=$(STAGING_DIR_HOST)/llvm-rust +RUST_LLVM_DIR:=$(HOST_BUILD_DIR)/build/$(RUSTC_HOST_ARCH)/llvm + +# Installation is done via Host/Compile +define Host/Install + cp -rf $(RUST_LLVM_DIR) $(LLVM_DIR) + ln -sf $(LLVM_DIR)/lib/libLLVM-14.so $(STAGING_DIR_HOST)/lib/libLLVM.so + ln -sf $(LLVM_DIR)/lib/libLLVM-14.so $(STAGING_DIR_HOST)/lib/libLLVM-14.so + ln -sf $(LLVM_DIR)/lib/libLLVM-14.so $(STAGING_DIR_HOST)/lib/libLLVM-14.0.1.so + ln -sf $(LLVM_DIR)/lib/libLTO.so.14 $(STAGING_DIR_HOST)/lib/libLTO.so + ln -sf $(LLVM_DIR)/lib/libRemarks.so.14 $(STAGING_DIR_HOST)/lib/libRemarks.so +endef + +define Host/Prepare + # Ensure rust temp directory + [ -d $(RUST_TMP_DIR) ] || \ + mkdir -p $(RUST_TMP_DIR) + + $(call Host/Prepare/Default) +endef + +### +# Build out stage1 artifacts only, stage2 is not needed +# Only build out minimal tools required to build the tuples +define Host/Compile + cd $(HOST_BUILD_DIR) && \ + CXXFLAGS='$(HOST_CXXFLAGS)' \ + LD_LIBRARY_PATH=$(LLVM_DIR)/lib:$(STAGING_DIR_HOST)/lib \ + CARGO_HOME="$(CARGO_HOME)" \ + $(PYTHON) x.py install --config ./config.toml +endef +# $(PYTHON) x.py install --config ./config.toml --stage 1 cargo \ +# library/std rustfmt src src/librustc + +$(eval $(call HostBuild)) +# $(eval $(call BuildPackage,rust_host)) diff --git a/lang/rust_host/patches/03-add_mips.patch b/lang/rust_host/patches/03-add_mips.patch new file mode 100644 index 0000000..db48710 --- /dev/null +++ b/lang/rust_host/patches/03-add_mips.patch @@ -0,0 +1,30 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1016,6 +1016,7 @@ + ("x86_64-unknown-none", x86_64_unknown_none), + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), ++ ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mips_openwrt_linux_musl.rs +@@ -0,0 +1,17 @@ ++use crate::abi::Endian; ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "mips32r2".into(); ++ base.features = "+mips32r2,+soft-float".into(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mips-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), ++ arch: "mips".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} diff --git a/lang/rust_host/patches/04-add_mipsel.patch b/lang/rust_host/patches/04-add_mipsel.patch new file mode 100644 index 0000000..b64f1ea --- /dev/null +++ b/lang/rust_host/patches/04-add_mipsel.patch @@ -0,0 +1,29 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mipsel_openwrt_linux_musl.rs +@@ -0,0 +1,16 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "mips32r2".into(); ++ base.features = "+mips32r2,+soft-float".into(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mipsel-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), ++ arch: "mips".into(), ++ options: TargetOptions { mcount: "_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1015,6 +1015,7 @@ + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), ++ ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/05-add_aarch64.patch b/lang/rust_host/patches/05-add_aarch64.patch new file mode 100644 index 0000000..0d21d6f --- /dev/null +++ b/lang/rust_host/patches/05-add_aarch64.patch @@ -0,0 +1,27 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/aarch64_openwrt_linux_musl.rs +@@ -0,0 +1,14 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.max_atomic_width = Some(128); ++ ++ Target { ++ llvm_target: "aarch64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), ++ arch: "aarch64".into(), ++ options: TargetOptions { mcount: "\u{1}_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1016,6 +1016,7 @@ + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), ++ ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/06-add_armv7.patch b/lang/rust_host/patches/06-add_armv7.patch new file mode 100644 index 0000000..e00aa61 --- /dev/null +++ b/lang/rust_host/patches/06-add_armv7.patch @@ -0,0 +1,38 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv7_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,25 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++// This target is for musl Linux on ARMv7 without thumb-mode, NEON or ++// hardfloat. ++ ++pub fn target() -> Target { ++ // Most of these settings are copied from the armv7_unknown_linux_gnueabi ++ // target. ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "armv7-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ ++ options: TargetOptions { ++ abi: "eabi".into(), ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1017,6 +1017,7 @@ + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), ++ ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/07-add_armv7hf.patch b/lang/rust_host/patches/07-add_armv7hf.patch new file mode 100644 index 0000000..f06f799 --- /dev/null +++ b/lang/rust_host/patches/07-add_armv7hf.patch @@ -0,0 +1,37 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv7_openwrt_linux_muslgnueabihf.rs +@@ -0,0 +1,24 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++// This target is for musl Linux on ARMv7 without thumb-mode or NEON. ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and LLVM ++ // doesn't support the "musleabihf" value. ++ llvm_target: "armv7-unknown-linux-gnueabihf".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ ++ // Most of these settings are copied from the armv7_unknown_linux_gnueabihf ++ // target. ++ options: TargetOptions { ++ abi: "eabihf".into(), ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1018,6 +1018,7 @@ + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), ++ ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/08-add_powerpc64.patch b/lang/rust_host/patches/08-add_powerpc64.patch new file mode 100644 index 0000000..1d73df4 --- /dev/null +++ b/lang/rust_host/patches/08-add_powerpc64.patch @@ -0,0 +1,30 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/powerpc64_openwrt_linux_musl.rs +@@ -0,0 +1,17 @@ ++use crate::abi::Endian; ++use crate::spec::{LinkerFlavor, Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "ppc64".into(); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); ++ base.max_atomic_width = Some(64); ++ ++ Target { ++ llvm_target: "powerpc64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), ++ arch: "powerpc64".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1019,6 +1019,7 @@ + ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), ++ ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/09-add_x86_64.patch b/lang/rust_host/patches/09-add_x86_64.patch new file mode 100644 index 0000000..b1e2b4b --- /dev/null +++ b/lang/rust_host/patches/09-add_x86_64.patch @@ -0,0 +1,38 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/x86_64_openwrt_linux_musl.rs +@@ -0,0 +1,25 @@ ++use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "x86-64".into(); ++ base.max_atomic_width = Some(64); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into()); ++ // don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved ++ base.stack_probes = StackProbeType::Call; ++ base.static_position_independent_executables = true; ++ base.supported_sanitizers = SanitizerSet::ADDRESS ++ | SanitizerSet::CFI ++ | SanitizerSet::LEAK ++ | SanitizerSet::MEMORY ++ | SanitizerSet::THREAD; ++ ++ Target { ++ llvm_target: "x86_64-unknown-linux-musl".into(), ++ pointer_width: 64, ++ data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" ++ .into(), ++ arch: "x86_64".into(), ++ options: base, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1020,6 +1020,7 @@ + ("armv7-openwrt-linux-muslgnueabi", armv7_openwrt_linux_muslgnueabi), + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), ++ ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/10-add_arm.patch b/lang/rust_host/patches/10-add_arm.patch new file mode 100644 index 0000000..e5580ce --- /dev/null +++ b/lang/rust_host/patches/10-add_arm.patch @@ -0,0 +1,34 @@ +--- /dev/null 2022-04-12 18:46:38.250000000 -0400 ++++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "arm-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabi ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1030,6 +1030,7 @@ supported_targets! { + ("armv7-openwrt-linux-muslgnueabihf", armv7_openwrt_linux_muslgnueabihf), + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), ++ ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/11-add_armhf.patch b/lang/rust_host/patches/11-add_armhf.patch new file mode 100644 index 0000000..9ccddbd --- /dev/null +++ b/lang/rust_host/patches/11-add_armhf.patch @@ -0,0 +1,34 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_muslgnueabihf.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and it ++ // doesn't support the "musleabihf" value. ++ llvm_target: "arm-unknown-linux-gnueabihf".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabihf".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabihf ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1031,6 +1031,7 @@ supported_targets! { + ("powerpc64-openwrt-linux-musl", powerpc64_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), ++ ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/12-add_armv5tej.patch b/lang/rust_host/patches/12-add_armv5tej.patch new file mode 100644 index 0000000..750d432 --- /dev/null +++ b/lang/rust_host/patches/12-add_armv5tej.patch @@ -0,0 +1,36 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv5tej_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,23 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // FIXME: this comment below does not seem applicable? ++ // It's important we use "gnueabihf" and not "musleabihf" here. LLVM ++ // uses it to determine the calling convention and float ABI, and LLVM ++ // doesn't support the "musleabihf" value. ++ llvm_target: "armv5tej-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Atomic operations provided by compiler-builtins ++ max_atomic_width: None, ++ atomic_cas: false, ++ mcount: "\u{1}mcount".into(), ++ has_thumb_interworking: true, ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1032,6 +1032,7 @@ supported_targets! { + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), ++ ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/13-add_armv6k.patch b/lang/rust_host/patches/13-add_armv6k.patch new file mode 100644 index 0000000..0d2e0ac --- /dev/null +++ b/lang/rust_host/patches/13-add_armv6k.patch @@ -0,0 +1,34 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/armv6k_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,21 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ Target { ++ // It's important we use "gnueabi" and not "musleabi" here. LLVM uses it ++ // to determine the calling convention and float ABI, and it doesn't ++ // support the "musleabi" value. ++ llvm_target: "armv6k-unknown-linux-gnueabi".into(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(), ++ arch: "arm".into(), ++ options: TargetOptions { ++ abi: "eabi".into(), ++ // Most of these settings are copied from the arm_unknown_linux_gnueabi ++ // target. ++ max_atomic_width: Some(64), ++ mcount: "\u{1}mcount".into(), ++ ..super::linux_musl_base::opts() ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1033,6 +1033,7 @@ supported_targets! { + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), ++ ("armv6k-openwrt-linux-muslgnueabi", armv6k_openwrt_linux_muslgnueabi), + } + + /// Warnings encountered when parsing the target `json`. diff --git a/lang/rust_host/patches/14-add_powerpc.patch b/lang/rust_host/patches/14-add_powerpc.patch new file mode 100644 index 0000000..5ad20d4 --- /dev/null +++ b/lang/rust_host/patches/14-add_powerpc.patch @@ -0,0 +1,29 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -1034,6 +1034,7 @@ supported_targets! { + ("arm-openwrt-linux-muslgnueabihf", arm_openwrt_linux_muslgnueabihf), + ("armv5tej-openwrt-linux-muslgnueabi", armv5tej_openwrt_linux_muslgnueabi), + ("armv6k-openwrt-linux-muslgnueabi", armv6k_openwrt_linux_muslgnueabi), ++ ("powerpc-openwrt-linux-musl", powerpc_openwrt_linux_musl), + } + + /// Warnings encountered when parsing the target `json`. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/powerpc_openwrt_linux_musl.rs +@@ -0,0 +1,16 @@ ++use crate::abi::Endian; ++use crate::spec::{LinkerFlavor, Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".into()); ++ base.max_atomic_width = Some(32); ++ ++ Target { ++ llvm_target: "powerpc-unknown-linux-musl".into(), ++ pointer_width: 32, ++ data_layout: "E-m:e-p:32:32-i64:64-n32".into(), ++ arch: "powerpc".into(), ++ options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, ++ } ++} -- cgit v1.2.3