From dc7016344eeb3ba2d58f80968c3df9503e7c72e7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Sep 2019 23:57:47 -0400 Subject: [PATCH] remove --override-std-dir. fix issues caused by moving std lib --- CMakeLists.txt | 3 +-- build.zig | 9 ++------- lib/std/build.zig | 16 ++-------------- lib/std/special/build_runner.zig | 6 ------ src/codegen.cpp | 13 ++++--------- src/codegen.hpp | 2 +- src/main.cpp | 18 ++++-------------- test/tests.zig | 2 +- 8 files changed, 15 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7fecfa51c..2482a61601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -601,8 +601,7 @@ else() endif() add_custom_target(zig_build_libuserland ALL COMMAND zig0 build - --override-std-dir std - --override-lib-dir "${CMAKE_SOURCE_DIR}" + --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" libuserland install "-Doutput-dir=${CMAKE_BINARY_DIR}" "-Drelease=${LIBUSERLAND_RELEASE_MODE}" diff --git a/build.zig b/build.zig index b38fb87cb7..390f1594f8 100644 --- a/build.zig +++ b/build.zig @@ -87,11 +87,6 @@ pub fn build(b: *Builder) !void { .source_dir = "lib", .install_dir = .Lib, .install_subdir = "zig", - }); - b.installDirectory(InstallDirectoryOptions{ - .source_dir = "std", - .install_dir = .Lib, - .install_subdir = "zig" ++ fs.path.sep_str ++ "std", .exclude_extensions = [_][]const u8{ "test.zig", "README.md" }, }); @@ -134,9 +129,9 @@ pub fn build(b: *Builder) !void { test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, glibc_multi_dir)); - test_step.dependOn(tests.addPkgTests(b, test_filter, "std/std.zig", "std", "Run the standard library tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, glibc_multi_dir)); + test_step.dependOn(tests.addPkgTests(b, test_filter, "lib/std/std.zig", "std", "Run the standard library tests", modes, false, skip_non_native, skip_libc, is_wine_enabled, is_qemu_enabled, glibc_multi_dir)); - test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt.zig", "compiler-rt", "Run the compiler_rt tests", modes, true, skip_non_native, true, is_wine_enabled, is_qemu_enabled, glibc_multi_dir)); + test_step.dependOn(tests.addPkgTests(b, test_filter, "lib/std/special/compiler_rt.zig", "compiler-rt", "Run the compiler_rt tests", modes, true, skip_non_native, true, is_wine_enabled, is_qemu_enabled, glibc_multi_dir)); test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); test_step.dependOn(tests.addStandaloneTests(b, test_filter, modes)); diff --git a/lib/std/build.zig b/lib/std/build.zig index 7f9a77351d..3b5299f523 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -52,7 +52,6 @@ pub const Builder = struct { cache_root: []const u8, release_mode: ?builtin.Mode, is_release: bool, - override_std_dir: ?[]const u8, override_lib_dir: ?[]const u8, pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null, @@ -158,7 +157,6 @@ pub const Builder = struct { }, .release_mode = null, .is_release = false, - .override_std_dir = null, .override_lib_dir = null, .install_path = undefined, }; @@ -1439,7 +1437,6 @@ pub const LibExeObjStep = struct { bundle_compiler_rt: bool, disable_stack_probing: bool, c_std: Builder.CStd, - override_std_dir: ?[]const u8, override_lib_dir: ?[]const u8, main_pkg_path: ?[]const u8, exec_cmd_args: ?[]const ?[]const u8, @@ -1570,7 +1567,6 @@ pub const LibExeObjStep = struct { .build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable, .c_std = Builder.CStd.C99, .system_linker_hack = false, - .override_std_dir = null, .override_lib_dir = null, .main_pkg_path = null, .exec_cmd_args = null, @@ -1883,8 +1879,8 @@ pub const LibExeObjStep = struct { self.build_mode = mode; } - pub fn overrideStdDir(self: *LibExeObjStep, dir_path: []const u8) void { - self.override_std_dir = dir_path; + pub fn overrideZigLibDir(self: *LibExeObjStep, dir_path: []const u8) void { + self.override_lib_dir = self.builder.dupe(dir_path); } pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void { @@ -2300,14 +2296,6 @@ pub const LibExeObjStep = struct { } } - if (self.override_std_dir) |dir| { - try zig_args.append("--override-std-dir"); - try zig_args.append(builder.pathFromRoot(dir)); - } else if (self.builder.override_std_dir) |dir| { - try zig_args.append("--override-std-dir"); - try zig_args.append(builder.pathFromRoot(dir)); - } - if (self.override_lib_dir) |dir| { try zig_args.append("--override-lib-dir"); try zig_args.append(builder.pathFromRoot(dir)); diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 01e307d46e..efe3275fe6 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -90,11 +90,6 @@ pub fn main() !void { return usageAndErr(builder, false, try stderr_stream); }); builder.addSearchPrefix(search_prefix); - } else if (mem.eql(u8, arg, "--override-std-dir")) { - builder.override_std_dir = try unwrapArg(arg_it.next(allocator) orelse { - warn("Expected argument after --override-std-dir\n\n"); - return usageAndErr(builder, false, try stderr_stream); - }); } else if (mem.eql(u8, arg, "--override-lib-dir")) { builder.override_lib_dir = try unwrapArg(arg_it.next(allocator) orelse { warn("Expected argument after --override-lib-dir\n\n"); @@ -199,7 +194,6 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { \\Advanced Options: \\ --build-file [file] Override path to build.zig \\ --cache-dir [path] Override path to zig cache directory - \\ --override-std-dir [arg] Override path to Zig standard library \\ --override-lib-dir [arg] Override path to Zig lib directory \\ --verbose-tokenize Enable compiler debug output for tokenization \\ --verbose-ast Enable compiler debug output for parsing into an AST diff --git a/src/codegen.cpp b/src/codegen.cpp index f3bb210902..a1da6752b3 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -10367,8 +10367,7 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o ZigLibCInstallation *libc) { CodeGen *child_gen = codegen_create(nullptr, root_src_path, parent_gen->zig_target, out_type, - parent_gen->build_mode, parent_gen->zig_lib_dir, parent_gen->zig_std_dir, libc, get_stage1_cache_path(), - false); + parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_stage1_cache_path(), false); child_gen->disable_gen_h = true; child_gen->want_stack_check = WantStackCheckDisabled; child_gen->verbose_tokenize = parent_gen->verbose_tokenize; @@ -10396,7 +10395,7 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o } CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target, - OutType out_type, BuildMode build_mode, Buf *override_lib_dir, Buf *override_std_dir, + OutType out_type, BuildMode build_mode, Buf *override_lib_dir, ZigLibCInstallation *libc, Buf *cache_dir, bool is_test_build) { CodeGen *g = allocate(1); @@ -10414,12 +10413,8 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget g->zig_lib_dir = override_lib_dir; } - if (override_std_dir == nullptr) { - g->zig_std_dir = buf_alloc(); - os_path_join(g->zig_lib_dir, buf_create_from_str("std"), g->zig_std_dir); - } else { - g->zig_std_dir = override_std_dir; - } + g->zig_std_dir = buf_alloc(); + os_path_join(g->zig_lib_dir, buf_create_from_str("std"), g->zig_std_dir); g->zig_c_headers_dir = buf_alloc(); os_path_join(g->zig_lib_dir, buf_create_from_str("include"), g->zig_c_headers_dir); diff --git a/src/codegen.hpp b/src/codegen.hpp index 794a0fd5a6..5be15b0513 100644 --- a/src/codegen.hpp +++ b/src/codegen.hpp @@ -17,7 +17,7 @@ #include CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target, - OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, Buf *override_std_dir, + OutType out_type, BuildMode build_mode, Buf *zig_lib_dir, ZigLibCInstallation *libc, Buf *cache_dir, bool is_test_build); CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType out_type, diff --git a/src/main.cpp b/src/main.cpp index 68ff97e4db..6f1eff174b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,8 +88,7 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { " -dirafter [dir] same as -isystem but do it last\n" " -isystem [dir] add additional search path for other .h files\n" " -mllvm [arg] (unsupported) forward an arg to LLVM's option processing\n" - " --override-std-dir [arg] override path to Zig standard library\n" - " --override-lib-dir [arg] override path to Zig lib library\n" + " --override-lib-dir [arg] override path to Zig lib directory\n" " -ffunction-sections places each function in a separate section\n" " -D[macro]=[value] define C [macro] to [value] (1 if [value] omitted)\n" "\n" @@ -490,7 +489,6 @@ int main(int argc, char **argv) { bool want_single_threaded = false; bool disable_gen_h = false; bool bundle_compiler_rt = false; - Buf *override_std_dir = nullptr; Buf *override_lib_dir = nullptr; Buf *main_pkg_path = nullptr; ValgrindSupport valgrind_support = ValgrindSupportAuto; @@ -526,12 +524,6 @@ int main(int argc, char **argv) { } else if (i + 1 < argc && strcmp(argv[i], "--cache-dir") == 0) { cache_dir = argv[i + 1]; i += 1; - } else if (i + 1 < argc && strcmp(argv[i], "--override-std-dir") == 0) { - override_std_dir = buf_create_from_str(argv[i + 1]); - i += 1; - - args.append("--override-std-dir"); - args.append(buf_ptr(override_std_dir)); } else if (i + 1 < argc && strcmp(argv[i], "--override-lib-dir") == 0) { override_lib_dir = buf_create_from_str(argv[i + 1]); i += 1; @@ -590,7 +582,7 @@ int main(int argc, char **argv) { } CodeGen *g = codegen_create(main_pkg_path, build_runner_path, &target, OutTypeExe, - BuildModeDebug, override_lib_dir, override_std_dir, nullptr, &full_cache_dir, false); + BuildModeDebug, override_lib_dir, nullptr, &full_cache_dir, false); g->valgrind_support = valgrind_support; g->enable_time_report = timing_info; codegen_set_out_name(g, buf_create_from_str("build")); @@ -787,8 +779,6 @@ int main(int argc, char **argv) { clang_argv.append(argv[i]); llvm_argv.append(argv[i]); - } else if (strcmp(arg, "--override-std-dir") == 0) { - override_std_dir = buf_create_from_str(argv[i]); } else if (strcmp(arg, "--override-lib-dir") == 0) { override_lib_dir = buf_create_from_str(argv[i]); } else if (strcmp(arg, "--main-pkg-path") == 0) { @@ -1036,7 +1026,7 @@ int main(int argc, char **argv) { } case CmdBuiltin: { CodeGen *g = codegen_create(main_pkg_path, nullptr, &target, - out_type, build_mode, override_lib_dir, override_std_dir, nullptr, nullptr, false); + out_type, build_mode, override_lib_dir, nullptr, nullptr, false); codegen_set_strip(g, strip); for (size_t i = 0; i < link_libs.length; i += 1) { LinkLib *link_lib = codegen_add_link_lib(g, buf_create_from_str(link_libs.at(i))); @@ -1140,7 +1130,7 @@ int main(int argc, char **argv) { cache_dir_buf = buf_create_from_str(cache_dir); } CodeGen *g = codegen_create(main_pkg_path, zig_root_source_file, &target, out_type, build_mode, - override_lib_dir, override_std_dir, libc, cache_dir_buf, cmd == CmdTest); + override_lib_dir, libc, cache_dir_buf, cmd == CmdTest); if (llvm_argv.length >= 2) codegen_set_llvm_argv(g, llvm_argv.items + 1, llvm_argv.length - 2); g->valgrind_support = valgrind_support; g->want_pic = want_pic; diff --git a/test/tests.zig b/test/tests.zig index 20c8276e42..1b51a0c694 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -408,7 +408,7 @@ pub fn addPkgTests( if (test_target.link_libc) { these_tests.linkSystemLibrary("c"); } - these_tests.overrideStdDir("std"); + these_tests.overrideZigLibDir("lib"); these_tests.enable_wine = is_wine_enabled; these_tests.enable_qemu = is_qemu_enabled; these_tests.glibc_multi_install_dir = glibc_dir;