From 5a65caa2a3686e12e4dfcfd599ed02f8a09c6017 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 4 Dec 2020 21:33:29 -0700 Subject: ability to build stage1 using only a zig tarball The main idea here is that there are now 2 ways to get a stage1 zig binary: * The cmake path. Requirements: cmake, system C++ compiler, system LLVM, LLD, Clang libraries, compiled by the system C++ compiler. * The zig path. Requirements: a zig installation, system LLVM, LLD, Clang libraries, compiled by the zig installation. Note that the former can be used to now take the latter path. Removed config.h.in and config.zig.in. The build.zig script no longer is coupled to the cmake script. cmake no longer tries to determine the zig version. A build with cmake will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to get reverted. `zig build` now accepts `-Dstage1` which will build the stage1 compiler, and put the stage2 backend behind a feature flag. build.zig is simplified to only support the use case of enabling LLVM support when the LLVM, LLD, and Clang libraries were built by zig. This part is probably sadly going to have to get reverted to make package maintainers happy. Zig build system addBuildOption supports a couple new types. The biggest reason to make this change is that the zig path is an attractive option for doing compiler development work on Windows. It allows people to work on the compiler without having MSVC installed, using only a .zip file that contains Zig + LLVM/LLD/Clang libraries. --- src/stage1/codegen.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/stage1/codegen.cpp') diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index eb0495c07d..c57325f954 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -8,7 +8,6 @@ #include "analyze.hpp" #include "ast_render.hpp" #include "codegen.hpp" -#include "config.h" #include "errmsg.hpp" #include "error.hpp" #include "hash_map.hpp" @@ -9051,7 +9050,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { buf_append_str(contents, "/// Deprecated: use `std.Target.current.cpu.arch.endian()`\n"); buf_append_str(contents, "pub const endian = Target.current.cpu.arch.endian();\n"); buf_appendf(contents, "pub const output_mode = OutputMode.Obj;\n"); - buf_appendf(contents, "pub const link_mode = LinkMode.%s;\n", ZIG_LINK_MODE); + buf_appendf(contents, "pub const link_mode = LinkMode.%s;\n", ZIG_QUOTE(ZIG_LINK_MODE)); buf_appendf(contents, "pub const is_test = false;\n"); buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded)); buf_appendf(contents, "pub const abi = Abi.%s;\n", cur_abi); @@ -9251,9 +9250,9 @@ static void init(CodeGen *g) { g->builder = LLVMCreateBuilder(); g->dbuilder = ZigLLVMCreateDIBuilder(g->module, true); - // Don't use ZIG_VERSION_STRING here, llvm misparses it when it includes - // the git revision. - Buf *producer = buf_sprintf("zig %d.%d.%d", ZIG_VERSION_MAJOR, ZIG_VERSION_MINOR, ZIG_VERSION_PATCH); + // Don't use the version string here, llvm misparses it when it includes the git revision. + Stage2SemVer semver = stage2_version(); + Buf *producer = buf_sprintf("zig %d.%d.%d", semver.major, semver.minor, semver.patch); const char *flags = ""; unsigned runtime_version = 0; @@ -9551,9 +9550,9 @@ void codegen_build_object(CodeGen *g) { } do_code_gen(g); - codegen_add_time_event(g, "LLVM Emit Output"); + codegen_add_time_event(g, "LLVM Emit Object"); { - const char *progress_name = "LLVM Emit Output"; + const char *progress_name = "LLVM Emit Object"; codegen_switch_sub_prog_node(g, stage2_progress_start(g->main_progress_node, progress_name, strlen(progress_name), 0)); } -- cgit v1.2.3