Skip to content

Commit 87a404d

Browse files
committed
Remove DETERMINISTIC setting
I'm not sure there are any users of this settings, but in case there are I have left the `src/deterministic.js` file in place which can be used via `--pre-js` instead. Fixes: #26647
1 parent f2ad693 commit 87a404d

10 files changed

Lines changed: 13 additions & 53 deletions

File tree

ChangeLog.md

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

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

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,20 +1775,6 @@ testing. See test_chunked_synchronous_xhr in runner.py and library.js.
17751775

17761776
Default value: false
17771777

1778-
.. _deterministic:
1779-
1780-
DETERMINISTIC
1781-
=============
1782-
1783-
If 1, we force Date.now(), Math.random, etc. to return deterministic results.
1784-
This also tries to make execution deterministic across machines and
1785-
environments, for example, not doing anything different based on the
1786-
browser's language setting (which would mean you can get different results
1787-
in different browsers, or in the browser and in node).
1788-
Good for comparing builds for debugging purposes (and nothing else).
1789-
1790-
Default value: false
1791-
17921778
.. _modularize:
17931779

17941780
MODULARIZE
@@ -3511,3 +3497,4 @@ for backwards compatibility with older versions:
35113497
- ``NODEJS_CATCH_REJECTION``: No longer supported (Valid values: [0])
35123498
- ``POLYFILL_OLD_MATH_FUNCTIONS``: No longer supported (Valid values: [0])
35133499
- ``RELOCATABLE``: No longer supported (Valid values: [0])
3500+
- ``DETERMINISTIC``: No longer supported (Valid values: [0])

src/deterministic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Date.now = deterministicNow;
2020
// Note: this approach does not work on certain versions of Node.js
2121
// Specifically it seems like its not possible to override performance.now on
2222
// node v16 through v18.
23-
// See getPerformanceNow in parseTools.mjs for how we deal with this.
2423
if (globalThis.performance) performance.now = deterministicNow;
2524

2625
// for consistency between different builds than between runs of the same build

src/lib/libcore.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,25 +1355,25 @@ addToLibrary({
13551355

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

1358-
emscripten_performance_now: () => {{{ getPerformanceNow() }}}(),
1358+
emscripten_performance_now: () => performance.now(),
13591359

13601360
#if PTHREADS && !AUDIO_WORKLET
13611361
// Pthreads need their clocks synchronized to the execution of the main
13621362
// thread, so, when using them, make sure to adjust all timings to the
13631363
// respective time origins.
1364-
emscripten_get_now: () => performance.timeOrigin + {{{ getPerformanceNow() }}}(),
1364+
emscripten_get_now: () => performance.timeOrigin + performance.now(),
13651365
#else
13661366
#if AUDIO_WORKLET // https://github.com/WebAudio/web-audio-api/issues/2413
13671367
emscripten_get_now: `;
13681368
// AudioWorkletGlobalScope does not have performance.now()
13691369
// (https://github.com/WebAudio/web-audio-api/issues/2527), so if building
13701370
// with
13711371
// Audio Worklets enabled, do a dynamic check for its presence.
1372-
if (globalThis.performance && {{{ getPerformanceNow() }}}) {
1372+
if (globalThis.performance && performance.now) {
13731373
#if PTHREADS
1374-
_emscripten_get_now = () => performance.timeOrigin + {{{ getPerformanceNow() }}}();
1374+
_emscripten_get_now = () => performance.timeOrigin + performance.now();
13751375
#else
1376-
_emscripten_get_now = () => {{{ getPerformanceNow() }}}();
1376+
_emscripten_get_now = () => performance.now();
13771377
#endif
13781378
} else {
13791379
_emscripten_get_now = Date.now;
@@ -1383,7 +1383,7 @@ addToLibrary({
13831383
// Modern environment where performance.now() is supported:
13841384
// N.B. a shorter form "_emscripten_get_now = performance.now;" is
13851385
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
1386-
emscripten_get_now: () => {{{ getPerformanceNow() }}}(),
1386+
emscripten_get_now: () => performance.now(),
13871387
#endif
13881388
#endif
13891389

src/lib/libwasi.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ var WasiLibrary = {
5050
$getEnvStrings: () => {
5151
if (!getEnvStrings.strings) {
5252
// Default values.
53-
#if DETERMINISTIC
54-
// Deterministic language detection, ignore the browser's language.
55-
var lang = 'C.UTF-8';
56-
#else
57-
// Browser language detection #8751
5853
var lang = (globalThis.navigator?.language ?? 'C').replace('-', '_') + '.UTF-8';
59-
#endif
6054
var env = {
6155
#if !PURE_WASI
6256
'USER': 'web_user',

src/parseTools.mjs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,17 +1105,6 @@ function formattedMinNodeVersion() {
11051105
return `v${major}.${minor}.${rev}`;
11061106
}
11071107

1108-
function getPerformanceNow() {
1109-
// This is needed to support Node.js v16 - v18 where `performance.now`
1110-
// cannot be overridden in the normal way.
1111-
// TODO(sbc): remove this once we drop support for these versions.
1112-
if (DETERMINISTIC && ENVIRONMENT_MAY_BE_NODE) {
1113-
return 'deterministicNow';
1114-
} else {
1115-
return 'performance.now';
1116-
}
1117-
}
1118-
11191108
function ENVIRONMENT_IS_MAIN_THREAD() {
11201109
return `(!${ENVIRONMENT_IS_WORKER_THREAD()})`;
11211110
}
@@ -1231,7 +1220,6 @@ addToCompileTimeContext({
12311220
getHeapForType,
12321221
getHeapOffset,
12331222
getNativeTypeSize,
1234-
getPerformanceNow,
12351223
getUnsharedTextDecoderView,
12361224
hasExportedSymbol,
12371225
isSymbolNeeded,

src/postamble.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#include "source_map_support.js"
1111
#endif
1212

13-
#if DETERMINISTIC
14-
#include "deterministic.js"
15-
#endif
16-
1713
#if ASSERTIONS
1814
var calledRun;
1915
#endif

src/settings.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,15 +1206,6 @@ var ERROR_ON_UNDEFINED_SYMBOLS = true;
12061206
// [link]
12071207
var SMALL_XHR_CHUNKS = false;
12081208

1209-
// If 1, we force Date.now(), Math.random, etc. to return deterministic results.
1210-
// This also tries to make execution deterministic across machines and
1211-
// environments, for example, not doing anything different based on the
1212-
// browser's language setting (which would mean you can get different results
1213-
// in different browsers, or in the browser and in node).
1214-
// Good for comparing builds for debugging purposes (and nothing else).
1215-
// [link]
1216-
var DETERMINISTIC = false;
1217-
12181209
// By default we emit all code in a straightforward way into the output
12191210
// .js file. That means that if you load that in a script tag in a web
12201211
// page, it will use the global scope. With ``MODULARIZE`` set, we instead emit

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12059,7 +12059,7 @@ def test_deterministic(self):
1205912059
printf("JS random: %d\n", EM_ASM_INT({ return Math.random() }));
1206012060
}
1206112061
''')
12062-
self.run_process([EMCC, 'src.c', '-sDETERMINISTIC'] + self.get_cflags())
12062+
self.run_process([EMCC, 'src.c', '--pre-js', path_from_root('src/deterministic.js')] + self.get_cflags())
1206312063
one = self.run_js('a.out.js')
1206412064
# ensure even if the time resolution is 1 second, that if we see the real
1206512065
# time we'll see a difference

tools/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
['NODEJS_CATCH_REJECTION', [0], 'No longer supported'],
253253
['POLYFILL_OLD_MATH_FUNCTIONS', [0], 'No longer supported'],
254254
['RELOCATABLE', [0], 'No longer supported'],
255+
['DETERMINISTIC', [0], 'No longer supported'],
255256
]
256257

257258
user_settings: dict[str, str] = {}

0 commit comments

Comments
 (0)