Skip to content

Commit 52ccabb

Browse files
authored
Merge branch 'main' into cw-audio-memory64
2 parents 92dc53e + 3084681 commit 52ccabb

File tree

209 files changed

+2280
-2006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+2280
-2006
lines changed

.circleci/config.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ jobs:
526526
asan.test_externref_emjs_dynlink
527527
asan.test_asyncify_longjmp
528528
asan.test_pthread_run_on_main_thread
529+
asan.test_minimal_runtime_global_initializer
529530
lsan.test_dylink_dso_needed
530531
lsan.test_stdio_locking
531532
lsan.test_dlfcn_basic
@@ -769,8 +770,7 @@ jobs:
769770
other.test_node_unhandled_rejection
770771
core2.test_hello_world
771772
core0.test_pthread_join_and_asyncify
772-
core0.test_async_ccall_promise_jspi
773-
core0.test_async_ccall_promise_exit_runtime_jspi
773+
core0.test_async_ccall_promise_jspi*
774774
core0.test_cubescript_jspi"
775775
# Run some basic tests with the minimum version of node that we currently
776776
# support in the generated code.
@@ -984,7 +984,6 @@ jobs:
984984
EMTEST_SKIP_V8: "1"
985985
EMTEST_SKIP_EH: "1"
986986
EMTEST_SKIP_WASM64: "1"
987-
EMTEST_SKIP_SIMD: "1"
988987
EMTEST_SKIP_SCONS: "1"
989988
EMTEST_SKIP_RUST: "1"
990989
EMTEST_SKIP_NODE_CANARY: "1"

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ tools/crunch-worker.js -diff
44
third_party/lzma.js/lzma-decoder.js -diff
55
third_party/lzma.js/lzma-full.js -diff
66
test/other/test_emsize.js -diff
7-
src/emscripten-source-map.min.js -diff
87
test/* linguist-vendored
98
third_party/* linguist-vendored
109
system/ linguist-vendored

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- name: Checkout repo
3434
uses: actions/checkout@v4
3535
with:
36+
submodules: true
3637
fetch-depth: 0 # We want access to other branches, specifically `main`
3738
- name: pip install
3839
run: |

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ jobs:
5252

5353
# Upload the results to GitHub's code scanning dashboard.
5454
- name: "Upload to code-scanning"
55-
uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
55+
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
5656
with:
5757
sarif_file: results.sarif

ChangeLog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.3 (in development)
2222
----------------------
23+
- emscan-deps tools was added. This tool wraps clang-scan-deps and injects the
24+
needed `--target` and `--sysroot` argument that would normally be injected by
25+
emcc itself. This enables support for C++20 in cmake projects. (#21987)
26+
- The version of python required to run emscripten was bumped from 3.6 to 3.8.
27+
(#23417)
28+
- The `EM_LOG_C_STACK` flag to `emscripten_log` was deprecated and the helper
29+
file on which it was based (`emscripten-source-map.min.js`) deleted. This
30+
feature (userspace source map parsing in logs) was never ported to wasm
31+
source maps, so it has not worked in many years, and there have been no
32+
requests for it. This has no impact on the source map support in browser
33+
devtools. (#23553)
2334

2435
4.0.2 - 01/30/25
2536
----------------
@@ -34,6 +45,10 @@ See docs/process.md for more on how version tagging works.
3445
- The system JS libraries in `src/` were renamed from `library_foo.js` to
3546
`lib/libfoo.js`. They are still included via the same `-lfoo.js` flag so
3647
this should not be a user-visible change. (#23348)
48+
- When using cmake the emscripten toolchain will no longer skip the toolchain
49+
detection stages. This means the initial cmake run will be slower, but will
50+
result in more accruate information. If cmake is running too slow for you,
51+
you can revert to the previous behaviour with `-DEMSCRIPTEN_FORCE_COMPILERS=ON`.
3752

3853
4.0.1 - 01/17/25
3954
----------------

bootstrap.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
'tools/maint/run_python.bat',
2727
'tools/maint/run_python.sh',
2828
'tools/maint/run_python.ps1',
29-
],
30-
[sys.executable, 'tools/maint/create_entry_points.py']),
31-
('git submodules', ['test/third_party/posixtestsuite/'], [shutil.which('git'), 'submodule', 'update', '--init']),
29+
], [sys.executable, 'tools/maint/create_entry_points.py']),
30+
('git submodules', [
31+
'test/third_party/posixtestsuite/',
32+
'test/third_party/googletest',
33+
'test/third_party/wasi-test-suite',
34+
], [shutil.which('git'), 'submodule', 'update', '--init']),
3235
]
3336

3437

cmake/Modules/Platform/Emscripten.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ set(CMAKE_C_COMPILER_AR "${CMAKE_AR}")
9393
set(CMAKE_CXX_COMPILER_AR "${CMAKE_AR}")
9494
set(CMAKE_C_COMPILER_RANLIB "${CMAKE_RANLIB}")
9595
set(CMAKE_CXX_COMPILER_RANLIB "${CMAKE_RANLIB}")
96+
set(CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS "${EMSCRIPTEN_ROOT_PATH}/emscan-deps")
9697

9798
# Capture the Emscripten version to EMSCRIPTEN_VERSION variable.
9899
if (NOT EMSCRIPTEN_VERSION)
@@ -120,11 +121,9 @@ endif()
120121
file(TO_CMAKE_PATH "${_emcache_output}" _emcache_output)
121122
set(EMSCRIPTEN_SYSROOT "${_emcache_output}/sysroot")
122123

123-
# Don't allow CMake to autodetect the compiler, since this is quite slow with
124-
# Emscripten.
125-
# Pass -DEMSCRIPTEN_FORCE_COMPILERS=OFF to disable (sensible mostly only for
126-
# testing/debugging purposes).
127-
option(EMSCRIPTEN_FORCE_COMPILERS "Force C/C++ compiler" ON)
124+
# Allow skipping of CMake compiler autodetection, since this is quite slow with
125+
# Emscripten. Pass -DEMSCRIPTEN_FORCE_COMPILERS=ON to enable
126+
option(EMSCRIPTEN_FORCE_COMPILERS "Force C/C++ compiler" OFF)
128127
if (EMSCRIPTEN_FORCE_COMPILERS)
129128

130129
# Detect version of the 'emcc' executable. Note that for CMake, we tell it the

emcc.py

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,24 @@ class Mode(Enum):
108108
COMPILE_AND_LINK = auto()
109109

110110

111+
class LinkFlag:
112+
"""Used to represent a linker flag.
113+
114+
The flag value is stored along with a bool that distingingishes input
115+
files from non-files.
116+
117+
A list of these is return by separate_linker_flags.
118+
"""
119+
def __init__(self, value, is_file):
120+
self.value = value
121+
self.is_file = is_file
122+
123+
111124
class EmccState:
112125
def __init__(self, args):
113126
self.mode = Mode.COMPILE_AND_LINK
114127
# Using tuple here to prevent accidental mutation
115128
self.orig_args = tuple(args)
116-
# List of link options paired with their position on the command line [(i, option), ...].
117-
self.link_flags = []
118-
self.lib_dirs = []
119-
120-
def has_link_flag(self, f):
121-
return f in [x for _, x in self.link_flags]
122-
123-
def add_link_flag(self, i, flag):
124-
if flag.startswith('-L'):
125-
self.lib_dirs.append(flag[2:])
126-
# Link flags should be adding in strictly ascending order
127-
assert not self.link_flags or i > self.link_flags[-1][0], self.link_flags
128-
self.link_flags.append((i, flag))
129-
130-
def append_link_flag(self, flag):
131-
if self.link_flags:
132-
index = self.link_flags[-1][0] + 1
133-
else:
134-
index = 1
135-
self.add_link_flag(index, flag)
136129

137130

138131
class EmccOptions:
@@ -190,6 +183,7 @@ def __init__(self):
190183
self.nostartfiles = False
191184
self.sanitize_minimal_runtime = False
192185
self.sanitize = set()
186+
self.lib_dirs = []
193187

194188

195189
def create_reproduce_file(name, args):
@@ -662,20 +656,21 @@ def run(args):
662656
if state.mode == Mode.POST_LINK_ONLY:
663657
if len(options.input_files) != 1:
664658
exit_with_error('--post-link requires a single input file')
665-
separate_linker_flags(state, newargs)
659+
linker_args = separate_linker_flags(newargs)[1]
660+
linker_args = [f.value for f in linker_args]
666661
# Delay import of link.py to avoid processing this file when only compiling
667662
from tools import link
668-
link.run_post_link(options.input_files[0], options, state)
663+
link.run_post_link(options.input_files[0], options, linker_args)
669664
return 0
670665

671666
# Compile source code to object files
672667
# When only compiling this function never returns.
673-
linker_inputs = phase_compile_inputs(options, state, newargs)
668+
linker_args = phase_compile_inputs(options, state, newargs)
674669

675670
if state.mode == Mode.COMPILE_AND_LINK:
676671
# Delay import of link.py to avoid processing this file when only compiling
677672
from tools import link
678-
return link.run(linker_inputs, options, state)
673+
return link.run(options, linker_args)
679674
else:
680675
logger.debug('stopping after compile phase')
681676
return 0
@@ -747,26 +742,21 @@ def phase_parse_arguments(state):
747742
return options, newargs
748743

749744

750-
def separate_linker_flags(state, newargs):
751-
"""Process argument list separating out input files, compiler flags
752-
and linker flags.
753-
754-
- Linker flags are stored in state.link_flags
755-
- Input files and compiler-only flags are returned as two separate lists.
745+
def separate_linker_flags(newargs):
746+
"""Process argument list separating out compiler args and linker args.
756747
757-
Both linker flags and input files are stored as pairs of (i, entry) where
758-
`i` is the orginal index in the command line arguments. This allow the two
759-
lists to be recombined in the correct order by the linker code (link.py).
760-
761-
Note that this index can have a fractional part for input arguments that
762-
expand into multiple processed arguments, as in -Wl,-f1,-f2.
748+
- Linker flags include input files and are returned a list of LinkFlag objects.
749+
- Compiler flags are those to be passed to `clang -c`.
763750
"""
764751

765752
if settings.RUNTIME_LINKED_LIBS:
766753
newargs += settings.RUNTIME_LINKED_LIBS
767754

768-
input_files = []
769755
compiler_args = []
756+
linker_args = []
757+
758+
def add_link_arg(flag, is_file=False):
759+
linker_args.append(LinkFlag(flag, is_file))
770760

771761
skip = False
772762
for i in range(len(newargs)):
@@ -789,30 +779,24 @@ def get_next_arg():
789779
# https://bugs.python.org/issue1311
790780
if not os.path.exists(arg) and arg not in (os.devnull, '-'):
791781
exit_with_error('%s: No such file or directory ("%s" was expected to be an input file, based on the commandline arguments provided)', arg, arg)
792-
input_files.append((i, arg))
782+
add_link_arg(arg, True)
793783
elif arg == '-z':
794-
state.add_link_flag(i, newargs[i])
795-
state.add_link_flag(i + 1, get_next_arg())
784+
add_link_arg(arg)
785+
add_link_arg(get_next_arg())
796786
elif arg.startswith('-Wl,'):
797-
# Multiple comma separated link flags can be specified. Create fake
798-
# fractional indices for these: -Wl,a,b,c,d at index 4 becomes:
799-
# (4, a), (4.25, b), (4.5, c), (4.75, d)
800-
link_flags_to_add = arg.split(',')[1:]
801-
for flag_index, flag in enumerate(link_flags_to_add):
802-
state.add_link_flag(i + float(flag_index) / len(link_flags_to_add), flag)
787+
for flag in arg.split(',')[1:]:
788+
add_link_arg(flag)
803789
elif arg == '-Xlinker':
804-
state.add_link_flag(i + 1, get_next_arg())
805-
elif arg == '-s':
806-
state.add_link_flag(i, newargs[i])
790+
add_link_arg(get_next_arg())
807791
elif arg == '-s' or arg.startswith(('-l', '-L', '--js-library=', '-z')):
808-
state.add_link_flag(i, arg)
792+
add_link_arg(arg)
809793
elif not arg.startswith('-o') and arg not in ('-nostdlib', '-nostartfiles', '-nolibc', '-nodefaultlibs', '-s'):
810794
# All other flags are for the compiler
811795
compiler_args.append(arg)
812796
if skip:
813797
compiler_args.append(get_next_arg())
814798

815-
return compiler_args, input_files
799+
return compiler_args, linker_args
816800

817801

818802
@ToolchainProfiler.profile_block('setup')
@@ -955,8 +939,7 @@ def get_clang_command_asm():
955939
# filter out the link flags
956940
assert state.mode == Mode.COMPILE_AND_LINK
957941
assert not options.dash_c
958-
compile_args, input_files = separate_linker_flags(state, newargs)
959-
linker_inputs = []
942+
compile_args, linker_args = separate_linker_flags(newargs)
960943
seen_names = {}
961944

962945
def uniquename(name):
@@ -967,10 +950,9 @@ def uniquename(name):
967950
def get_object_filename(input_file):
968951
return in_temp(shared.replace_suffix(uniquename(input_file), '.o'))
969952

970-
def compile_source_file(i, input_file):
953+
def compile_source_file(input_file):
971954
logger.debug(f'compiling source file: {input_file}')
972955
output_file = get_object_filename(input_file)
973-
linker_inputs.append((i, output_file))
974956
if get_file_suffix(input_file) in ASSEMBLY_EXTENSIONS:
975957
cmd = get_clang_command_asm()
976958
elif get_file_suffix(input_file) in PREPROCESSED_EXTENSIONS:
@@ -993,28 +975,29 @@ def compile_source_file(i, input_file):
993975
assert os.path.exists(output_file)
994976
if options.save_temps:
995977
shutil.copyfile(output_file, shared.unsuffixed_basename(input_file) + '.o')
978+
return output_file
996979

997-
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
998-
for i, input_file in input_files:
980+
# Compile input files individually to temporary locations.
981+
for arg in linker_args:
982+
if not arg.is_file:
983+
continue
984+
input_file = arg.value
999985
file_suffix = get_file_suffix(input_file)
1000986
if file_suffix in SOURCE_EXTENSIONS | ASSEMBLY_EXTENSIONS or (options.dash_c and file_suffix == '.bc'):
1001-
compile_source_file(i, input_file)
987+
arg.value = compile_source_file(input_file)
1002988
elif file_suffix in DYLIB_EXTENSIONS:
1003989
logger.debug(f'using shared library: {input_file}')
1004-
linker_inputs.append((i, input_file))
1005990
elif building.is_ar(input_file):
1006991
logger.debug(f'using static library: {input_file}')
1007-
linker_inputs.append((i, input_file))
1008992
elif options.input_language:
1009-
compile_source_file(i, input_file)
993+
arg.value = compile_source_file(input_file)
1010994
elif input_file == '-':
1011995
exit_with_error('-E or -x required when input is from standard input')
1012996
else:
1013997
# Default to assuming the inputs are object files and pass them to the linker
1014-
logger.debug(f'using object file: {input_file}')
1015-
linker_inputs.append((i, input_file))
998+
pass
1016999

1017-
return linker_inputs
1000+
return [f.value for f in linker_args]
10181001

10191002

10201003
def version_string():
@@ -1319,6 +1302,8 @@ def consume_arg_file():
13191302
'encountered. If this is to a local system header/library, it may '
13201303
'cause problems (local system files make sense for compiling natively '
13211304
'on your system, but not necessarily to JavaScript).')
1305+
if arg.startswith('-L'):
1306+
options.lib_dirs.append(path_name)
13221307
elif check_flag('--emrun'):
13231308
options.emrun = True
13241309
elif check_flag('--cpuprofiler'):

emscan-deps

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
# Copyright 2020 The Emscripten Authors. All rights reserved.
3+
# Emscripten is available under two separate licenses, the MIT license and the
4+
# University of Illinois/NCSA Open Source License. Both these licenses can be
5+
# found in the LICENSE file.
6+
#
7+
# Entry point for running python scripts on UNIX systems.
8+
#
9+
# Automatically generated by `create_entry_points.py`; DO NOT EDIT.
10+
#
11+
# To make modifications to this file, edit `tools/run_python.sh` and then run
12+
# `tools/maint/create_entry_points.py`
13+
14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
18+
if [ -z "$PYTHON" ]; then
19+
PYTHON=$EMSDK_PYTHON
20+
fi
21+
22+
if [ -z "$PYTHON" ]; then
23+
PYTHON=$(command -v python3 2> /dev/null)
24+
fi
25+
26+
if [ -z "$PYTHON" ]; then
27+
PYTHON=$(command -v python 2> /dev/null)
28+
fi
29+
30+
if [ -z "$PYTHON" ]; then
31+
echo 'unable to find python in $PATH'
32+
exit 1
33+
fi
34+
35+
exec "$PYTHON" -E "$0.py" "$@"

0 commit comments

Comments
 (0)