Skip to content

Commit f4d35a6

Browse files
addpkg(main/turbopack): 16.1.6
1 parent 5dcbbe0 commit f4d35a6

5 files changed

Lines changed: 203 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From af6b224ff9a0e4c532ccb67f4875fd72fa0632db Mon Sep 17 00:00:00 2001
2+
From: xingguangcuican6666 <xingguangcuican666@foxmail.com>
3+
Date: Thu, 5 Mar 2026 10:47:09 +0800
4+
Subject: [PATCH 1/3] fix_malloc
5+
6+
---
7+
turbopack/crates/turbo-tasks-malloc/Cargo.toml | 4 ++--
8+
1 file changed, 2 insertions(+), 2 deletions(-)
9+
10+
diff --git a/turbopack/crates/turbo-tasks-malloc/Cargo.toml b/turbopack/crates/turbo-tasks-malloc/Cargo.toml
11+
index 2933ebad..22b6fbc1 100644
12+
--- a/turbopack/crates/turbo-tasks-malloc/Cargo.toml
13+
+++ b/turbopack/crates/turbo-tasks-malloc/Cargo.toml
14+
@@ -26,5 +26,5 @@ mimalloc = { version = "0.1.48", features = [
15+
], optional = true }
16+
17+
[features]
18+
-custom_allocator = ["dep:mimalloc"]
19+
-default = ["custom_allocator"]
20+
+custom_allocator = []
21+
+default = []
22+
--
23+
2.53.0
24+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From 5dfdda0c7402c740d8d05848e3b13b1396cdbaa9 Mon Sep 17 00:00:00 2001
2+
From: xingguangcuican6666 <xingguangcuican666@foxmail.com>
3+
Date: Thu, 5 Mar 2026 11:12:02 +0800
4+
Subject: [PATCH 2/3] patch_lib.rc
5+
6+
---
7+
turbopack/crates/turbo-tasks-malloc/src/lib.rs | 18 ++++++++++++++----
8+
1 file changed, 14 insertions(+), 4 deletions(-)
9+
10+
diff --git a/turbopack/crates/turbo-tasks-malloc/src/lib.rs b/turbopack/crates/turbo-tasks-malloc/src/lib.rs
11+
index 4f3024a4..68823e73 100644
12+
--- a/turbopack/crates/turbo-tasks-malloc/src/lib.rs
13+
+++ b/turbopack/crates/turbo-tasks-malloc/src/lib.rs
14+
@@ -115,17 +115,27 @@ impl TurboMalloc {
15+
#[inline]
16+
fn base_alloc() -> &'static impl GlobalAlloc {
17+
#[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
18+
- return &mimalloc::MiMalloc;
19+
+ {
20+
+ return &mimalloc::MiMalloc;
21+
+ }
22+
+
23+
#[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
24+
- return &std::alloc::System;
25+
+ {
26+
+ return &std::alloc::System;
27+
+ }
28+
}
29+
30+
#[allow(unused_variables)]
31+
unsafe fn base_alloc_size(ptr: *const u8, layout: Layout) -> usize {
32+
#[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
33+
- return unsafe { mimalloc::MiMalloc.usable_size(ptr) };
34+
+ {
35+
+ return unsafe { mimalloc::MiMalloc.usable_size(ptr) };
36+
+ }
37+
+
38+
#[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
39+
- return layout.size();
40+
+ {
41+
+ return layout.size();
42+
+ }
43+
}
44+
45+
unsafe impl GlobalAlloc for TurboMalloc {
46+
--
47+
2.53.0
48+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
From 898d5817e9bb1ab993093350ebcc1fe92dc27799 Mon Sep 17 00:00:00 2001
2+
From: xingguangcuican6666 <xingguangcuican666@foxmail.com>
3+
Date: Thu, 5 Mar 2026 11:54:07 +0800
4+
Subject: [PATCH 3/3] patch_malloc
5+
6+
---
7+
.../crates/turbo-tasks-malloc/src/lib.rs | 22 ++++---------------
8+
1 file changed, 4 insertions(+), 18 deletions(-)
9+
10+
diff --git a/turbopack/crates/turbo-tasks-malloc/src/lib.rs b/turbopack/crates/turbo-tasks-malloc/src/lib.rs
11+
index 68823e73..99800748 100644
12+
--- a/turbopack/crates/turbo-tasks-malloc/src/lib.rs
13+
+++ b/turbopack/crates/turbo-tasks-malloc/src/lib.rs
14+
@@ -114,28 +114,14 @@ impl TurboMalloc {
15+
/// Get the allocator for this platform that we should wrap with TurboMalloc.
16+
#[inline]
17+
fn base_alloc() -> &'static impl GlobalAlloc {
18+
- #[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
19+
- {
20+
- return &mimalloc::MiMalloc;
21+
- }
22+
-
23+
- #[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
24+
- {
25+
- return &std::alloc::System;
26+
- }
27+
+ // 彻底移除 mimalloc 引用,强制返回系统分配器以适配 Termux
28+
+ &std::alloc::System
29+
}
30+
31+
#[allow(unused_variables)]
32+
unsafe fn base_alloc_size(ptr: *const u8, layout: Layout) -> usize {
33+
- #[cfg(all(feature = "custom_allocator", not(target_family = "wasm")))]
34+
- {
35+
- return unsafe { mimalloc::MiMalloc.usable_size(ptr) };
36+
- }
37+
-
38+
- #[cfg(not(all(feature = "custom_allocator", not(target_family = "wasm"))))]
39+
- {
40+
- return layout.size();
41+
- }
42+
+ // 直接返回 layout 定义的大小,避免调用 mimalloc 的 usable_size
43+
+ layout.size()
44+
}
45+
46+
unsafe impl GlobalAlloc for TurboMalloc {
47+
--
48+
2.53.0
49+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From 8e67ab456d44c99f390d51df7a07352fc466fc53 Mon Sep 17 00:00:00 2001
2+
From: xingguangcuican6666 <xingguangcuican666@foxmail.com>
3+
Date: Wed, 4 Mar 2026 23:30:01 +0800
4+
Subject: [PATCH] Fixed_arch
5+
6+
---
7+
packages/next-swc/package.json | 4 ++++
8+
1 file changed, 4 insertions(+)
9+
10+
diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json
11+
index da9a29f0..b0687f66 100644
12+
--- a/packages/next-swc/package.json
13+
+++ b/packages/next-swc/package.json
14+
@@ -27,6 +27,10 @@
15+
"defaults": true,
16+
"additional": [
17+
"i686-pc-windows-msvc",
18+
+ "aarch64-linux-android",
19+
+ "armv7-linux-androideabi",
20+
+ "i686-linux-android",
21+
+ "x86_64-linux-android",
22+
"aarch64-unknown-linux-gnu",
23+
"aarch64-apple-darwin",
24+
"x86_64-unknown-linux-musl",
25+
--
26+
2.53.0
27+

packages/turbopack/build.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
TERMUX_PKG_HOMEPAGE=https://turbo.build/
2+
TERMUX_PKG_DESCRIPTION="Rust-based incremental compilation engine and bundler for Next.js"
3+
TERMUX_PKG_MAINTAINER="@xingguangcuican6666"
4+
TERMUX_PKG_LICENSE="MIT"
5+
TERMUX_PKG_VERSION=16.1.6
6+
TERMUX_PKG_SRCURL=https://github.com/vercel/next.js/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
7+
TERMUX_PKG_SHA256=63e8f9f386022fa0b9bea1113e7649fe250ae4bb85782b1c4286a3fbf0efedea
8+
TERMUX_PKG_BUILD_IN_SRC=true
9+
TERMUX_RUST_VERSION="nightly"
10+
TERMUX_PKG_EXCLUDED_ARCHES="arm, i686"
11+
12+
termux_step_make() {
13+
local RUST_TARGET
14+
case "$TERMUX_ARCH" in
15+
aarch64) RUST_TARGET="aarch64-linux-android" ;;
16+
x86_64) RUST_TARGET="x86_64-linux-android" ;;
17+
esac
18+
termux_setup_rust
19+
termux_setup_nodejs
20+
export ANDROID_NDK_LATEST_HOME="${NDK}"
21+
export RUSTFLAGS="--cfg tokio_unstable"
22+
local ENV_PREFIX=$(echo "$RUST_TARGET" | tr '[:lower:]-' '[:upper:]_')
23+
export "CARGO_TARGET_${ENV_PREFIX}_LINKER"="$CC"
24+
export "CC_${RUST_TARGET//-/_}"="$CC"
25+
npx pnpm install
26+
cd packages/next-swc
27+
# export RUSTFLAGS="-C stack-check=no -C link-args=-zstack-size=2097152"
28+
export RUSTFLAGS="-C link-args=-zstack-size=2097152 -C target-feature=-stack-probes"
29+
npx pnpm run build-native-release --target "$RUST_TARGET"
30+
}
31+
32+
termux_step_make_install() {
33+
cd packages/next-swc
34+
ls -l native
35+
local NAPI_ARCH
36+
case "$TERMUX_ARCH" in
37+
aarch64) NAPI_ARCH="arm64" ;;
38+
x86_64) NAPI_ARCH="x64" ;;
39+
esac
40+
local PACKAGE_NAME="@next/swc-android-${NAPI_ARCH}"
41+
local INSTALL_DIR="$TERMUX_PREFIX/lib/node_modules/${PACKAGE_NAME}"
42+
local BINARY_NAME="next-swc.android-${NAPI_ARCH}.node"
43+
mkdir -p "$INSTALL_DIR"
44+
install -Dm755 "native/${BINARY_NAME}" "$INSTALL_DIR/${BINARY_NAME}"
45+
${STRIP} --strip-unneeded "$INSTALL_DIR/${BINARY_NAME}"
46+
cat > "$INSTALL_DIR/package.json" <<EOF
47+
{
48+
"name": "${PACKAGE_NAME}",
49+
"version": "$TERMUX_PKG_VERSION",
50+
"os": ["android"],
51+
"cpu": ["${NAPI_ARCH}"],
52+
"main": "${BINARY_NAME}"
53+
}
54+
EOF
55+
}

0 commit comments

Comments
 (0)