Skip to content

Allow emcc build and validate in CI #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,35 @@ jobs:
uses: rlalik/setup-cpp-compiler@master
with:
compiler: ${{ matrix.compiler }}
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.51
actions-cache-folder: 'emsdk-cache'
- name: fetch artifact first to reduce HTTP requests
env:
CC: ${{ steps.install_cc.outputs.cc }}
run: |
make artifact
make ENABLE_SYSTEM=1 artifact
make ENABLE_ARCH_TEST=1 artifact
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
--header="Referer: https://www.doomworld.com/" \
--header="Accept-Language: en-US,en;q=0.9" \
-O build/shareware_doom_iwad.zip \
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
unzip -d build/ build/shareware_doom_iwad.zip
if: ${{ always() }}
- name: default build using emcc
run: |
make CC=emcc -j$(nproc)
if: ${{ always() }}
- name: default build for system emulation using emcc
run: |
make distclean
make CC=emcc ENABLE_SYSTEM=1 -j$(nproc)
make distclean ENABLE_SYSTEM=1
if: ${{ always() }}
- name: default build with -g
env:
Expand Down
8 changes: 8 additions & 0 deletions mk/system.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ $(BUILD_DTB): $(DEV_SRC)/minimal.dts
$(VECHO) " DTC\t$@\n"
$(Q)$(CC) -nostdinc -E -P -x assembler-with-cpp -undef $(CFLAGS_dt) $^ | $(DTC) - > $@

# Assume the system has either GCC or Clang
NATIVE_CC := $(shell which gcc || which clang)

BIN_TO_C := $(OUT)/bin2c
$(BIN_TO_C): tools/bin2c.c
# emcc generates wasm but not executable, so fallback to use GCC or Clang
ifeq ("$(CC_IS_EMCC)", "1")
$(Q)$(NATIVE_CC) -Wall -o $@ $^
else
$(Q)$(CC) -Wall -o $@ $^
endif

BUILD_DTB2C := src/minimal_dtb.h
$(BUILD_DTB2C): $(BIN_TO_C) $(BUILD_DTB)
Expand Down
4 changes: 4 additions & 0 deletions mk/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ else ifneq ($(shell $(CC) --version | grep "Free Software Foundation"),)
CC_IS_GCC := 1
endif

ifeq ("$(CC_IS_CLANG)$(CC_IS_GCC)$(CC_IS_EMCC)", "")
$(error "Only supported GCC/Clang/Emcc")
endif

CFLAGS_NO_CET :=
processor := $(shell uname -m)
ifeq ($(processor),$(filter $(processor),i386 x86_64))
Expand Down
Loading