diff --git a/lang/rust/Config.in b/lang/rust/Config.in new file mode 100644 index 00000000000000..38ecb4782e49e2 --- /dev/null +++ b/lang/rust/Config.in @@ -0,0 +1,117 @@ +# Rust Language Options +menu "Compiler Options" + depends on 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 n + + 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 00000000000000..a3c81b93a66dfd --- /dev/null +++ b/lang/rust/Makefile @@ -0,0 +1,130 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_NAME:=rust +PKG_VERSION:=1.50.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:=2021-02-10 +PKG_SOURCE_VERSION:=cb75ad5db02783e8b0222fee363c5f63f7e2cf5b +PKG_MIRROR_HASH:=747c6a9f26d143e0ef95f1be4c6ac814e2d5eead1811cba797b04e71f720df02 +PKG_HOST_ONLY:=1 + +include $(INCLUDE_DIR)/cmake.mk +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/download.mk + +HOST_BUILD_DEPENDS:=ninja/host python3/host +PKG_BUILD_DEPENDS:=rust/host +CMAKE_INSTALL:=1 + +# These are environment variables that are used by other packages to +# define where rustc/cargo are kept. +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_HOSTPKG) + +# Basic Configuration Args that are used across all builds. +# Other build arguments are found in ./rustc-config.mk +# +# Default CONFIGURE_ARGS introduces unknown options - Use this instead +CONFIGURE_ARGS = \ + --host=$(RUSTC_HOST_ARCH) \ + --build=$(RUSTC_HOST_ARCH) \ + --target=$(RUSTC_TARGET_ARCH) \ + --prefix=$(CARGO_HOME) \ + --bindir=$(CARGO_HOME)/bin \ + --libdir=$(CARGO_HOME)/lib \ + --sysconfdir=$(CARGO_HOME)/etc \ + --datadir=$(CARGO_HOME)/share \ + --mandir=$(CARGO_HOME)/man \ + --infodir=$(CARGO_HOME)/info \ + --localstatedir=/var \ + --release-channel=nightly \ + --enable-lld + +ifeq ($(CONFIG_USE_MUSL),y) +CONFIGURE_ARGS += \ + --set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \ + --set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \ + --set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) +endif + +# Because we override CONFIGURE_ARGS, this needs to go here. +include ./rustc-config.mk + +RUST_TMP_DIR:=$(TMP_DIR)/rust-install +RUST_INSTALL_HOST_FILE_NAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_HOST_ARCH)-install.tar.xz +RUST_INSTALL_TARGET_FILE_NAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_TARGET_ARCH)-install.tar.xz + +RUST_INSTALL_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh + +RUST_INSTALL_HOST_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_HOST_FILE_NAME) $(CARGO_HOME) +RUST_INSTALL_TARGET_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_TARGET_FILE_NAME) $(CARGO_HOME) + +RUST_HOST_BINARY:=$(or $(and $(wildcard $(DL_DIR)/$(RUST_INSTALL_HOST_FILE_NAME)),true),false) +RUST_TARGET_BINARY:=$(or $(and $(wildcard $(DL_DIR)/$(RUST_INSTALL_TARGET_FILE_NAME)),true),false) + +# If the HOST Install doesn't exist, force building all the tools +ifeq ($(RUST_HOST_BINARY), false) +CONFIGURE_ARGS += \ + --enable-full-tools +endif + +define Host/Clean + $(call Host/Clean/Default) + + [ -f $(RUST_INSTALL_UNINSTALL) ] && \ + $(RUST_INSTALL_UNINSTALL) || echo No Uninstall Found + + rm -rf $(BUILD_DIR_HOST)/rust +endef + +define Host/Prepare + # Allows outside packages to call $$(BUILD_DIR_HOST)/rust as the dir + # rather than needing the version number. + [ -L $(BUILD_DIR_HOST)/rust ] || \ + (cd $(BUILD_DIR_HOST); ln -s "$(PKG_NAME)-$(PKG_VERSION)" rust) + + [ -d $(RUST_TMP_DIR) ] || \ + mkdir -p $(RUST_TMP_DIR) + + $(call Host/Prepare/Default) +endef + +ifeq ($(RUST_TARGET_BINARY),true) +include ./rust_install.mk +else +include ./rust_compile.mk +endif + +define Package/rust + SECTION:=lang + CATEGORY:=Languages + TITLE:=Rust Programming Language Compiler + URL:=https://www.rust-lang.org/ + DEPENDS:=+python3 +ninja +pkg-config +libopenssl +libyaml \ + +libyaml-cpp +libunwind +openssl-util +python3-yaml +endef + +define Package/rust/description + Rust lang +endef + +define Package/rust/config + source "$(SOURCE)/Config.in" +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,rust)) diff --git a/lang/rust/install_binaries.sh b/lang/rust/install_binaries.sh new file mode 100755 index 00000000000000..efe0e5c6d63be2 --- /dev/null +++ b/lang/rust/install_binaries.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# Rust Langauge Host Installer +# +TMP_DIR=$1 +RUST_INSTALL_FILE_NAME=$2 +CARGO_HOME=$3 + +tar -C $TMP_DIR -xvJf $RUST_INSTALL_FILE_NAME + +cd $TMP_DIR && \ + find -iname "*.xz" -exec tar -v -x -J -f {} ";" && \ + find ./* -type f -name install.sh -execdir sh {} --prefix=$CARGO_HOME --disable-ldconfig \; diff --git a/lang/rust/patches/00-default_dynamic_linking.patch b/lang/rust/patches/00-default_dynamic_linking.patch new file mode 100644 index 00000000000000..11c1df8832ac4b --- /dev/null +++ b/lang/rust/patches/00-default_dynamic_linking.patch @@ -0,0 +1,11 @@ +--- a/compiler/rustc_target/src/spec/linux_musl_base.rs ++++ b/compiler/rustc_target/src/spec/linux_musl_base.rs +@@ -10,7 +10,7 @@ + base.crt_objects_fallback = Some(CrtObjectsFallback::Musl); + + // These targets statically link libc by default +- base.crt_static_default = true; ++ base.crt_static_default = false; + + base + } diff --git a/lang/rust/patches/01-add_mips64_musl_support.patch b/lang/rust/patches/01-add_mips64_musl_support.patch new file mode 100644 index 00000000000000..a4b46a7a38f575 --- /dev/null +++ b/lang/rust/patches/01-add_mips64_musl_support.patch @@ -0,0 +1,30 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mips64_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 = "mips64r2".to_string(); ++ base.features = "+mips64r2,+soft-float".to_string(); ++ base.max_atomic_width = Some(64); ++ Target { ++ // LLVM doesn't recognize "muslabi64" yet. ++ llvm_target: "mips64-unknown-linux-musl".to_string(), ++ pointer_width: 64, ++ data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(), ++ arch: "mips64".to_string(), ++ options: TargetOptions { endian: "big".to_string(), mcount: "_mcount".to_string(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -662,6 +662,8 @@ supported_targets! { + ("mipsel-sony-psp", mipsel_sony_psp), + ("mipsel-unknown-none", mipsel_unknown_none), + ("thumbv4t-none-eabi", thumbv4t_none_eabi), ++ ++ ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. diff --git a/lang/rust/patches/02-add_mips_musl_support.patch b/lang/rust/patches/02-add_mips_musl_support.patch new file mode 100644 index 00000000000000..a65e4a2a675cdf --- /dev/null +++ b/lang/rust/patches/02-add_mips_musl_support.patch @@ -0,0 +1,29 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/mips_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".to_string(); ++ base.features = "+mips32r2,+soft-float".to_string(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mips-unknown-linux-musl".to_string(), ++ pointer_width: 32, ++ data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), ++ arch: "mips".to_string(), ++ options: TargetOptions { endian: "big".to_string(), mcount: "_mcount".to_string(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -664,6 +664,7 @@ supported_targets! { + ("thumbv4t-none-eabi", thumbv4t_none_eabi), + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), ++ ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. diff --git a/lang/rust/patches/03-add_x86_64_musl_support.patch b/lang/rust/patches/03-add_x86_64_musl_support.patch new file mode 100644 index 00000000000000..07b98823af6e6b --- /dev/null +++ b/lang/rust/patches/03-add_x86_64_musl_support.patch @@ -0,0 +1,32 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -665,6 +665,7 @@ supported_targets! { + + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), ++ ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/x86_64_openwrt_linux_musl.rs +@@ -0,0 +1,19 @@ ++use crate::spec::{LinkerFlavor, Target}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.cpu = "x86-64".to_string(); ++ base.max_atomic_width = Some(64); ++ base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); ++ base.stack_probes = true; ++ base.static_position_independent_executables = true; ++ ++ Target { ++ llvm_target: "x86_64-unknown-linux-musl".to_string(), ++ 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" ++ .to_string(), ++ arch: "x86_64".to_string(), ++ options: base, ++ } ++} diff --git a/lang/rust/patches/04-add_arm_muslgnuabi_support.patch b/lang/rust/patches/04-add_arm_muslgnuabi_support.patch new file mode 100644 index 00000000000000..29a3eab89d9390 --- /dev/null +++ b/lang/rust/patches/04-add_arm_muslgnuabi_support.patch @@ -0,0 +1,37 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/arm_openwrt_linux_muslgnueabi.rs +@@ -0,0 +1,24 @@ ++use crate::spec::{Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ ++ // Most of these settings are copied from the arm_unknown_linux_gnueabi ++ // target. ++ base.features = "+strict-align,+v6".to_string(); ++ base.max_atomic_width = Some(64); ++ 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".to_string(), ++ pointer_width: 32, ++ data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), ++ arch: "arm".to_string(), ++ options: TargetOptions { ++ unsupported_abis: super::arm_base::unsupported_abis(), ++ mcount: "\u{1}mcount".to_string(), ++ ..base ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -666,6 +666,7 @@ supported_targets! { + ("mips64-openwrt-linux-musl", mips64_openwrt_linux_musl), + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), ++ ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + } + + /// Everything `rustc` knows about how to compile for a specific target. diff --git a/lang/rust/patches/05-add_powerpc_musl_support.patch b/lang/rust/patches/05-add_powerpc_musl_support.patch new file mode 100644 index 00000000000000..47bd1b38a84afe --- /dev/null +++ b/lang/rust/patches/05-add_powerpc_musl_support.patch @@ -0,0 +1,28 @@ +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -667,6 +667,7 @@ supported_targets! { + ("mips-openwrt-linux-musl", mips_openwrt_linux_musl), + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), ++ ("powerpc-openwrt-linux-musl", powerpc_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. +--- /dev/null ++++ b/compiler/rustc_target/src/spec/powerpc_openwrt_linux_musl.rs +@@ -0,0 +1,15 @@ ++use crate::spec::{LinkerFlavor, Target, TargetOptions}; ++ ++pub fn target() -> Target { ++ let mut base = super::linux_musl_base::opts(); ++ base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); ++ base.max_atomic_width = Some(32); ++ ++ Target { ++ llvm_target: "powerpc-unknown-linux-musl".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: "big".to_string(), mcount: "_mcount".to_string(), ..base }, ++ } ++} diff --git a/lang/rust/patches/06-add_mipsel_musl_support.patch b/lang/rust/patches/06-add_mipsel_musl_support.patch new file mode 100644 index 00000000000000..8f73f54229ea42 --- /dev/null +++ b/lang/rust/patches/06-add_mipsel_musl_support.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".to_string(); ++ base.features = "+mips32r2,+soft-float".to_string(); ++ base.max_atomic_width = Some(32); ++ base.crt_static_default = false; ++ Target { ++ llvm_target: "mipsel-unknown-linux-musl".to_string(), ++ pointer_width: 32, ++ data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), ++ arch: "mips".to_string(), ++ options: TargetOptions { mcount: "_mcount".to_string(), ..base }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -668,6 +668,7 @@ + ("x86_64-openwrt-linux-musl", x86_64_openwrt_linux_musl), + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("powerpc-openwrt-linux-musl", powerpc_openwrt_linux_musl), ++ ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. diff --git a/lang/rust/patches/07-add_aarch64_musl_support.patch b/lang/rust/patches/07-add_aarch64_musl_support.patch new file mode 100644 index 00000000000000..6c9c6d0025d394 --- /dev/null +++ b/lang/rust/patches/07-add_aarch64_musl_support.patch @@ -0,0 +1,31 @@ +--- /dev/null ++++ b/compiler/rustc_target/src/spec/aarch64_openwrt_linux_musl.rs +@@ -0,0 +1,18 @@ ++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".to_string(), ++ pointer_width: 64, ++ data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), ++ arch: "aarch64".to_string(), ++ options: TargetOptions { ++ unsupported_abis: super::arm_base::unsupported_abis(), ++ mcount: "\u{1}_mcount".to_string(), ++ ..base ++ }, ++ } ++} +--- a/compiler/rustc_target/src/spec/mod.rs ++++ b/compiler/rustc_target/src/spec/mod.rs +@@ -669,6 +669,7 @@ supported_targets! { + ("arm-openwrt-linux-muslgnueabi", arm_openwrt_linux_muslgnueabi), + ("powerpc-openwrt-linux-musl", powerpc_openwrt_linux_musl), + ("mipsel-openwrt-linux-musl", mipsel_openwrt_linux_musl), ++ ("aarch64-openwrt-linux-musl", aarch64_openwrt_linux_musl), + } + + /// Everything `rustc` knows about how to compile for a specific target. diff --git a/lang/rust/rust_compile.mk b/lang/rust/rust_compile.mk new file mode 100644 index 00000000000000..6c51e8033b52c7 --- /dev/null +++ b/lang/rust/rust_compile.mk @@ -0,0 +1,35 @@ +define Host/Configure + # Required because OpenWrt Default CONFIGURE_ARGS contain extra + # args that cause errors + cd $(HOST_BUILD_DIR) && \ + ./configure $(CONFIGURE_ARGS) +endef + +define Host/Compile + cd $(HOST_BUILD_DIR) && \ + [ $(RUST_HOST_BINARY) ] && ( $(RUST_INSTALL_HOST_BINARIES) && \ + $(PYTHON) x.py --config ./config.toml dist std ) || \ + $(PYTHON) x.py --config ./config.toml dist cargo extended \ + library/std llvm-tools miri +endef + +define Host/Install + cd $(HOST_BUILD_DIR)/build/dist && \ + $(RM) *.gz && \ + $(TAR) -cJf $(DL_DIR)/$(RUST_INSTALL_TARGET_FILE_NAME) \ + rust-std-nightly-$(RUSTC_TARGET_ARCH).tar.xz + + [ $(RUST_HOST_BINARY) = false ] && \ + cd $(HOST_BUILD_DIR)/build/dist && \ + $(TAR) -cJf $(DL_DIR)/$(RUST_INSTALL_HOST_FILE_NAME) --exclude rust-std-nightly-$(RUSTC_TARGET_ARCH).tar.xz *.xz || \ + true + + sh $(RUST_INSTALL_HOST_BINARIES) && \ + sh $(RUST_INSTALL_TARGET_BINARIES) + + +# cd $(RUST_TMP_DIR) && \ +# $(TAR) -xJf $(DL_DIR)/$(RUST_INSTALL_FILE_NAME) && \ +# find -iname "*.xz" -exec $(TAR) -x -J -f {} ";" && \ +# find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; +endef diff --git a/lang/rust/rust_install.mk b/lang/rust/rust_install.mk new file mode 100644 index 00000000000000..47d8223a8d9704 --- /dev/null +++ b/lang/rust/rust_install.mk @@ -0,0 +1,14 @@ +RUST_INSTALL_HOST_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_HOST_FILE_NAME) $(CARGO_HOME) +RUST_INSTALL_TARGET_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_TARGET_FILE_NAME) $(CARGO_HOME) +define Host/Configure + true +endef + +define Host/Compile + true +endef + +define Host/Install + sh $(RUST_INSTALL_HOST_BINARIES) && \ + sh $(RUST_INSTALL_TARGET_BINARIES) +endef diff --git a/lang/rust/rustc-config.mk b/lang/rust/rustc-config.mk new file mode 100644 index 00000000000000..72988f1185d90a --- /dev/null +++ b/lang/rust/rustc-config.mk @@ -0,0 +1,125 @@ + +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 + +ifeq ($(CONFIG_LIBC),"musl") +CONFIGURE_ARGS += \ + --set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR) +endif diff --git a/lang/rust/rustc-triple.mk b/lang/rust/rustc-triple.mk new file mode 100644 index 00000000000000..38ad6fe350c7fb --- /dev/null +++ b/lang/rust/rustc-triple.mk @@ -0,0 +1,30 @@ +# To enable rustc/cargo support in your packages, add: +# include $(TOPDIR)/feeds/packages/lang/rustup/rustc-triple.mk +# below include $(TOPDIR)/rules.mk +# +# You will need to add --host=$(RUSTC_TARGET_ARCH) to your packages +# CONFIGURE_VARS to cross-compile for the target architecture + +ifeq ($(CONFIG_arm_v7),y) +RUST_ARCH:=armv7 +else +RUST_ARCH:=$(ARCH) +endif + +CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)") + +RUSTC_HOST_ARCH:= \ + $(strip $(foreach \ + v, \ + $(filter $(HOST_ARCH)-%, $(RUSTC_ARCH_TARGETS)), \ + $(if $(findstring -$(CONFIG_HOST_SUFFIX:"%"=%),$v),$v) \ + ) \ + ) + + +RUSTC_HOST_ARCH:=$(GNU_HOST_NAME) +RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME) + +# These are environment variables that are used by other packages to +# define where rustc/cargo are kept. +CARGO_HOME:=$(STAGING_DIR_HOSTPKG)