Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions compiler/main.c2
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
@@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion install_plugins.sh
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Loading