Skip to content

Commit 8abfdb7

Browse files
committed
Fix C++ standard support for Emscripten
The first versions of Emscripten that correspond with the Clang version Meson uses to determine flag support don't actually support the expected flags. So I went through and picked the first version that actually worked with the expected flags. Fixes mesonbuild#13628
1 parent d48602a commit 8abfdb7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mesonbuild/compilers/cpp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,15 @@ class EmscriptenCPPCompiler(EmscriptenMixin, ClangCPPCompiler):
350350

351351
id = 'emscripten'
352352

353+
# Emscripten uses different version numbers than Clang; `emcc -v` will show
354+
# the Clang version number used as well (but `emcc --version` does not).
355+
# See https://github.com/pyodide/pyodide/discussions/4762 for more on
356+
# emcc <--> clang versions. Note, although earlier versions claim to be the
357+
# Clang versions 12.0.0 and 17.0.0 required for these C++ standards, they
358+
# only accept the flags in the later versions below.
359+
_CPP23_VERSION = '>=2.0.10'
360+
_CPP26_VERSION = '>=3.1.39'
361+
353362
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool,
354363
info: 'MachineInfo',
355364
linker: T.Optional['DynamicLinker'] = None,

test cases/wasm/1 basic/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project('emcctest', 'c', 'cpp',
22
default_options: [
33
'c_std=c17',
4-
'cpp_std=c++17',
4+
'cpp_std=c++26',
55
]
66
)
77

0 commit comments

Comments
 (0)