From 2864523eead672f17497f937f98c10c47f14a714 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 14 Feb 2024 01:24:04 -0500 Subject: [PATCH] Fix ldflags for compiling with GCC and add trapping integer arithmetic --- nextlang.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nextlang.c b/nextlang.c index 98e54eb..9321490 100644 --- a/nextlang.c +++ b/nextlang.c @@ -87,14 +87,16 @@ int main(int argc, char *argv[]) const char *cflags = getenv("CFLAGS"); if (!cflags) - cflags = "-std=c11"; + cflags = "-std=c11 -fsanitize=signed-integer-overflow -fno-sanitize-recover"; const char *ldlibs = "-lgc -lcord -lm -L. -lnext"; if (getenv("LDLIBS")) ldlibs = heap_strf("%s %s", ldlibs, getenv("LDLIBS")); - const char *run = heap_strf("tcc -run %s %s -", cflags, ldlibs); - // const char *run = heap_strf("gcc -x c %s %s -", cflags, ldlibs); + 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);