From b5c861e5cecb12ff98875f997bdcb083db9743b6 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Sat, 4 Apr 2026 18:59:16 +0200 Subject: [PATCH] Compiler: reduce compiler output verbosity * add `--terse` option to disable logging messages * make Makefile rebuild target less verbose --- Makefile | 24 ++++++++++++------------ compiler/main.c2 | 14 +++++++++++--- examples/Makefile | 3 ++- install_plugins.sh | 2 +- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index fc8d06b73..5b6215284 100644 --- a/Makefile +++ b/Makefile @@ -31,11 +31,11 @@ $(C2C): output/bootstrap/bootstrap $(C2C_DEPS) @rm -rf output/bootstrap/cgen @mv -f output/c2c/* output/bootstrap @echo "---- running c2c (no plugins$(C2FLAGS)) ----" - @output/bootstrap/c2c $(C2FLAGS) --noplugins --fast c2c $(PLUGINS) + @output/bootstrap/c2c $(C2FLAGS) --noplugins --fast --terse c2c $(PLUGINS) @mv -f output/c2c/c2c output/c2c/c2c_fast @./install_plugins.sh @echo "---- running c2c (optimized with plugins$(C2FLAGS)) ----" - @output/c2c/c2c_fast $(C2FLAGS) + @output/c2c/c2c_fast $(C2FLAGS) --terse @./install_plugins.sh output/bootstrap/bootstrap: @@ -48,22 +48,22 @@ ubsan:; @$(MAKE) -B UBSAN=1 debug:; @$(MAKE) -B DEBUG=1 output/tester/tester: tools/tester/*.c2 $(C2C_DEPS) $(C2C) - @$(C2C) tester + @$(C2C) tester --terse test-bootstrap: $(C2C) - @$(C2C) c2c -o c2c_bootstrap --bootstrap + @$(C2C) c2c -o c2c_bootstrap --bootstrap --terse rebuild-bootstrap: $(C2C) @echo "generating bootstrap files for various systems/architectures" - $(C2C) c2c -b bootstrap/build-linux-x86_64.yaml --no-build --bootstrap + $(C2C) c2c -b bootstrap/build-linux-x86_64.yaml --no-build --bootstrap --terse mv -f output/linux-x86_64/c2c/cgen/build.c bootstrap/bootstrap.c - $(C2C) c2c -b bootstrap/build-darwin-x86_64.yaml --no-build --bootstrap + $(C2C) c2c -b bootstrap/build-darwin-x86_64.yaml --no-build --bootstrap --terse ( diff bootstrap/bootstrap.c output/darwin-x86_64/c2c/cgen/build.c > bootstrap/bootstrap-darwin-x86_64.patch ; true ) - $(C2C) c2c -b bootstrap/build-darwin-arm64.yaml --no-build --bootstrap + $(C2C) c2c -b bootstrap/build-darwin-arm64.yaml --no-build --bootstrap --terse ( diff bootstrap/bootstrap.c output/darwin-arm64/c2c/cgen/build.c > bootstrap/bootstrap-darwin-arm64.patch ; true ) - $(C2C) c2c -b bootstrap/build-freebsd-amd64.yaml --no-build --bootstrap + $(C2C) c2c -b bootstrap/build-freebsd-amd64.yaml --no-build --bootstrap --terse ( diff bootstrap/bootstrap.c output/freebsd-amd64/c2c/cgen/build.c > bootstrap/bootstrap-freebsd-amd64.patch ; true ) - $(C2C) c2c -b bootstrap/build-openbsd-amd64.yaml --no-build --bootstrap + $(C2C) c2c -b bootstrap/build-openbsd-amd64.yaml --no-build --bootstrap --terse ( diff bootstrap/bootstrap.c output/openbsd-amd64/c2c/cgen/build.c > bootstrap/bootstrap-openbsd-amd64.patch ; true ) test: output/tester/tester @@ -75,16 +75,16 @@ testv: output/tester/tester @output/tester/tester -v test output/c2c_trace/c2c_trace: $(C2C_DEPS) - $(C2C) c2c --trace-calls -o c2c_trace --fast + $(C2C) c2c --trace-calls -o c2c_trace --fast --terse trace_calls: $(C2C) output/c2c_trace/c2c_trace - C2_TRACE="min=10;min2=1;mode=3;name=*;fd=2" output/c2c_trace/c2c_trace c2c -o c2c_calls --test 2> output/c2c/calls + C2_TRACE="min=10;min2=1;mode=3;name=*;fd=2" output/c2c_trace/c2c_trace c2c -o c2c_calls --terse --test 2> output/c2c/calls trace: trace_calls cat output/c2c/calls alloc_trace: $(C2C) output/c2c_trace/c2c_trace - C2_TRACE="min=10;min2=1;mode=3;name=stdlib.malloc,stdlib.calloc;fd=2" output/c2c_trace/c2c_trace c2c -o c2c_alloc --test 2> output/c2c/calls + C2_TRACE="min=10;min2=1;mode=3;name=stdlib.malloc,stdlib.calloc;fd=2" output/c2c_trace/c2c_trace --terse c2c -o c2c_alloc --test 2> output/c2c/calls cat output/c2c/calls errors: diff --git a/compiler/main.c2 b/compiler/main.c2 index 74ced2152..48810b7b7 100644 --- a/compiler/main.c2 +++ b/compiler/main.c2 @@ -49,6 +49,7 @@ type Options struct { bool print_timing; bool show_targets; bool show_plugins; + bool terse_mode; bool no_plugins; bool use_ir_backend; bool trace_calls; @@ -210,6 +211,7 @@ const char[] Usage_help = " --showplugins print available plugins\n" " --target [triple] cross compile for a specified architecture\n" " --targets show available targets in recipe\n" + " --terse prevent compiler logging messages\n" " --test test mode (do not check for main() function)\n" " --trace-calls generate code that traces function calls\n" " --version print version\n"; @@ -297,6 +299,9 @@ fn void parse_long_opt(ArgumentParser *ap, const char* arg, compiler.Options* co case "targets": opts.show_targets = true; break; + case "terse": + opts.terse_mode = true; + break; case "test": comp_opts.test_mode = true; break; @@ -524,7 +529,8 @@ fn void Context.handle_args(Context* c, i32 argc, char** argv) { c.plugins = plugin_mgr.create(c.auxPool, c.opts.print_timing, c.opts.log_verbose, c.opts.no_plugins); if (c.opts.build_file) { - console.log("using build-file %s", c.opts.build_file); + if (!c.opts.terse_mode) + console.log("using build-file %s", c.opts.build_file); c.build_info = build_file_parser.parse(c.sm, c.auxPool, c.opts.build_file); if (!c.build_info) exit(EXIT_FAILURE); @@ -602,11 +608,13 @@ fn bool Context.build_target(Context* c, if (c.opts.force_warnings) target.enableWarnings(); if (c.opts.output_name) { - console.log("building %s as %s", target_name, c.opts.output_name); + if (!c.opts.terse_mode) + console.log("building %s as %s", target_name, c.opts.output_name); target_name = c.opts.output_name; target.setNameIdx(c.auxPool.addStr(target_name, true)); } else { - console.log("building %s", target_name); + if (!c.opts.terse_mode) + console.log("building %s", target_name); } c.comp_opts.trace_calls = c.opts.trace_calls; diff --git a/examples/Makefile b/examples/Makefile index b0a3e5db0..c9a2d9ba0 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,6 @@ all: - c2c + @echo "---- building examples ----" + @../output/c2c/c2c --terse errors: @( grep -n 'error:' `find . -name build.log` | sed -E 's/build.log:[0-9]+://' ; true ) diff --git a/install_plugins.sh b/install_plugins.sh index afd814de7..83630959d 100755 --- a/install_plugins.sh +++ b/install_plugins.sh @@ -1,6 +1,6 @@ #!/bin/sh -echo "Installing C2C plugins in $C2_PLUGINDIR" +echo "---- installing c2c plugins in $C2_PLUGINDIR" if [ $(uname -s) = 'Darwin' ] ; then LIB_EXT='.dylib'