Skip to content
Draft
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
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.

5.0.6 (in development)
----------------------
- The `-sDETERMINISTIC` setting was removed. This setting just injected
`src/deterministic.js` as a `--pre-js`. For now, this file remains part of
emscripten. If you are a user of this feature please let us know otherwise
this may be deleted in a future release.
- The minimum version of node supported by the generated code was bumped from
v12.22.0 to v18.3.0. (#26604)

Expand Down
15 changes: 1 addition & 14 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1775,20 +1775,6 @@ testing. See test_chunked_synchronous_xhr in runner.py and library.js.

Default value: false

.. _deterministic:

DETERMINISTIC
=============

If 1, we force Date.now(), Math.random, etc. to return deterministic results.
This also tries to make execution deterministic across machines and
environments, for example, not doing anything different based on the
browser's language setting (which would mean you can get different results
in different browsers, or in the browser and in node).
Good for comparing builds for debugging purposes (and nothing else).

Default value: false

.. _modularize:

MODULARIZE
Expand Down Expand Up @@ -3511,3 +3497,4 @@ for backwards compatibility with older versions:
- ``NODEJS_CATCH_REJECTION``: No longer supported (Valid values: [0])
- ``POLYFILL_OLD_MATH_FUNCTIONS``: No longer supported (Valid values: [0])
- ``RELOCATABLE``: No longer supported (Valid values: [0])
- ``DETERMINISTIC``: No longer supported (Valid values: [0])
1 change: 0 additions & 1 deletion src/deterministic.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Date.now = deterministicNow;
// Note: this approach does not work on certain versions of Node.js
// Specifically it seems like its not possible to override performance.now on
// node v16 through v18.
// See getPerformanceNow in parseTools.mjs for how we deal with this.
if (globalThis.performance) performance.now = deterministicNow;

// for consistency between different builds than between runs of the same build
Expand Down
12 changes: 6 additions & 6 deletions src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1355,25 +1355,25 @@ addToLibrary({

emscripten_date_now: () => Date.now(),

emscripten_performance_now: () => {{{ getPerformanceNow() }}}(),
emscripten_performance_now: () => performance.now(),

#if PTHREADS && !AUDIO_WORKLET
// Pthreads need their clocks synchronized to the execution of the main
// thread, so, when using them, make sure to adjust all timings to the
// respective time origins.
emscripten_get_now: () => performance.timeOrigin + {{{ getPerformanceNow() }}}(),
emscripten_get_now: () => performance.timeOrigin + performance.now(),
#else
#if AUDIO_WORKLET // https://github.com/WebAudio/web-audio-api/issues/2413
emscripten_get_now: `;
// AudioWorkletGlobalScope does not have performance.now()
// (https://github.com/WebAudio/web-audio-api/issues/2527), so if building
// with
// Audio Worklets enabled, do a dynamic check for its presence.
if (globalThis.performance && {{{ getPerformanceNow() }}}) {
if (globalThis.performance && performance.now) {
#if PTHREADS
_emscripten_get_now = () => performance.timeOrigin + {{{ getPerformanceNow() }}}();
_emscripten_get_now = () => performance.timeOrigin + performance.now();
#else
_emscripten_get_now = () => {{{ getPerformanceNow() }}}();
_emscripten_get_now = () => performance.now();
#endif
} else {
_emscripten_get_now = Date.now;
Expand All @@ -1383,7 +1383,7 @@ addToLibrary({
// Modern environment where performance.now() is supported:
// N.B. a shorter form "_emscripten_get_now = performance.now;" is
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
emscripten_get_now: () => {{{ getPerformanceNow() }}}(),
emscripten_get_now: () => performance.now(),
#endif
#endif

Expand Down
6 changes: 0 additions & 6 deletions src/lib/libwasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ var WasiLibrary = {
$getEnvStrings: () => {
if (!getEnvStrings.strings) {
// Default values.
#if DETERMINISTIC
// Deterministic language detection, ignore the browser's language.
var lang = 'C.UTF-8';
#else
// Browser language detection #8751
var lang = (globalThis.navigator?.language ?? 'C').replace('-', '_') + '.UTF-8';
#endif
var env = {
#if !PURE_WASI
'USER': 'web_user',
Expand Down
12 changes: 0 additions & 12 deletions src/parseTools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,17 +1105,6 @@ function formattedMinNodeVersion() {
return `v${major}.${minor}.${rev}`;
}

function getPerformanceNow() {
// This is needed to support Node.js v16 - v18 where `performance.now`
// cannot be overridden in the normal way.
// TODO(sbc): remove this once we drop support for these versions.
if (DETERMINISTIC && ENVIRONMENT_MAY_BE_NODE) {
return 'deterministicNow';
} else {
return 'performance.now';
}
}

function ENVIRONMENT_IS_MAIN_THREAD() {
return `(!${ENVIRONMENT_IS_WORKER_THREAD()})`;
}
Expand Down Expand Up @@ -1231,7 +1220,6 @@ addToCompileTimeContext({
getHeapForType,
getHeapOffset,
getNativeTypeSize,
getPerformanceNow,
getUnsharedTextDecoderView,
hasExportedSymbol,
isSymbolNeeded,
Expand Down
4 changes: 0 additions & 4 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include "source_map_support.js"
#endif

#if DETERMINISTIC
#include "deterministic.js"
#endif

#if ASSERTIONS
var calledRun;
#endif
Expand Down
9 changes: 0 additions & 9 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1206,15 +1206,6 @@ var ERROR_ON_UNDEFINED_SYMBOLS = true;
// [link]
var SMALL_XHR_CHUNKS = false;

// If 1, we force Date.now(), Math.random, etc. to return deterministic results.
// This also tries to make execution deterministic across machines and
// environments, for example, not doing anything different based on the
// browser's language setting (which would mean you can get different results
// in different browsers, or in the browser and in node).
// Good for comparing builds for debugging purposes (and nothing else).
// [link]
var DETERMINISTIC = false;

// By default we emit all code in a straightforward way into the output
// .js file. That means that if you load that in a script tag in a web
// page, it will use the global scope. With ``MODULARIZE`` set, we instead emit
Expand Down
2 changes: 1 addition & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -12059,7 +12059,7 @@ def test_deterministic(self):
printf("JS random: %d\n", EM_ASM_INT({ return Math.random() }));
}
''')
self.run_process([EMCC, 'src.c', '-sDETERMINISTIC'] + self.get_cflags())
self.run_process([EMCC, 'src.c', '--pre-js', path_from_root('src/deterministic.js')] + self.get_cflags())
one = self.run_js('a.out.js')
# ensure even if the time resolution is 1 second, that if we see the real
# time we'll see a difference
Expand Down
1 change: 1 addition & 0 deletions tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
['NODEJS_CATCH_REJECTION', [0], 'No longer supported'],
['POLYFILL_OLD_MATH_FUNCTIONS', [0], 'No longer supported'],
['RELOCATABLE', [0], 'No longer supported'],
['DETERMINISTIC', [0], 'No longer supported'],
]

user_settings: dict[str, str] = {}
Expand Down
Loading