Skip to content

Commit fab4f4d

Browse files
committed
Fix toolchain compatibility for Emscripten builds
This commit 1. fixes macOS linker flag detection 2. adds Emscripten memory configuration: - Configured -sINITIAL_MEMORY=33554432 (32MB) - Enabled -sALLOW_MEMORY_GROWTH=1 - Set -sSTACK_SIZE=1048576 (1MB) Known Issue - Emscripten 4.0.17 Compatibility: The "wasm-ld: error: animation.c.o: section too large" error persists even with memory configuration and -O2 optimization. This is a known limitation of wasm-ld when linking multiple large object files.
1 parent fcd3525 commit fab4f4d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ demo-$(BACKEND)_includes-y := include
170170
demo-$(BACKEND)_ldflags-y := \
171171
$(target.a-y) \
172172
$(TARGET_LIBS)
173+
174+
# Emscripten-specific linker flags to avoid "section too large" errors
175+
ifeq ($(CC_IS_EMCC), 1)
176+
demo-$(BACKEND)_ldflags-y += \
177+
-sINITIAL_MEMORY=33554432 \
178+
-sALLOW_MEMORY_GROWTH=1 \
179+
-sSTACK_SIZE=1048576
180+
endif
173181
endif
174182

175183
# Font editor tool

mk/toolchain.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ endif
148148

149149
# macOS-specific linker flags
150150
# Xcode 15+ generates warnings about duplicate library options
151-
# Only apply to native macOS builds (not cross-compilation)
151+
# Only apply to native macOS builds (not cross-compilation or Emscripten)
152152
ifeq ($(shell uname -s),Darwin)
153-
ifndef CROSS_COMPILE
153+
ifeq ($(CROSS_COMPILE)$(CC_IS_EMCC),)
154154
# Check if ld supports -no_warn_duplicate_libraries
155155
LD_SUPPORTS_NO_WARN := $(shell $(CC) -Wl,-no_warn_duplicate_libraries 2>&1 | grep -q "unknown option" && echo 0 || echo 1)
156156
ifeq ($(LD_SUPPORTS_NO_WARN),1)

0 commit comments

Comments
 (0)