From 8d4b80f769f8f91aba703ae85e4f46fdaf68ea8a Mon Sep 17 00:00:00 2001 From: Donald Hoskins Date: Thu, 18 Mar 2021 10:05:43 -0400 Subject: [PATCH] rust: Initial commit for rust-lang Signed-off-by: Donald Hoskins --- lang/rust/Config.in | 121 ++++++++++++++++ lang/rust/Makefile | 111 +++++++++++++++ lang/rust/install_binaries.sh | 13 ++ .../patches/00-default_dynamic_linking.patch | 11 ++ .../patches/01-add_mips64_musl_support.patch | 30 ++++ .../patches/02-add_mips_musl_support.patch | 29 ++++ .../patches/03-add_x86_64_musl_support.patch | 32 +++++ .../04-add_arm_muslgnuabi_support.patch | 37 +++++ .../patches/05-add_powerpc_musl_support.patch | 28 ++++ .../patches/06-add_mipsel_musl_support.patch | 29 ++++ lang/rust/rust_compile.mk | 22 +++ lang/rust/rust_install.mk | 11 ++ lang/rust/rustc-config.mk | 129 ++++++++++++++++++ lang/rust/rustc-triple.mk | 91 ++++++++++++ 14 files changed, 694 insertions(+) create mode 100644 lang/rust/Config.in create mode 100644 lang/rust/Makefile create mode 100755 lang/rust/install_binaries.sh create mode 100644 lang/rust/patches/00-default_dynamic_linking.patch create mode 100644 lang/rust/patches/01-add_mips64_musl_support.patch create mode 100644 lang/rust/patches/02-add_mips_musl_support.patch create mode 100644 lang/rust/patches/03-add_x86_64_musl_support.patch create mode 100644 lang/rust/patches/04-add_arm_muslgnuabi_support.patch create mode 100644 lang/rust/patches/05-add_powerpc_musl_support.patch create mode 100644 lang/rust/patches/06-add_mipsel_musl_support.patch create mode 100644 lang/rust/rust_compile.mk create mode 100644 lang/rust/rust_install.mk create mode 100644 lang/rust/rustc-config.mk create mode 100644 lang/rust/rustc-triple.mk diff --git a/lang/rust/Config.in b/lang/rust/Config.in new file mode 100644 index 00000000000000..e6849237d28795 --- /dev/null +++ b/lang/rust/Config.in @@ -0,0 +1,121 @@ +# 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 y + + 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 + bool "Build optimized rust code (--enable-optimize)" + 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 y + +endmenu diff --git a/lang/rust/Makefile b/lang/rust/Makefile new file mode 100644 index 00000000000000..cc1c3fabdd7934 --- /dev/null +++ b/lang/rust/Makefile @@ -0,0 +1,111 @@ +# 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.49.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:=2020-11-11 +PKG_SOURCE_VERSION:=fa55f668e5ea5388ec98b9340969527252239151 +PKG_MIRROR_HASH:=e7c3fefe77ee8c15b49fac4c89c9f7025c57e8f6ff3079d905e51a96bda3042d +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 +include ./rustc-triple.mk + +HOST_BUILD_DEPENDS:=ninja/host python3/host +PKG_BUILD_DEPENDS:=rust/host +CMAKE_INSTALL:=1 + +# 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 \ + --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) + +# Because we override CONFIGURE_ARGS, this needs to go here. +include ./rustc-config.mk + +RUST_TMP_DIR:=$(TMP_DIR)/rust-install +RUST_INSTALL_FILE_NAME:=$(PKG_NAME)-$(PKG_VERSION)-$(RUSTC_HOST_ARCH)_$(RUSTC_TARGET_ARCH)-install.tar.xz +RUST_INSTALL_FILE_VERIFY:=$(call check_hash,$(RUST_INSTALL_FILE_NAME),$(RUST_INSTALL_FILE_HASH),RUST_INSTALL_FILE_HASH) +RUST_INSTALL_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh +RUST_INSTALL_BINARIES:=$(CURDIR)/install_binaries.sh $(RUST_TMP_DIR) $(DL_DIR)/$(RUST_INSTALL_FILE_NAME) $(CARGO_HOME) +RUST_INSTALL_FILE_HASH:=skip + +RUST_BINARY=$(or $(and $(wildcard $(DL_DIR)/$(RUST_INSTALL_FILE_NAME)),true),false) + +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_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/rust_compile.mk b/lang/rust/rust_compile.mk new file mode 100644 index 00000000000000..e30ad511e43569 --- /dev/null +++ b/lang/rust/rust_compile.mk @@ -0,0 +1,22 @@ +define Host/Configure + # Required because OpenWrt Default CONFIGURE_ARGS contain extra + # args that cause errors + cd $(HOST_BUILD_DIR) && \ + RUST_BACKTRACE=full ./configure $(CONFIGURE_ARGS) +endef + +define Host/Compile + cd $(HOST_BUILD_DIR) && \ + RUST_BACKTRACE=full $(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 && \ + $(call dl_tar_pack,$(DL_DIR)/$(RUST_INSTALL_FILE_NAME),.) && \ + 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..ccf922d178f4b4 --- /dev/null +++ b/lang/rust/rust_install.mk @@ -0,0 +1,11 @@ +define Host/Configure + true +endef + +define Host/Compile + true +endef + +define Host/Install + sh $(RUST_INSTALL_BINARIES) +endef diff --git a/lang/rust/rustc-config.mk b/lang/rust/rustc-config.mk new file mode 100644 index 00000000000000..48edf1220a9461 --- /dev/null +++ b/lang/rust/rustc-config.mk @@ -0,0 +1,129 @@ + +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),y) +CONFIGURE_ARGS += --enable-optimize +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..f5efc58adcbcb0 --- /dev/null +++ b/lang/rust/rustc-triple.mk @@ -0,0 +1,91 @@ +# 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_ARCH_TARGETS:= \ +mips64-unknown-linux-gnuabi64 mips64-unknown-linux-muslabi64 \ +\ +armv7-unknown-linux-gnueabi armv7-unknown-linux-gnueabihf \ +armv7-unknown-linux-musleabi \ +\ +x86_64-unknown-linux-gnu x86_64-unknown-linux-musl + +RUSTC_ARCH_TARGETS:= \ +aarch64-unknown-linux-gnu aarch64-unknown-linux-musl \ +\ +arm-unknown-linux-gnueabi arm-unknown-linux-gnueabihf \ +arm-unknown-linux-musleabi arm-unknown-linux-musleabihf \ +\ +armv4t-unknown-linux-gnueabi \ +\ +armv5te-unknown-linux-gnueabi armv5te-unknown-linux-musleabi \ +\ +armv7-unknown-linux-gnueabi armv7-unknown-linux-gnueabihf \ +armv7-unknown-linux-musleabi \ +\ +hexagon-unknown-linux-musl \ +\ +i586-unknown-linux-gnu i586-unknown-linux-musl \ +\ +i686-unknown-linux-gnu i686-unknown-linux-musl \ +\ +mips-unknown-linux-gnu mips-unknown-linux-musl mips-unknown-linux-uclibc \ +\ +mips64-unknown-linux-gnuabi64 mips64-unknown-linux-muslabi64 \ +\ +mips64el-unknown-linux-gnuabi64 mips64el-unknown-linux-muslabi64 \ +\ +mipsel-unknown-linux-gnu mipsel-unknown-linux-musl \ +mipsel-unknown-linux-uclibc \ +\ +mipsisa32r6-unknown-linux-gnu mipsisa32r6el-unknown-linux-gnu \ +\ +mipsisa64r6-unknown-linux-gnuabi64 mipsisa64r6el-unknown-linux-gnuabi64 \ +\ +powerpc-unknown-linux-gnu powerpc-unknown-linux-musl \ +\ +powerpc64-unknown-linux-gnu powerpc64-unknown-linux-musl \ +\ +powerpc64le-unknown-linux-gnu powerpc64le-unknown-linux-musl \ +\ +riscv64gc-unknown-linux-gnu \ +\ +s390x-unknown-linux-gnu \ +\ +sparc-unknown-linux-gnu \ +\ +sparc64-unknown-linux-gnu \ +\ +thumbv7neon-unknown-linux-gnueabihf thumbv7neon-unknown-linux-musleabihf \ +\ +x86_64-unknown-linux-gnu x86_64-unknown-linux-musl + +RUSTC_HOST_ARCH:= \ + $(strip $(foreach \ + v, \ + $(filter $(HOST_ARCH)-%, $(RUSTC_ARCH_TARGETS)), \ + $(if $(findstring -$(CONFIG_HOST_SUFFIX:"%"=%),$v),$v) \ + ) \ + ) + +# More than one triple-target remains. +ifneq ($(word 2, $(RUSTC_TARGET_ARCH)),) +$(error RUSTC ERROR: Unsupported or Unknown Target Triple: $(RUSTC_TARGET_ARCH)) +endif + +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)