Skip to content

Commit

Permalink
Downgrade Rust for kernel 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Jan 20, 2024
1 parent 1013739 commit aa3db5a
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 304 deletions.
15 changes: 0 additions & 15 deletions rust/Config.in

This file was deleted.

58 changes: 26 additions & 32 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
# Copyright (C) 2023 Luca Barbato and Donald Hoskins

include $(TOPDIR)/rules.mk
include ./rust-values.mk

PKG_NAME:=rust
PKG_VERSION:=1.75.0
PKG_VERSION:=1.71.1
PKG_RELEASE:=1

PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
PKG_HASH:=5b739f45bc9d341e2d1c570d65d2375591e22c2d23ef5b8a37711a0386abc088
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src
PKG_HASH:=6fa90d50d1d529a75f6cc349784de57d7ec0ba2419b09bde7d335c25bd4e472e
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rust-$(RUSTC_TARGET_ARCH)/rustc-$(PKG_VERSION)-src

PKG_MAINTAINER:=Luca Barbato <[email protected]>
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

HOST_BUILD_DEPENDS:=python3/host
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
Expand All @@ -39,12 +39,8 @@ define Package/rust/description
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
RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh

# Target Flags
TARGET_CONFIGURE_ARGS = \
Expand All @@ -53,24 +49,23 @@ TARGET_CONFIGURE_ARGS = \
--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_DIR))

# CARGO_HOME is an environmental
HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"
HOST_CONFIGURE_OPTS += 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 \
--prefix=$(CARGO_HOME) \
--bindir=$(CARGO_HOME)/bin \
--libdir=$(CARGO_HOME)/lib \
--sysconfdir=$(CARGO_HOME)/etc \
--datadir=$(CARGO_HOME)/share \
--mandir=$(CARGO_HOME)/man \
--dist-compression-formats=xz \
--enable-missing-tools \
--disable-sanitizers \
--release-channel=stable \
Expand All @@ -85,24 +80,23 @@ define Host/Uninstall
endef

define Host/Compile
$(RUST_SCCACHE_VARS) \
CARGO_HOME=$(CARGO_HOME) \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
$(PYTHON) $(HOST_BUILD_DIR)/x.py \
--build-dir $(HOST_BUILD_DIR)/build \
--config $(HOST_BUILD_DIR)/config.toml \
dist build-manifest cargo llvm-tools rustc rust-std rust-src
( \
cd $(HOST_BUILD_DIR) ; \
$(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
rustc rust-std 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 \; ; \
find -iname "*.xz" -exec tar -xJf {} \; ; \
find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \
\
sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
-e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
-e 's|@RUSTC_LDFLAGS@|$(RUSTC_LDFLAGS)|g' \
$(CURDIR)/files/cargo-config > $(CARGO_HOME)/config ; \
)
endef

Expand Down
8 changes: 8 additions & 0 deletions rust/files/cargo-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[target.@RUSTC_TARGET_ARCH@]
linker = "@TARGET_CC_NOCACHE@"
rustflags = ["-Ctarget-feature=-crt-static", "-Clink-args=@RUSTC_LDFLAGS@"]

[profile.stripped]
inherits = "release"
opt-level = "s"
strip = true
14 changes: 7 additions & 7 deletions rust/patches/0001-Update-xz2-and-use-it-static.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Subject: [PATCH] Update xz2 and use it static

--- a/src/bootstrap/Cargo.lock
+++ b/src/bootstrap/Cargo.lock
@@ -391,9 +391,9 @@ dependencies = [
@@ -443,9 +443,9 @@ dependencies = [

[[package]]
name = "lzma-sys"
Expand All @@ -23,7 +23,7 @@ Subject: [PATCH] Update xz2 and use it static
dependencies = [
"cc",
"libc",
@@ -834,9 +834,9 @@ dependencies = [
@@ -912,9 +912,9 @@ dependencies = [

[[package]]
name = "xz2"
Expand All @@ -37,12 +37,12 @@ Subject: [PATCH] Update xz2 and use it static
]
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -57,7 +57,7 @@ tar = "0.4"
termcolor = "1.2.0"
toml = "0.5"
walkdir = "2"
@@ -50,7 +50,7 @@ toml = "0.5"
ignore = "0.4.10"
opener = "0.5"
once_cell = "1.7.2"
-xz2 = "0.1"
+xz2 = { version = "0.1", features = ["static"] }
walkdir = "2"

# Dependencies needed by the build-metrics feature
sysinfo = { version = "0.26.0", optional = true }
35 changes: 35 additions & 0 deletions rust/patches/0002-Bumped-libc-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 032857e7e403f654129c45dc7e6718a9ad49e377 Mon Sep 17 00:00:00 2001
From: Nikolay Arhipov <[email protected]>
Date: Tue, 6 Jun 2023 16:09:05 +0300
Subject: [PATCH] Bumped libc version

---
Cargo.lock | 4 ++--
library/std/Cargo.toml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1988,9 +1988,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0e

[[package]]
name = "libc"
-version = "0.2.143"
+version = "0.2.146"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
+checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b"
dependencies = [
"rustc-std-workspace-core",
]
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = [
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
-libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'] }
+libc = { version = "0.2.146", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.92" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
52 changes: 0 additions & 52 deletions rust/patches/0002-rustc-bootstrap-cache.patch

This file was deleted.

100 changes: 0 additions & 100 deletions rust/patches/0003-bump-libc-deps-to-0.2.146.patch

This file was deleted.

Loading

0 comments on commit aa3db5a

Please sign in to comment.