Skip to content

Commit fb8ae60

Browse files
committed
Last Sync: 2026-02-22 01:32 (Mobile)
1 parent 1edf3cc commit fb8ae60

2 files changed

Lines changed: 82 additions & 68 deletions

File tree

.github/workflows/main.yml

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
locales \
5151
curl \
5252
ca-certificates \
53-
m4 # 安装系统 m4
53+
m4
5454
5555
sudo ln -sf /usr/bin/python2 /usr/bin/python
5656
sudo locale-gen en_US.UTF-8
@@ -124,13 +124,13 @@ jobs:
124124
BR2_PACKAGE_HOST_MTOOLS=y
125125
EOF
126126
127-
- name: Disable host-m4 build and use system m4
127+
- name: Configure Buildroot with system m4
128128
run: |
129129
cd ~/buildroot-work/buildroot-2018.02-rc3
130130
131131
# 创建目录结构
132132
mkdir -p output/build
133-
mkdir -p output/host
133+
mkdir -p output/host/usr/bin
134134
mkdir -p output/staging
135135
mkdir -p output/target
136136
mkdir -p output/images
@@ -144,25 +144,55 @@ jobs:
144144
# 修改配置,禁用 host-m4 构建
145145
echo "BR2_PACKAGE_HOST_M4=n" >> .config
146146
147-
# 创建符号链接,使用系统 m4
148-
mkdir -p output/host/usr/bin
149-
ln -sf /usr/bin/m4 output/host/usr/bin/m4
150-
151147
# 验证配置
152148
if [ -f .config ]; then
153149
echo "✅ Configuration successful"
150+
echo "=== Configuration Summary ==="
154151
grep "^BR2_" .config | grep -v "^#" | head -20
155152
else
156153
echo "❌ Configuration failed"
157154
exit 1
158155
fi
159156
157+
- name: Fix m4 dependency
158+
run: |
159+
cd ~/buildroot-work/buildroot-2018.02-rc3
160+
161+
# 确保 host-m4 不会被构建
162+
rm -rf package/m4
163+
mkdir -p package/m4
164+
165+
# 创建一个空的 m4 包,让它什么都不做
166+
cat > package/m4/m4.mk << 'EOF'
167+
# 这是一个空的 m4 包,使用系统 m4
168+
HOST_M4_DEPENDENCIES =
169+
HOST_M4_CONFIGURE_CMDS =
170+
HOST_M4_BUILD_CMDS =
171+
HOST_M4_INSTALL_CMDS =
172+
173+
$(eval $(host-generic-package))
174+
EOF
175+
176+
# 创建一个空的 Config.in
177+
touch package/m4/Config.in
178+
179+
# 创建符号链接到系统 m4(如果需要)
180+
if [ ! -f output/host/usr/bin/m4 ]; then
181+
cp /usr/bin/m4 output/host/usr/bin/m4
182+
fi
183+
184+
echo "✅ m4 package disabled"
185+
160186
- name: Build toolchain
161187
run: |
162188
cd ~/buildroot-work/buildroot-2018.02-rc3
163189
echo "Starting toolchain build (this will take 2-3 hours)..."
164190
165-
# 直接构建 toolchain,跳过 host-m4
191+
# 显示配置
192+
echo "=== Build Configuration ==="
193+
make show-targets || true
194+
195+
# 构建 toolchain
166196
make toolchain -j2
167197
env:
168198
FORCE_UNSAFE_CONFIGURE: 1
@@ -184,6 +214,7 @@ jobs:
184214
echo "=== Checking compiler target ==="
185215
aarch64-linux-gcc -dumpmachine
186216
217+
# 测试编译
187218
cat > /tmp/test.c << 'EOF'
188219
#include <stdio.h>
189220
int main() {
@@ -192,18 +223,27 @@ jobs:
192223
}
193224
EOF
194225
226+
echo "=== Compiling test program ==="
195227
aarch64-linux-gcc -o /tmp/test-arm64 /tmp/test.c
228+
229+
echo "=== Test program info ==="
196230
file /tmp/test-arm64
231+
197232
echo "✅ Toolchain verification passed!"
198233
199234
- name: Create SDK package
200235
run: |
201236
cd ~/buildroot-work/buildroot-2018.02-rc3
237+
238+
# 尝试创建 SDK
202239
make sdk || true
203240
241+
# 查找或创建 SDK 包
204242
if ls output/images/*sdk*.tar.gz 1> /dev/null 2>&1; then
205243
cp output/images/*sdk*.tar.gz .
244+
echo "SDK package created"
206245
else
246+
echo "Creating manual SDK package..."
207247
tar -czf aarch64-buildroot-linux-gnu_sdk.tar.gz -C output/host .
208248
fi
209249
@@ -213,6 +253,8 @@ jobs:
213253
214254
cat > dictpen-env.sh << 'EOF'
215255
#!/bin/bash
256+
# DictPen P5 Toolchain environment script
257+
216258
TOOLCHAIN_DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")" && pwd )"
217259
218260
export PATH="$TOOLCHAIN_DIR/output/host/usr/bin:$PATH"
@@ -227,11 +269,23 @@ jobs:
227269
228270
export CC="aarch64-linux-gcc --sysroot=$SYSROOT"
229271
export CXX="aarch64-linux-g++ --sysroot=$SYSROOT"
272+
export LD="aarch64-linux-ld"
273+
export AR="aarch64-linux-ar"
274+
export AS="aarch64-linux-as"
275+
export NM="aarch64-linux-nm"
276+
export STRIP="aarch64-linux-strip"
277+
export RANLIB="aarch64-linux-ranlib"
278+
export OBJCOPY="aarch64-linux-objcopy"
279+
export OBJDUMP="aarch64-linux-objdump"
230280
231281
echo "========================================="
232282
echo "DictPen P5 Toolchain Ready!"
283+
echo "========================================="
233284
echo "GCC: $(aarch64-linux-gcc --version | head -1)"
234-
echo "Example: \$CC -o hello hello.c"
285+
echo "SYSROOT: $SYSROOT"
286+
echo ""
287+
echo "Example:"
288+
echo " \$CC -o hello hello.c"
235289
echo "========================================="
236290
EOF
237291
@@ -240,11 +294,14 @@ jobs:
240294
- name: Package toolchain
241295
run: |
242296
cd ~/buildroot-work/buildroot-2018.02-rc3
297+
298+
# 创建完整的工具链包
243299
tar -czf dictpen-p5-toolchain-complete.tar.gz \
244300
output/host \
245301
dictpen-env.sh \
246302
configs/dictpen_p5_defconfig \
247-
.config
303+
.config \
304+
--transform 's|^|dictpen-p5-toolchain/|'
248305
249306
echo "✅ Toolchain packaged: dictpen-p5-toolchain-complete.tar.gz"
250307
ls -lh *.tar.gz

.github/workflows/main.yml.bak

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
device-tree-compiler \
5050
locales \
5151
curl \
52-
ca-certificates
52+
ca-certificates \
53+
m4 # 安装系统 m4
5354

5455
sudo ln -sf /usr/bin/python2 /usr/bin/python
5556
sudo locale-gen en_US.UTF-8
@@ -123,65 +124,11 @@ jobs:
123124
BR2_PACKAGE_HOST_MTOOLS=y
124125
EOF
125126

126-
- name: Clean any existing m4 patches and build
127-
run: |
128-
cd ~/buildroot-work/buildroot-2018.02-rc3
129-
rm -rf package/m4/*.patch
130-
rm -rf output/build/host-m4-*
131-
rm -rf dl/m4-1.4.18.tar.xz
132-
133-
- name: Create m4 patch for Ubuntu 22.04
134-
run: |
135-
cd ~/buildroot-work/buildroot-2018.02-rc3
136-
mkdir -p package/m4
137-
138-
cat > package/m4/0001-fix-c-stack-ubuntu22.patch << 'EOF'
139-
--- a/lib/c-stack.c
140-
+++ b/lib/c-stack.c
141-
@@ -16,16 +16,17 @@
142-
along with this program. If not, see <http://www.gnu.org/licenses/>. */
143-
144-
/* Written by Paul Eggert. */
145-
146-
#include <config.h>
147-
148-
-#include "c-stack.h"
149-
-
150-
#include <errno.h>
151-
#include <signal.h>
152-
#include <stdbool.h>
153-
#include <stdlib.h>
154-
#include <string.h>
155-
#include <unistd.h>
156-
157-
+#include "c-stack.h"
158-
+
159-
#if HAVE_SETRLIMIT
160-
/* FIXME: This use of HAVE_SETRLIMIT is wrong, as it checks for the
161-
function, not the symbol. But glibc defines setrlimit unconditionally,
162-
@@ -49,15 +50,7 @@
163-
#endif
164-
#endif
165-
166-
-#if HAVE_LIBSIGSEGV
167-
-# include <sigsegv.h>
168-
-#elif defined HAVE_LIBSIGSEGV && SIGSTKSZ < 16384
169-
-/* libsigsegv 2.6 through 2.8 have a bug where sigsegv_handler fails
170-
- to install the preallocated stack for the overflow handler. */
171-
-# else
172-
-# define LIBSIGSEGV_PREALLOC_STACK 1
173-
-# include <sigsegv.h>
174-
-#endif
175-
+#include <sigsegv.h>
176-
177-
#if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T
178-
# include <ucontext.h>
179-
EOF
180-
181-
- name: Initialize Buildroot and Configure
127+
- name: Disable host-m4 build and use system m4
182128
run: |
183129
cd ~/buildroot-work/buildroot-2018.02-rc3
184130

131+
# 创建目录结构
185132
mkdir -p output/build
186133
mkdir -p output/host
187134
mkdir -p output/staging
@@ -190,9 +137,18 @@ jobs:
190137

191138
touch output/.br-external.mk
192139

140+
# 应用配置
193141
make defconfig
194142
make dictpen_p5_defconfig
195143

144+
# 修改配置,禁用 host-m4 构建
145+
echo "BR2_PACKAGE_HOST_M4=n" >> .config
146+
147+
# 创建符号链接,使用系统 m4
148+
mkdir -p output/host/usr/bin
149+
ln -sf /usr/bin/m4 output/host/usr/bin/m4
150+
151+
# 验证配置
196152
if [ -f .config ]; then
197153
echo "✅ Configuration successful"
198154
grep "^BR2_" .config | grep -v "^#" | head -20
@@ -205,7 +161,8 @@ jobs:
205161
run: |
206162
cd ~/buildroot-work/buildroot-2018.02-rc3
207163
echo "Starting toolchain build (this will take 2-3 hours)..."
208-
make host-m4 -j2
164+
165+
# 直接构建 toolchain,跳过 host-m4
209166
make toolchain -j2
210167
env:
211168
FORCE_UNSAFE_CONFIGURE: 1

0 commit comments

Comments
 (0)