From 487129055f14cfaf844c5675d96586395e1a1b87 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 12 Nov 2024 01:01:52 +0100 Subject: [PATCH] Work around broken atomics in tinycc (#669) --- quickjs.c | 5 ++++- run-test262.c | 10 +++++++++- test262.conf | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/quickjs.c b/quickjs.c index a612f079..f2fc66b8 100644 --- a/quickjs.c +++ b/quickjs.c @@ -62,7 +62,10 @@ #define NO_TM_GMTOFF #endif -#if !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__ +// atomic_store etc. are completely busted in recent versions of tcc; +// somehow the compiler forgets to load |ptr| into %rdi when calling +// the __atomic_*() helpers in its lib/stdatomic.c and lib/atomic.S +#if !defined(__TINYC__) && !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__ #include "quickjs-c-atomics.h" #define CONFIG_ATOMICS #endif diff --git a/run-test262.c b/run-test262.c index c63b9102..5d42139e 100644 --- a/run-test262.c +++ b/run-test262.c @@ -50,6 +50,14 @@ typedef pthread_t js_thread_t; #define CMD_NAME "run-test262" +// not quite correct because in theory someone could compile quickjs.c +// with a different compiler but in practice no one does that, right? +#ifdef __TINYC__ +#define CC_IS_TCC 1 +#else +#define CC_IS_TCC 0 +#endif + typedef struct { js_mutex_t agent_mutex; js_cond_t agent_cond; @@ -1219,7 +1227,7 @@ void load_config(const char *filename, const char *ignore) namelist_add(&exclude_list, base_name, p); break; case SECTION_FEATURES: - if (!q || str_equal(q, "yes")) + if (!q || str_equal(q, "yes") || (!CC_IS_TCC && str_equal(q, "!tcc"))) str_append(&harness_features, " ", p); else str_append(&harness_skip_features, " ", p); diff --git a/test262.conf b/test262.conf index dfec6f70..9b721c8f 100644 --- a/test262.conf +++ b/test262.conf @@ -62,7 +62,8 @@ arraybuffer-transfer arrow-function async-functions async-iteration -Atomics +# atomics are broken in recent versions of tcc +Atomics=!tcc Atomics.pause=skip Atomics.waitAsync=skip BigInt