NanoPi R4S: https://r4s.cooluc.com
NanoPi R5S/R5C: https://r5s.cooluc.com
X86_64: https://x86.cooluc.com
sudo apt-get update
sudo apt-get install -y build-essential flex bison g++ gawk gcc-multilib g++-multilib gettext git libfuse-dev libncurses5-dev libssl-dev python3 python3-pip python3-ply python3-distutils python3-pyelftools rsync unzip zlib1g-dev file wget subversion patch upx-ucl autoconf automake curl asciidoc binutils bzip2 lib32gcc-s1 libc6-dev-i386 uglifyjs msmtp texinfo libreadline-dev libglib2.0-dev xmlto libelf-dev libtool autopoint antlr3 gperf ccache swig coreutils haveged scons libpython3-dev jq
安装 LLVM/CLANG - 启用 ENABLE_BPF
/ KERNEL_CLANG_LTO
时需要
# 下载并解压
sudo mkdir -p /opt/clang
curl -LO https://github.com/sbwml/redhat-llvm-project/releases/download/18.1.6/clang-18.1.6-x86_64-redhat-linux.tar.xz
sudo tar --strip-components=1 -C /opt/clang -xf clang-18.1.6-x86_64-redhat-linux.tar.xz
rm -rf clang-18.1.6-x86_64-redhat-linux.tar.xz
# 添加 BIN 到系统变量
export PATH="/opt/clang/bin:$PATH"
# clang 版本验证
clang --version
clang version 18.1.6 (https://github.com/llvm/llvm-project 1118c2e05e67a36ed8ca250524525cdb66a55256)
Target: x86_64-redhat-linux
Thread model: posix
InstalledDir: /opt/clang/bin
启用 Clang/LLVM 构建内核
export KERNEL_CLANG_LTO=y
# GCC13
export USE_GCC13=y
# GCC14
export USE_GCC14=y
# GCC15
export USE_GCC15=y
启用 LTO 优化
export ENABLE_LTO=y
启用 MOLD 现代链接器(需要启用 USE_GCC13=y
或 USE_GCC14=y
或 USE_GCC15=y
)
export USE_MOLD=y
启用 eBPF 支持
export ENABLE_BPF=y
启用 LRNG
export ENABLE_LRNG=y
启用 Glibc 库构建 (实验性)
export USE_GLIBC=y
脚本会使用 toolchain 缓存代替源码构建,与常规构建相比能节省大约 60 分钟的编译耗时,仅适用于 Github Actions ubuntu-24.04
环境
export BUILD_FAST=y
export MINIMAL_BUILD=y
export LAN=10.0.0.1
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) rc2 nanopi-r4s
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) rc2 nanopi-r5s
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) rc2 x86_64
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) dev nanopi-r4s
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) dev nanopi-r5s
# linux-6.6
bash <(curl -sS https://init2.cooluc.com/build.sh) dev x86_64
将 init.cooluc.com 脚本默认连接替换为你的 github raw 连接(不带 https://),像这样 raw.githubusercontent.com/你的用户名/r4s_build_script/master
# script url
if [ "$isCN" = "CN" ]; then
- export mirror=init.cooluc.com
+ export mirror=raw.githubusercontent.com/你的用户名/r4s_build_script/master
else
- export mirror=init2.cooluc.com
+ export mirror=raw.githubusercontent.com/你的用户名/r4s_build_script/master
fi
# linux-6.6
bash <(curl -sS https://raw.githubusercontent.com/你的用户名/r4s_build_script/master/openwrt/build.sh) rc2 nanopi-r4s
# linux-6.6
bash <(curl -sS https://raw.githubusercontent.com/你的用户名/r4s_build_script/master/openwrt/build.sh) rc2 nanopi-r5s
# linux-6.6
bash <(curl -sS https://raw.githubusercontent.com/你的用户名/r4s_build_script/master/openwrt/build.sh) rc2 x86_64