--- a/qjsc.c
+++ b/qjsc.c
@@ -452,6 +452,9 @@ static int output_executable(const char *out_filename, const char *cfilename,
*arg++ = "-lm";
*arg++ = "-ldl";
*arg++ = "-lpthread";
+#ifdef LINK_ATOMIC
+ *arg++ = "-latomic";
+#endif
*arg = NULL;
if (verbose) {