From bc3667cc3de2a6df699a61b4549037c84f75fe03 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 28 Mar 2025 17:17:58 -0400 Subject: [PATCH] Conditional flags for running tomo with clang vs gcc --- src/tomo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tomo.c b/src/tomo.c index 2b2617c..6bbcc93 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -106,9 +106,6 @@ int main(int argc, char *argv[]) #ifdef __OpenBSD__ ldlibs = Texts(ldlibs, Text(" -lexecinfo -lpthread")); -#else - cflags = Texts(cflags, Text(" -fsanitize=signed-integer-overflow -fno-sanitize-recover" - " -fno-signaling-nans -fno-trapping-math")); #endif USE_COLOR = getenv("COLOR") ? strcmp(getenv("COLOR"), "1") == 0 : isatty(STDOUT_FILENO); @@ -171,6 +168,12 @@ int main(int argc, char *argv[]) {"f", false, &Bool$info, &clean_build}, ); + bool is_gcc = (system(String(cc, " -v 2>&1 | grep 'gcc version' >/dev/null")) == 0); + if (is_gcc) { + cflags = Texts(cflags, Text(" -fsanitize=signed-integer-overflow -fno-sanitize-recover" + " -fno-signaling-nans -fno-trapping-math")); + } + if (show_codegen.length > 0 && Text$equal_values(show_codegen, Text("pretty"))) show_codegen = Text("sed '/^#line/d;/^$/d' | indent -o /dev/stdout | bat -l c -P");