Skip to content

Commit 75f6782

Browse files
committed
Fix build system regressions
This commit consolidates multiple build system fixes: 1. DTB compilation regression - Fixed unconditional DTB build in user-space mode - Fixed WebAssembly build missing DTB dependencies - Fixed DTB not being built on macOS-arm64 for SYSTEM mode 2. Makefile syntax error - Fixed TAB characters before $(warning) in mk/toolchain.mk - This prevented entire Makefile from parsing correctly 3. emcc configuration pollution - Fixed .config persistence causing ENABLE_SYSTEM=1 to leak - Added distclean before emcc builds to ensure clean state 4. Ubuntu ARM64 apt-get failures - Exponential backoff: 30s, 60s delays (mirror sync needs time) - Detect "Mirror sync in progress" in addition to fetch failures - Fallback with --fix-broken install if apt install fails - Reduced retries from 5 to 3 (longer delays are more effective)
1 parent 2cc7b01 commit 75f6782

File tree

4 files changed

+67
-17
lines changed

4 files changed

+67
-17
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ jobs:
135135
- name: default build using emcc
136136
if: success()
137137
run: |
138+
make distclean
138139
make CC=emcc ENABLE_JIT=0 $PARALLEL
139140
140141
- name: default build for system emulation using emcc
141142
if: success()
142143
run: |
143144
make distclean
144145
make CC=emcc ENABLE_SYSTEM=1 ENABLE_JIT=0 $PARALLEL
145-
make distclean ENABLE_SYSTEM=1
146+
make distclean
146147
147148
- name: Build with various optimization levels
148149
if: success()
@@ -301,8 +302,28 @@ jobs:
301302
githubToken: ${{ github.token }}
302303
# No 'sudo' is available
303304
install: |
304-
apt update -qq
305-
apt install -yqq make git curl wget clang libsdl2-dev libsdl2-mixer-dev lsb-release software-properties-common gnupg bc
305+
# Retry apt update with exponential backoff for mirror sync issues
306+
# apt update returns 0 even with partial failures, so check logs
307+
for i in 1 2 3; do
308+
apt update -qq --allow-releaseinfo-change 2>&1 | tee /tmp/apt-update.log
309+
if ! grep -q "Failed to fetch\|Hash Sum mismatch\|Mirror sync in progress" /tmp/apt-update.log; then
310+
echo "apt update succeeded on attempt $i"
311+
break
312+
fi
313+
if [ $i -lt 3 ]; then
314+
delay=$((i * 30))
315+
echo "apt update attempt $i had errors, waiting ${delay}s for mirror sync..."
316+
sleep $delay
317+
else
318+
echo "Warning: Proceeding with partial package lists after 3 attempts..."
319+
echo "This is usually safe - required packages are likely available"
320+
fi
321+
done
322+
apt install -yqq make git curl wget clang libsdl2-dev libsdl2-mixer-dev lsb-release software-properties-common gnupg bc || {
323+
echo "Warning: apt install had issues, retrying with apt --fix-broken install"
324+
apt --fix-broken install -yqq
325+
apt install -yqq make git curl wget clang libsdl2-dev libsdl2-mixer-dev lsb-release software-properties-common gnupg bc
326+
}
306327
which wget || echo "WARNING: wget not found after installation"
307328
# FIXME: gcc build fails on Aarch64/Linux hosts
308329
env: |
@@ -311,7 +332,17 @@ jobs:
311332
run: |
312333
# Verify and install wget if needed (workaround for install step issues)
313334
if ! command -v wget > /dev/null 2>&1; then
314-
apt update -qq && apt install -yqq wget
335+
for i in 1 2; do
336+
apt update -qq --allow-releaseinfo-change 2>&1 | tee /tmp/apt-update-wget.log
337+
if ! grep -q "Failed to fetch\|Hash Sum mismatch\|Mirror sync in progress" /tmp/apt-update-wget.log; then
338+
break
339+
fi
340+
if [ $i -lt 2 ]; then
341+
echo "apt update retry $i had errors, waiting 30s for mirror sync..."
342+
sleep 30
343+
fi
344+
done
345+
apt install -yqq wget || echo "Warning: wget install failed, may affect later steps"
315346
fi
316347
git config --global --add safe.directory ${{ github.workspace }}
317348
git config --global --add safe.directory ${{ github.workspace }}/src/softfloat
@@ -435,14 +466,15 @@ jobs:
435466
- name: default build using emcc
436467
if: success()
437468
run: |
469+
make distclean
438470
make CC=emcc ENABLE_JIT=0 $PARALLEL
439471
440472
- name: default build for system emulation using emcc
441473
if: success()
442474
run: |
443475
make distclean
444476
make CC=emcc ENABLE_SYSTEM=1 ENABLE_JIT=0 $PARALLEL
445-
make distclean ENABLE_SYSTEM=1
477+
make distclean
446478
447479
- name: check + tests
448480
if: success()
@@ -499,14 +531,14 @@ jobs:
499531
fi
500532
done
501533
502-
- name: JIT debug test
503-
env:
504-
CC: ${{ steps.install_cc.outputs.cc }}
505-
run: |
506-
# Run JIT tests with debug mode to catch register allocation and cache coherency issues
507-
make distclean && make ENABLE_JIT=1 ENABLE_JIT_DEBUG=1 check $PARALLEL
508-
make distclean && make ENABLE_EXT_C=0 ENABLE_JIT=1 ENABLE_JIT_DEBUG=1 check $PARALLEL
509-
if: ${{ always() }}
534+
- name: JIT debug test
535+
env:
536+
CC: ${{ steps.install_cc.outputs.cc }}
537+
run: |
538+
# Run JIT tests with debug mode to catch register allocation and cache coherency issues
539+
make distclean && make ENABLE_JIT=1 ENABLE_JIT_DEBUG=1 check $PARALLEL
540+
make distclean && make ENABLE_EXT_C=0 ENABLE_JIT=1 ENABLE_JIT_DEBUG=1 check $PARALLEL
541+
if: ${{ always() }}
510542

511543
- name: undefined behavior test
512544
if: (success() || failure()) && steps.install_cc.outputs.cc == 'clang' # gcc on macOS/arm64 does not support sanitizers

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ DTB_DEPS := $(BUILD_DTB) $(BUILD_DTB2C)
392392
endif
393393
endif
394394

395-
all: config $(DTB_DEPS) $(BUILD_DTB) $(BUILD_DTB2C) $(BIN)
395+
all: config $(DTB_DEPS) $(BIN)
396396

397397
OBJS := \
398398
map.o \
@@ -437,7 +437,7 @@ $(OUT):
437437

438438
$(BIN): $(OBJS) $(DEV_OBJS) | $(OUT)
439439
$(VECHO) " LD\t$@\n"
440-
$(Q)$(CC) -o $@ $(CFLAGS_emcc) $^ $(LDFLAGS)
440+
$(Q)$(CC) -o $@ $(CFLAGS_emcc) $(filter-out %.dtb %.h,$^) $(LDFLAGS)
441441

442442
$(CONFIG_FILE): FORCE
443443
$(Q)mkdir -p $(OUT)

mk/toolchain.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ ifneq ($(shell $(CC) --version | head -n 1 | grep emcc),)
2222
$(warning $(SDL_MUSIC_CANNOT_PLAY_WARNING))
2323
endif
2424
else
25-
$(warning $(SDL_MUSIC_CANNOT_PLAY_WARNING))
25+
$(warning $(SDL_MUSIC_CANNOT_PLAY_WARNING))
2626
endif
2727
else
28-
$(warning $(SDL_MUSIC_CANNOT_PLAY_WARNING))
28+
$(warning $(SDL_MUSIC_CANNOT_PLAY_WARNING))
2929
endif
3030

3131
# see commit 165c1a3 of emscripten

mk/wasm.mk

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,21 @@ start-web: $(start_web_deps)
166166
.PHONY: check-demo-dir-exist start-web
167167

168168
endif
169+
170+
# For SYSTEM mode, DTB needs to be built regardless of whether we're using emcc
171+
# DTB is only built when SYSTEM=1 and ELF_LOADER=0
172+
ifeq ($(call has, SYSTEM), 1)
173+
ifeq ($(call has, ELF_LOADER), 0)
174+
# Add DTB as dependency for compilation stages
175+
# This is used by mk/system.mk for device object files
176+
deps_emcc += $(BUILD_DTB) $(BUILD_DTB2C)
177+
178+
# For emcc builds: ensure DTB exists before emcc embeds it
179+
# Make BIN directly depend on DTB files as regular prerequisites
180+
# This will cause them to be built, but they'll also be passed to the linker
181+
# We need to filter them out in the linker command
182+
ifeq ("$(CC_IS_EMCC)", "1")
183+
$(BIN): $(BUILD_DTB) $(BUILD_DTB2C)
184+
endif
185+
endif
186+
endif

0 commit comments

Comments
 (0)