5050 locales \
5151 curl \
5252 ca-certificates \
53- m4
53+ m4 # 安装系统 m4,用于替代 host-m4
5454
5555 sudo ln -sf /usr/bin/python2 /usr/bin/python
5656 sudo locale-gen en_US.UTF-8
@@ -124,11 +124,11 @@ jobs:
124124 BR2_PACKAGE_HOST_MTOOLS=y
125125 EOF
126126
127- - name : Initialize Buildroot (without host/usr interference)
127+ - name : Initialize Buildroot
128128 run : |
129129 cd ~/buildroot-work/buildroot-2018.02-rc3
130130
131- # 只创建必要的顶层输出目录,不创建 host/usr 子目录
131+ # 创建必要的输出目录(不深入创建 host/usr)
132132 mkdir -p output/build
133133 mkdir -p output/images
134134 mkdir -p output/target
@@ -149,150 +149,20 @@ jobs:
149149 exit 1
150150 fi
151151
152- - name : Manually patch host-m4 source
152+ - name : Fake host-m4 build (use system m4)
153153 run : |
154154 cd ~/buildroot-work/buildroot-2018.02-rc3
155155
156- # 先解压 host-m4(如果尚未解压)
157- make host-m4-extract || true
156+ # 彻底删除可能存在的旧 host-m4 构建目录
157+ rm -rf output/build/ host-m4-1.4.18
158158
159- # 进入源码目录
160- M4_SRC_DIR="output/build/host-m4-1.4.18"
161- if [ -d "$M4_SRC_DIR" ]; then
162- echo "Patching c-stack.c in $M4_SRC_DIR"
163- cat > "$M4_SRC_DIR/lib/c-stack.c" << 'EOF'
164- /* c-stack.c - stack overflow handling
159+ # 创建空的构建目录,并放入所有必需的 stamp 文件
160+ mkdir -p output/build/host-m4-1.4.18
161+ touch output/build/host-m4-1.4.18/.stamp_configured
162+ touch output/build/host-m4-1.4.18/.stamp_patched
163+ touch output/build/host-m4-1.4.18/.stamp_built
165164
166- Copyright (C) 2002, 2004, 2006-2016 Free Software Foundation, Inc.
167-
168- This program is free software: you can redistribute it and/or modify
169- it under the terms of the GNU General Public License as published by
170- the Free Software Foundation; either version 3 of the License, or
171- (at your option) any later version.
172-
173- This program is distributed in the hope that it will be useful,
174- but WITHOUT ANY WARRANTY; without even the implied warranty of
175- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176- GNU General Public License for more details.
177-
178- You should have received a copy of the GNU General Public License
179- along with this program. If not, see <http://www.gnu.org/licenses/>. */
180-
181- /* Written by Paul Eggert. */
182-
183- #include <config.h>
184-
185- #include <errno.h>
186- #include <signal.h>
187- #include <stdbool.h>
188- #include <stdlib.h>
189- #include <string.h>
190- #include <unistd.h>
191-
192- #include "c-stack.h"
193-
194- #if HAVE_SETRLIMIT
195- /* FIXME: This use of HAVE_SETRLIMIT is wrong, as it checks for the
196- function, not the symbol. But glibc defines setrlimit unconditionally,
197- at least in conservative environments. */
198- # include <sys/time.h>
199- # include <sys/resource.h>
200- #endif
201-
202- #if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T
203- # include <ucontext.h>
204- #endif
205-
206- #include <sigsegv.h>
207-
208- #if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T
209- /* Storage for the alternate signal stack. */
210- static union
211- {
212- char buffer[SIGSTKSZ];
213- stack_t ss;
214- } alternate_signal_stack;
215-
216- static void
217- null_action (int signo __attribute__ ((unused)),
218- siginfo_t *info __attribute__ ((unused)),
219- void *context __attribute__ ((unused)))
220- {
221- }
222- #endif /* HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T */
223-
224- /* The user-specified action. */
225- static void (* volatile action) (int) = NULL;
226-
227- static void
228- segv_handler (int signo __attribute__ ((unused)),
229- siginfo_t *info __attribute__ ((unused)),
230- void *context __attribute__ ((unused)))
231- {
232- #if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T
233- ucontext_t const *uc = context;
234-
235- /* If the faulting address is within the stack, or within the
236- kernel's specially designated stack overflow area, assume that
237- this is a stack overflow. */
238- if (0 < uc->uc_stack.ss_size)
239- {
240- char *const stack_base = (char *) uc->uc_stack.ss_sp;
241- size_t stack_size = uc->uc_stack.ss_size;
242- char *const fault = (char *) info->si_addr;
243- size_t page_size = sysconf (_SC_PAGE_SIZE);
244- if (page_size == (size_t) -1)
245- page_size = 4096;
246-
247- if (stack_base <= fault && fault < stack_base + stack_size + page_size)
248- {
249- if (action)
250- action (SIGSEGV);
251- else
252- {
253- /* Reset the handler to the default and re-raise the
254- signal. */
255- struct sigaction act;
256- act.sa_handler = SIG_DFL;
257- sigemptyset (&act.sa_mask);
258- act.sa_flags = 0;
259- sigaction (SIGSEGV, &act, NULL);
260- raise (SIGSEGV);
261- }
262- }
263- }
264- #endif /* HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T */
265- }
266-
267- int
268- c_stack_action (void (*func) (int))
269- {
270- int r = sigsegv_install_handler (segv_handler);
271- if (r == 0)
272- {
273- action = func;
274-
275- #if HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T
276- /* Use libsigsegv to set up an alternate stack. */
277- r = sigsegv_init (&alternate_signal_stack.ss);
278- if (r == 0)
279- {
280- alternate_signal_stack.ss.ss_flags = 0;
281- if (sigaltstack (&alternate_signal_stack.ss, NULL) < 0)
282- r = -1;
283- }
284- #endif /* HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_T */
285- }
286-
287- return r;
288- }
289- EOF
290- # 标记为已打补丁(防止再次尝试应用补丁)
291- touch "$M4_SRC_DIR/.stamp_patched"
292- echo "✅ host-m4 manually patched"
293- else
294- echo "⚠️ host-m4 source not found, will be handled during build"
295- fi
165+ echo "✅ host-m4 faked, will use system m4"
296166
297167 - name : Build toolchain
298168 run : |
@@ -303,7 +173,7 @@ jobs:
303173 echo "=== Build Targets ==="
304174 make show-targets || true
305175
306- # 开始构建
176+ # 开始构建 toolchain(host-m4 已被跳过)
307177 make toolchain -j2
308178 env :
309179 FORCE_UNSAFE_CONFIGURE : 1
0 commit comments