aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorErsikan <julien.philippon@epitech.eu>2021-03-13 12:00:06 +0100
committerIsaac Freund <ifreund@ifreund.xyz>2021-03-14 17:48:02 +0100
commitf69305f865c346ffb2a00403efd0768f8bbdd20b (patch)
tree8c212eefddd4d9f4b2353059855418021c25ab75 /src/main.zig
parent4e9894cfc4c8e2e1d3e01aa2e3400b295b0ee2df (diff)
downloadzig-f69305f865c346ffb2a00403efd0768f8bbdd20b.tar.gz
zig-f69305f865c346ffb2a00403efd0768f8bbdd20b.zip
stage2: Warn when using --debug-log without logging enabled
A warning is emitted when using the debug option --debug-log when the compiler was not compiled using the build option -Dlog. Additionnaly, the scopes are not added to log_scopes as they have no effect.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 011b9edf76..bc4f209b45 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -841,7 +841,11 @@ fn buildOutputType(
} else if (mem.eql(u8, arg, "--debug-log")) {
if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
i += 1;
- try log_scopes.append(gpa, args[i]);
+ if (!build_options.enable_logging) {
+ std.log.warn("Zig was compiled without logging enabled (-Dlog). --debug-log has no effect.", .{});
+ } else {
+ try log_scopes.append(gpa, args[i]);
+ }
} else if (mem.eql(u8, arg, "-fcompiler-rt")) {
want_compiler_rt = true;
} else if (mem.eql(u8, arg, "-fno-compiler-rt")) {