Skip to content

Commit 065c8b3

Browse files
authored
Merge pull request #114 from Provenance-Emu/fix/build-simd-emscripten
Fix SIMD build on MSVC + add Emscripten/WASM support
2 parents dd44259 + f302123 commit 065c8b3

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/workflows/c-cpp.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
cxx: 'g++'
4747
shell: 'msys2 {0}'
4848

49+
# Emscripten (WebAssembly)
50+
- displayTargetName: 'Emscripten (WASM)'
51+
artifact: 'virtualjaguar_libretro_emscripten.bc'
52+
os: ubuntu-latest
53+
emscripten: true
54+
4955
name: build-${{ matrix.config.displayTargetName }}
5056
runs-on: ${{ matrix.config.os }}
5157

@@ -66,12 +72,21 @@ jobs:
6672
mingw-w64-x86_64-gcc
6773
make
6874
75+
- name: Set up Emscripten
76+
if: matrix.config.emscripten
77+
uses: mymindstorm/setup-emsdk@v14
78+
6979
- name: Build
80+
if: ${{ !matrix.config.emscripten }}
7081
run: make -j4 CC=${{ matrix.config.cc }} CXX=${{ matrix.config.cxx }}
7182

83+
- name: Build (Emscripten)
84+
if: matrix.config.emscripten
85+
run: emmake make -j4 platform=emscripten
86+
7287
- name: Run SIMD blitter tests
88+
if: ${{ !matrix.config.emscripten }}
7389
run: |
74-
# Detect which SIMD impl to test based on runner architecture
7590
ARCH=$(uname -m)
7691
case "$ARCH" in
7792
x86_64|i686|i386) SIMD_SRC=src/blitter_simd_sse2.c; EXTRA="-msse2" ;;

.gitlab-ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ include:
8080
file: '/tvos-arm64.yml'
8181

8282
#################################### MISC ##################################
83+
# Emscripten (WebAssembly)
84+
- project: 'libretro-infrastructure/ci-templates'
85+
file: '/emscripten-static.yml'
86+
8387
# webOS 32-bit (LGTV)
8488
- project: 'libretro-infrastructure/ci-templates'
8589
file: '/webos-make.yml'
@@ -212,6 +216,12 @@ libretro-build-libnx-aarch64:
212216
- .core-defs
213217

214218
#################################### MISC ####################################
219+
# Emscripten (WebAssembly)
220+
libretro-build-emscripten:
221+
extends:
222+
- .libretro-emscripten-static-retroarch-master
223+
- .core-defs
224+
215225
# webOS 32-bit
216226
libretro-build-webos-armv7a:
217227
extends:

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,14 @@ else ifeq ($(platform), switch)
237237
STATIC_LINKING=1
238238
fpic := -nostdlib
239239

240-
# emscripten
240+
# emscripten (WebAssembly / asm.js for RetroArch Web Player)
241241
else ifeq ($(platform), emscripten)
242242
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
243+
CC = emcc
244+
CXX = em++
245+
AR = emar
246+
STATIC_LINKING = 1
247+
FLAGS += -DHAVE_EMSCRIPTEN
243248

244249
# Windows MSVC 2017 all architectures
245250
else ifneq (,$(findstring windows_msvc2017,$(platform)))

Makefile.common

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,18 @@ ifneq (,$(filter MINGW64% MINGW32%,$(MSYSTEM)))
9393
BLITTER_SIMD_SRC := $(CORE_DIR)/src/blitter_simd_sse2.c
9494
endif
9595
# 32-bit x86 needs explicit -msse2 (x86_64 has it baseline).
96+
# Skip for MSVC (cl.exe) — it enables SSE2 by default on x86 and does
97+
# not understand the GCC -msse2 flag.
9698
ifeq ($(BLITTER_SIMD_SRC),$(CORE_DIR)/src/blitter_simd_sse2.c)
99+
ifeq (,$(findstring msvc,$(platform)))
97100
ifneq (,$(filter i686 i386 x86 win32,$(ARCH) $(platform)))
98101
CFLAGS += -msse2
99102
endif
100103
ifneq (,$(filter MINGW32%,$(MSYSTEM)))
101104
CFLAGS += -msse2
102105
endif
103106
endif
107+
endif
104108

105109
# Native build fallback: auto-detect from host architecture, but only for
106110
# native-build platforms (unix/osx/win). Cross-compile targets (vita, ps3,

0 commit comments

Comments
 (0)