Skip to content

Commit 4871290

Browse files
authored
Work around broken atomics in tinycc (#669)
1 parent c41ee4f commit 4871290

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

quickjs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@
6262
#define NO_TM_GMTOFF
6363
#endif
6464

65-
#if !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__
65+
// atomic_store etc. are completely busted in recent versions of tcc;
66+
// somehow the compiler forgets to load |ptr| into %rdi when calling
67+
// the __atomic_*() helpers in its lib/stdatomic.c and lib/atomic.S
68+
#if !defined(__TINYC__) && !defined(EMSCRIPTEN) && !defined(__wasi__) && !__STDC_NO_ATOMICS__
6669
#include "quickjs-c-atomics.h"
6770
#define CONFIG_ATOMICS
6871
#endif

run-test262.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ typedef pthread_t js_thread_t;
5050

5151
#define CMD_NAME "run-test262"
5252

53+
// not quite correct because in theory someone could compile quickjs.c
54+
// with a different compiler but in practice no one does that, right?
55+
#ifdef __TINYC__
56+
#define CC_IS_TCC 1
57+
#else
58+
#define CC_IS_TCC 0
59+
#endif
60+
5361
typedef struct {
5462
js_mutex_t agent_mutex;
5563
js_cond_t agent_cond;
@@ -1219,7 +1227,7 @@ void load_config(const char *filename, const char *ignore)
12191227
namelist_add(&exclude_list, base_name, p);
12201228
break;
12211229
case SECTION_FEATURES:
1222-
if (!q || str_equal(q, "yes"))
1230+
if (!q || str_equal(q, "yes") || (!CC_IS_TCC && str_equal(q, "!tcc")))
12231231
str_append(&harness_features, " ", p);
12241232
else
12251233
str_append(&harness_skip_features, " ", p);

test262.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ arraybuffer-transfer
6262
arrow-function
6363
async-functions
6464
async-iteration
65-
Atomics
65+
# atomics are broken in recent versions of tcc
66+
Atomics=!tcc
6667
Atomics.pause=skip
6768
Atomics.waitAsync=skip
6869
BigInt

0 commit comments

Comments
 (0)