aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--nextlang.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index f5682ee0..e44a17e4 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ tags:
ctags *.[ch] **/*.[ch]
test: nextlang
- for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 ./nextlang "$$f" || break; done
+ for f in tests/*; do echo -e "\x1b[1;4m$$f\x1b[m"; VERBOSE=0 CC=tcc ./nextlang "$$f" || break; done
clean:
rm -f nextlang *.o SipHash/halfsiphash.o builtins/*.o libnext.so
diff --git a/nextlang.c b/nextlang.c
index 62a3feec..0e52a790 100644
--- a/nextlang.c
+++ b/nextlang.c
@@ -79,11 +79,13 @@ int main(int argc, char *argv[])
const char *ldflags = "-Wl,-rpath '-Wl,$ORIGIN'";
- // const char *run = heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs);
- const char *run = heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs);
- FILE *cc = popen(run, "w");
- CORD_put(program, cc);
- fclose(cc);
+ const char *cc = getenv("CC");
+ if (!cc) cc = "tcc";
+ const char *run = streq(cc, "tcc") ? heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs)
+ : heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs);
+ FILE *runner = popen(run, "w");
+ CORD_put(program, runner);
+ fclose(runner);
return 0;
}