Skip to content

Commit

Permalink
Work around broken atomics in tinycc (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis authored Nov 12, 2024
1 parent c41ee4f commit 4871290
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion run-test262.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test262.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4871290

Please sign in to comment.