Skip to content

Commit 8a6e6a4

Browse files
committed
Allow emcc build
Emcc generates Wasm but not a native executable, making the generated bin2c non-executable. As a result, the device tree blob cannot be built into a C application. To resolve this, fall back to a native compiler gcc or clang to build bin2c. Additionally, ensuring CC is set to gcc, clang, or emcc. Otherwise, trigger a build error early. Related: #534
1 parent 375e96d commit 8a6e6a4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mk/system.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ $(BUILD_DTB): $(DEV_SRC)/minimal.dts
1212
$(VECHO) " DTC\t$@\n"
1313
$(Q)$(CC) -nostdinc -E -P -x assembler-with-cpp -undef $(CFLAGS_dt) $^ | $(DTC) - > $@
1414

15+
# Assume the system has either GCC or Clang
16+
NATIVE_CC := $(shell which gcc || which clang)
17+
1518
BIN_TO_C := $(OUT)/bin2c
1619
$(BIN_TO_C): tools/bin2c.c
20+
# emcc generates wasm but not executable, so fallback to use GCC or Clang
21+
ifeq ("$(CC_IS_EMCC)", "1")
22+
$(Q)$(NATIVE_CC) -Wall -o $@ $^
23+
else
1724
$(Q)$(CC) -Wall -o $@ $^
25+
endif
1826

1927
BUILD_DTB2C := src/minimal_dtb.h
2028
$(BUILD_DTB2C): $(BIN_TO_C) $(BUILD_DTB)

mk/toolchain.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ else ifneq ($(shell $(CC) --version | grep "Free Software Foundation"),)
5252
CC_IS_GCC := 1
5353
endif
5454

55+
ifeq ("$(CC_IS_CLANG)$(CC_IS_GCC)$(CC_IS_EMCC)", "")
56+
$(error "Only supported GCC/Clang/Emcc")
57+
endif
58+
5559
CFLAGS_NO_CET :=
5660
processor := $(shell uname -m)
5761
ifeq ($(processor),$(filter $(processor),i386 x86_64))

0 commit comments

Comments
 (0)