From f189a90829d6f579a96241010af82b9fd5c8fb49 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 10 Nov 2024 22:37:59 +0100 Subject: [PATCH 1/2] Work around broken atomics in tinycc --- 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 ca4db6940..d0622dc57 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 c63b9102b..2c01c91b7 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 dfec6f701..9b721c8f7 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 From 2b006509d9c889835620d75202b1cec34ada71a7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 10 Nov 2024 22:57:06 +0100 Subject: [PATCH 2/2] squash! silence compiler --- run-test262.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-test262.c b/run-test262.c index 2c01c91b7..5d42139e1 100644 --- a/run-test262.c +++ b/run-test262.c @@ -1227,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") || !CC_IS_TCC && str_equal(q, "!tcc")) + 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);