rust: init version 1.95.0

Signed-off-by: gitea-action <git@cooluc.com>
This commit is contained in:
gitea-action
2026-05-11 03:04:05 +08:00
commit 509dd13080
6 changed files with 383 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
menu "Configuration options (for developers)"
config RUST_SCCACHE
bool "Use sccache"
help
Shared compilation cache; see https://github.com/mozilla/sccache
config RUST_SCCACHE_DIR
string "Set sccache directory" if RUST_SCCACHE
default ""
help
Store sccache in this directory.
If not set, uses './.sccache'
endmenu
+109
View File
@@ -0,0 +1,109 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
include $(TOPDIR)/rules.mk
PKG_NAME:=rust
PKG_VERSION:=1.95.0
PKG_RELEASE:=1
PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.xz
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
PKG_HASH:=62b67230754da642a264ca0cb9fc08820c54e2ed7b3baba0289876d4cdb48c08
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src
PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
PKG_CPE_ID:=cpe:/a:rust-lang:rust
PKG_HOST_ONLY:=1
PKG_BUILD_FLAGS:=no-mips16
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ./rust-values.mk
define Package/rust
SECTION:=lang
CATEGORY:=Languages
SUBMENU:=Rust
TITLE:=Rust Programming Language Compiler
URL:=https://www.rust-lang.org/
DEPENDS:=$(RUST_ARCH_DEPENDS)
endef
define Package/rust/description
Rust is a multi-paradigm, general-purpose programming language designed for performance
and safety, especially safe concurrency. Rust is syntactically similar to C++, but can
guarantee memory safety by using a borrow checker to validate references.
endef
define Package/rust/config
source "$(SOURCE)/Config.in"
endef
# Rust-lang has an uninstall script
RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh
# Target Flags
TARGET_CONFIGURE_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).ranlib=$(TARGET_RANLIB) \
--set=target.$(RUSTC_TARGET_ARCH).crt-static=false \
$(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_ROOT_DIR))
# CARGO_HOME is an environmental
HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"
# Rust Configuration Arguments
HOST_CONFIGURE_ARGS = \
--build=$(RUSTC_HOST_ARCH) \
--target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
--host=$(RUSTC_HOST_ARCH) \
--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 \
--dist-compression-formats=gz \
--disable-sanitizers \
--release-channel=stable \
--enable-cargo-native-static \
--bootstrap-cache-path=$(DL_DIR)/rustc \
--set=llvm.download-ci-llvm=true \
$(TARGET_CONFIGURE_ARGS)
define Host/Uninstall
# Call the Uninstall script
[ -f $(RUST_UNINSTALL) ] && \
$(BASH) $(RUST_UNINSTALL) || echo No Uninstall
endef
define Host/Compile
$(RUST_SCCACHE_VARS) \
CARGO_HOME=$(CARGO_HOME) \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
$(PYTHON) $(HOST_BUILD_DIR)/x.py \
--build-dir $(HOST_BUILD_DIR)/build \
dist build-manifest rustc rust-std cargo llvm-tools rust-src
endef
define Host/Install
( \
cd $(HOST_BUILD_DIR)/build/dist ; \
for targz in *.tar.gz; do \
$(STAGING_DIR_HOST)/bin/libdeflate-gzip -dc "$$$$targz" | tar -xf - ; \
done ; \
find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
-execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
)
endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,rust))
@@ -0,0 +1,20 @@
From d3000458501d339ea2043006924d431ead18769e Mon Sep 17 00:00:00 2001
From: Luca Barbato <lu_zero@gentoo.org>
Date: Sun, 4 Jun 2023 19:32:28 +0000
Subject: [PATCH] Update xz2 and use it static
---
src/bootstrap/Cargo.toml | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -54,7 +54,7 @@ tar = { version = "0.4.44", default-feat
termcolor = "1.4"
toml = "0.5"
walkdir = "2.4"
-xz2 = "0.1"
+xz2 = { version = "0.1", features = ["static"] }
# Dependencies needed by the build-metrics feature
sysinfo = { version = "0.37.0", default-features = false, optional = true, features = ["system"] }
+68
View File
@@ -0,0 +1,68 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
# Variables (all optional) to be set in package Makefiles:
#
# RUST_HOST_FEATURES - list of options, default empty
#
# Space or comma separated list of features to activate
#
# e.g. RUST_HOST_FEATURES:=enable-foo,with-bar
#
#
# RUST_HOST_LOCKED - Assert that `Cargo.lock` will remain unchanged
# (Enabled by default)
#
# Disable it if you want to have up-to-date dependencies
#
# e.g. RUST_HOST_LOCKED:=0
ifeq ($(origin RUST_INCLUDE_DIR),undefined)
RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
RUST_HOST_LOCKED ?= 1
CARGO_HOST_VARS= \
$(CARGO_HOST_CONFIG_VARS) \
CC=$(HOSTCC_NOCACHE) \
MAKEFLAGS="$(HOST_JOBS)"
CARGO_HOST_ARGS=
ifeq ($(strip $(RUST_HOST_LOCKED)),1)
CARGO_HOST_ARGS+= --locked
endif
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Host/Compile/Cargo
+$(CARGO_HOST_VARS) \
cargo install -v \
--profile $(CARGO_HOST_PROFILE) \
$(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
--root $(HOST_INSTALL_DIR) \
--path "$(HOST_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)),$(strip $(HOST_MAKE_PATH)))" \
$(if $(filter --jobserver%,$(HOST_JOBS)),,-j1) \
$(CARGO_HOST_ARGS) \
$(2)
endef
define Host/Uninstall/Cargo
+$(CARGO_HOST_VARS) \
cargo uninstall -v \
--root $(HOST_INSTALL_DIR) \
|| true
endef
define RustBinHostBuild
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin
$(INSTALL_BIN) $(HOST_INSTALL_DIR)/bin/* $(STAGING_DIR_HOSTPKG)/bin/
endef
endef
Host/Compile=$(call Host/Compile/Cargo)
Host/Uninstall=$(call Host/Uninstall/Cargo)
+63
View File
@@ -0,0 +1,63 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
# Variables (all optional) to be set in package Makefiles:
#
# RUST_PKG_FEATURES - list of options, default empty
#
# Space or comma separated list of features to activate
#
# e.g. RUST_PKG_FEATURES:=enable-foo,with-bar
#
#
# RUST_PKG_LOCKED - Assert that `Cargo.lock` will remain unchanged
# (Enabled by default)
#
# Disable it if you want to have up-to-date dependencies
#
# e.g. RUST_PKG_LOCKED:=0
ifeq ($(origin RUST_INCLUDE_DIR),undefined)
RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
RUST_PKG_LOCKED ?= 1
CARGO_PKG_VARS= \
$(CARGO_PKG_CONFIG_VARS) \
CC=$(HOSTCC_NOCACHE) \
MAKEFLAGS="$(PKG_JOBS)"
CARGO_PKG_ARGS=
ifeq ($(strip $(RUST_PKG_LOCKED)),1)
CARGO_PKG_ARGS+= --locked
endif
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Build/Compile/Cargo
+$(CARGO_PKG_VARS) \
cargo install -v \
--profile $(CARGO_PKG_PROFILE) \
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
--root $(PKG_INSTALL_DIR) \
--path "$(PKG_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)),$(strip $(MAKE_PATH)))" \
$(if $(filter --jobserver%,$(PKG_JOBS)),,-j1) \
$(CARGO_PKG_ARGS) \
$(2)
endef
define RustBinPackage
ifndef Package/$(1)/install
define Package/$(1)/install
$$(INSTALL_DIR) $$(1)/usr/bin/
$$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/bin/* $$(1)/usr/bin/
endef
endif
endef
Build/Compile=$(call Build/Compile/Cargo)
+108
View File
@@ -0,0 +1,108 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
# Clear environment variables which should be handled internally,
# as users might configure their own env on the host
# CCache
unexport RUSTC_WRAPPER
# Rust Environmental Vars
RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
CARGO_HOME:=$(DL_DIR)/cargo
ifeq ($(CONFIG_USE_MUSL),y)
# Force linking of the SSP library for musl
ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
ifeq ($(strip $(PKG_SSP)),1)
RUSTC_LDFLAGS+=-lssp_nonshared
endif
endif
ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
ifeq ($(strip $(PKG_SSP)),1)
RUSTC_LDFLAGS+=-lssp_nonshared
endif
endif
endif
CARGO_RUSTFLAGS+=-Ctarget-feature=-crt-static $(RUSTC_LDFLAGS)
ifeq ($(HOST_OS),Darwin)
ifeq ($(HOST_ARCH),arm64)
RUSTC_HOST_ARCH:=aarch64-apple-darwin
endif
endif
# mips64 openwrt has a specific target in rustc
ifeq ($(ARCH),mips64)
RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME)
else
RUSTC_TARGET_ARCH:=$(subst openwrt,unknown,$(REAL_GNU_TARGET_NAME))
endif
RUSTC_TARGET_ARCH:=$(subst muslgnueabi,musleabi,$(RUSTC_TARGET_ARCH))
ifeq ($(ARCH),i386)
RUSTC_TARGET_ARCH:=$(subst i486,i586,$(RUSTC_TARGET_ARCH))
else ifeq ($(ARCH),riscv64)
RUSTC_TARGET_ARCH:=$(subst riscv64,riscv64gc,$(RUSTC_TARGET_ARCH))
endif
# ARM Logic
ifeq ($(ARCH),arm)
ifeq ($(CONFIG_arm_v6)$(CONFIG_arm_v7),)
RUSTC_TARGET_ARCH:=$(subst arm,armv5te,$(RUSTC_TARGET_ARCH))
else ifeq ($(CONFIG_arm_v7),y)
RUSTC_TARGET_ARCH:=$(subst arm,armv7,$(RUSTC_TARGET_ARCH))
endif
ifeq ($(CONFIG_HAS_FPU),y)
RUSTC_TARGET_ARCH:=$(subst musleabi,musleabihf,$(RUSTC_TARGET_ARCH))
RUSTC_TARGET_ARCH:=$(subst gnueabi,gnueabihf,$(RUSTC_TARGET_ARCH))
endif
endif
ifeq ($(ARCH),aarch64)
RUSTC_CFLAGS:=-mno-outline-atomics
endif
# Support only a subset for now.
RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||loongarch64||mips||mips64||mips64el||mipsel||powerpc||powerpc64||riscv64||x86_64)
ifneq ($(CONFIG_RUST_SCCACHE),)
RUST_SCCACHE_DIR:=$(if $(call qstrip,$(CONFIG_RUST_SCCACHE_DIR)),$(call qstrip,$(CONFIG_RUST_SCCACHE_DIR)),$(TOPDIR)/.sccache)
RUST_SCCACHE_VARS:= \
CARGO_INCREMENTAL=0 \
RUSTC_WRAPPER=sccache \
SCCACHE_DIR=$(RUST_SCCACHE_DIR)
endif
CARGO_HOST_CONFIG_VARS= \
$(RUST_SCCACHE_VARS) \
CARGO_HOME=$(CARGO_HOME)
CARGO_HOST_PROFILE:=release
CARGO_PKG_CONFIG_VARS= \
$(RUST_SCCACHE_VARS) \
CARGO_BUILD_TARGET=$(RUSTC_TARGET_ARCH) \
CARGO_HOME=$(CARGO_HOME) \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
CARGO_PROFILE_RELEASE_DEBUG=false \
CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=false \
CARGO_PROFILE_RELEASE_LTO=true \
CARGO_PROFILE_RELEASE_OPT_LEVEL=z \
CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS=true \
CARGO_PROFILE_RELEASE_PANIC=unwind \
CARGO_PROFILE_RELEASE_RPATH=false \
CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \
RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
TARGET_CC=$(TARGET_CC_NOCACHE) \
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)"
CARGO_PKG_PROFILE:=$(if $(CONFIG_DEBUG),dev,release)
CARGO_RUSTFLAGS+=-Clink-arg=-fuse-ld=$(TARGET_LINKER)