diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-09-26 21:03:38 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-09-26 21:03:38 -0700 |
| commit | b6556c944b88726c2bdb34ce72358ade88c5a984 (patch) | |
| tree | 426cf861f39fb6e250e581588c33496366a1e68c /src/main.zig | |
| parent | fe4c348f578903d53c490673b1b1dcf5513ae049 (diff) | |
| download | zig-b6556c944b88726c2bdb34ce72358ade88c5a984.tar.gz zig-b6556c944b88726c2bdb34ce72358ade88c5a984.zip | |
fix another round of regressions in this branch
* std.log: still print error messages in ReleaseSmall builds.
- when start code gets an error code from main, it uses std.log.err
to report the error. this resulted in a test failure because
ReleaseSmall wasn't printing `error: TheErrorCode` when an error
was returned from main. But that seems like it should keep working.
So I changed the std.log defaults. I plan to follow this up with a
proposal to change the names of and reduce the quantity of the
log levels.
* warning emitted when using -femit-h when using stage1 backend; fatal
log message when using -femit-h with self-hosted backend (because the
feature is not yet available)
* fix double `test-cli` build steps in zig's build.zig
* update docgen to use new CLI
* translate-c uses `-x c` and generates a temporary basename with a
`.h` extension. Otherwise clang reports an error.
* --show-builtin implies -fno-emit-bin
* restore the compile error for using an extern "c" function without
putting -lc on the build line. we have to know about the libc
dependency up front.
* Fix ReleaseFast and ReleaseSmall getting swapped when passing the
value to the stage1 backend.
* correct the zig0 CLI usage text.
* update test harness code to the new CLI.
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/src/main.zig b/src/main.zig index 572ab4b7b0..31eaf5d8ae 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,16 +7,18 @@ const process = std.process; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const ast = std.zig.ast; +const warn = std.log.warn; + const Compilation = @import("Compilation.zig"); const link = @import("link.zig"); const Package = @import("Package.zig"); const zir = @import("zir.zig"); const build_options = @import("build_options"); -const warn = std.log.warn; const introspect = @import("introspect.zig"); const LibCInstallation = @import("libc_installation.zig").LibCInstallation; const translate_c = @import("translate_c.zig"); const Cache = @import("Cache.zig"); +const target_util = @import("target.zig"); pub fn fatal(comptime format: []const u8, args: anytype) noreturn { std.log.emerg(format, args); @@ -773,6 +775,7 @@ fn buildOutputType( dll_export_fns = false; } else if (mem.eql(u8, arg, "--show-builtin")) { show_builtin = true; + emit_bin = .no; } else if (mem.eql(u8, arg, "--strip")) { strip = true; } else if (mem.eql(u8, arg, "--single-threaded")) { @@ -1219,12 +1222,12 @@ fn buildOutputType( var i: usize = 0; while (i < system_libs.items.len) { const lib_name = system_libs.items[i]; - if (is_libc_lib_name(target_info.target, lib_name)) { + if (target_util.is_libc_lib_name(target_info.target, lib_name)) { link_libc = true; _ = system_libs.orderedRemove(i); continue; } - if (is_libcpp_lib_name(target_info.target, lib_name)) { + if (target_util.is_libcpp_lib_name(target_info.target, lib_name)) { link_libcpp = true; _ = system_libs.orderedRemove(i); continue; @@ -2809,62 +2812,6 @@ pub const ClangArgIterator = struct { } }; -fn eqlIgnoreCase(ignore_case: bool, a: []const u8, b: []const u8) bool { - if (ignore_case) { - return std.ascii.eqlIgnoreCase(a, b); - } else { - return mem.eql(u8, a, b); - } -} - -fn is_libc_lib_name(target: std.Target, name: []const u8) bool { - const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; - - if (eqlIgnoreCase(ignore_case, name, "c")) - return true; - - if (target.isMinGW()) { - if (eqlIgnoreCase(ignore_case, name, "m")) - return true; - - return false; - } - - if (target.abi.isGnu() or target.abi.isMusl() or target.os.tag.isDarwin()) { - if (eqlIgnoreCase(ignore_case, name, "m")) - return true; - if (eqlIgnoreCase(ignore_case, name, "rt")) - return true; - if (eqlIgnoreCase(ignore_case, name, "pthread")) - return true; - if (eqlIgnoreCase(ignore_case, name, "crypt")) - return true; - if (eqlIgnoreCase(ignore_case, name, "util")) - return true; - if (eqlIgnoreCase(ignore_case, name, "xnet")) - return true; - if (eqlIgnoreCase(ignore_case, name, "resolv")) - return true; - if (eqlIgnoreCase(ignore_case, name, "dl")) - return true; - if (eqlIgnoreCase(ignore_case, name, "util")) - return true; - } - - if (target.os.tag.isDarwin() and eqlIgnoreCase(ignore_case, name, "System")) - return true; - - return false; -} - -fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { - const ignore_case = target.os.tag.isDarwin() or target.os.tag == .windows; - - return eqlIgnoreCase(ignore_case, name, "c++") or - eqlIgnoreCase(ignore_case, name, "stdc++") or - eqlIgnoreCase(ignore_case, name, "c++abi"); -} - fn parseCodeModel(arg: []const u8) std.builtin.CodeModel { return std.meta.stringToEnum(std.builtin.CodeModel, arg) orelse fatal("unsupported machine code model: '{}'", .{arg}); |
