diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/main.cpp b/src/main.cpp index 63b077e833..9c36f9b091 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,6 +43,7 @@ static int usage(const char *arg0) { " --pkg-end pop current pkg\n" " --release-fast build with optimizations on and safety off\n" " --release-safe build with optimizations on and safety on\n" + " --release-small build with size optimizations on and safety off\n" " --static output will be statically linked\n" " --strip exclude debug symbols\n" " --target-arch [name] specify target architecture\n" @@ -54,7 +55,6 @@ static int usage(const char *arg0) { " --verbose-ir turn on compiler debug output for Zig IR\n" " --verbose-llvm-ir turn on compiler debug output for LLVM IR\n" " --verbose-cimport turn on compiler debug output for C imports\n" - " --zig-install-prefix [path] override directory where zig thinks it is installed\n" " -dirafter [dir] same as -isystem but do it last\n" " -isystem [dir] add additional search path for other .h files\n" " -mllvm [arg] additional arguments to forward to LLVM's option processing\n" @@ -74,6 +74,7 @@ static int usage(const char *arg0) { " -L[dir] alias for --library-path\n" " -rdynamic add all symbols to the dynamic symbol table\n" " -rpath [path] add directory to the runtime library search path\n" + " --no-rosegment compromise security to workaround valgrind bug\n" " -mconsole (windows) --subsystem console to the linker\n" " -mwindows (windows) --subsystem windows to the linker\n" " -framework [name] (darwin) link against framework\n" @@ -177,6 +178,7 @@ static int find_zig_lib_dir(Buf *out_path) { int err; Buf self_exe_path = BUF_INIT; + buf_resize(&self_exe_path, 0); if (!(err = os_self_exe_path(&self_exe_path))) { Buf *cur_path = &self_exe_path; @@ -199,23 +201,14 @@ static int find_zig_lib_dir(Buf *out_path) { return ErrorFileNotFound; } -static Buf *resolve_zig_lib_dir(const char *zig_install_prefix_arg) { +static Buf *resolve_zig_lib_dir(void) { int err; Buf *result = buf_alloc(); - if (zig_install_prefix_arg == nullptr) { - if ((err = find_zig_lib_dir(result))) { - fprintf(stderr, "Unable to find zig lib directory. Reinstall Zig or use --zig-install-prefix.\n"); - exit(EXIT_FAILURE); - } - return result; - } - Buf *zig_lib_dir_buf = buf_create_from_str(zig_install_prefix_arg); - if (test_zig_install_prefix(zig_lib_dir_buf, result)) { - return result; + if ((err = find_zig_lib_dir(result))) { + fprintf(stderr, "Unable to find zig lib directory\n"); + exit(EXIT_FAILURE); } - - fprintf(stderr, "No Zig installation found at prefix: %s\n", zig_install_prefix_arg); - exit(EXIT_FAILURE); + return result; } enum Cmd { @@ -299,7 +292,6 @@ int main(int argc, char **argv) { const char *libc_include_dir = nullptr; const char *msvc_lib_dir = nullptr; const char *kernel32_lib_dir = nullptr; - const char *zig_install_prefix = nullptr; const char *dynamic_linker = nullptr; ZigList<const char *> clang_argv = {0}; ZigList<const char *> llvm_argv = {0}; @@ -333,6 +325,7 @@ int main(int argc, char **argv) { ZigList<const char *> test_exec_args = {0}; int comptime_args_end = 0; int runtime_args_start = argc; + bool no_rosegment_workaround = false; if (argc >= 2 && strcmp(argv[1], "build") == 0) { const char *zig_exe_path = arg0; @@ -359,17 +352,12 @@ 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], "--zig-install-prefix") == 0) { - args.append(argv[i]); - i += 1; - zig_install_prefix = argv[i]; - args.append(zig_install_prefix); } else { args.append(argv[i]); } } - Buf *zig_lib_dir_buf = resolve_zig_lib_dir(zig_install_prefix); + Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); Buf *zig_std_dir = buf_alloc(); os_path_join(zig_lib_dir_buf, buf_create_from_str("std"), zig_std_dir); @@ -497,6 +485,8 @@ int main(int argc, char **argv) { build_mode = BuildModeFastRelease; } else if (strcmp(arg, "--release-safe") == 0) { build_mode = BuildModeSafeRelease; + } else if (strcmp(arg, "--release-small") == 0) { + build_mode = BuildModeSmallRelease; } else if (strcmp(arg, "--strip") == 0) { strip = true; } else if (strcmp(arg, "--static") == 0) { @@ -519,6 +509,8 @@ int main(int argc, char **argv) { mconsole = true; } else if (strcmp(arg, "-rdynamic") == 0) { rdynamic = true; + } else if (strcmp(arg, "--no-rosegment") == 0) { + no_rosegment_workaround = true; } else if (strcmp(arg, "--each-lib-rpath") == 0) { each_lib_rpath = true; } else if (strcmp(arg, "--enable-timing-info") == 0) { @@ -590,8 +582,6 @@ int main(int argc, char **argv) { msvc_lib_dir = argv[i]; } else if (strcmp(arg, "--kernel32-lib-dir") == 0) { kernel32_lib_dir = argv[i]; - } else if (strcmp(arg, "--zig-install-prefix") == 0) { - zig_install_prefix = argv[i]; } else if (strcmp(arg, "--dynamic-linker") == 0) { dynamic_linker = argv[i]; } else if (strcmp(arg, "-isystem") == 0) { @@ -803,7 +793,7 @@ int main(int argc, char **argv) { full_cache_dir); } - Buf *zig_lib_dir_buf = resolve_zig_lib_dir(zig_install_prefix); + Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); codegen_set_out_name(g, buf_out_name); @@ -858,6 +848,7 @@ int main(int argc, char **argv) { codegen_set_windows_subsystem(g, mwindows, mconsole); codegen_set_rdynamic(g, rdynamic); + g->no_rosegment_workaround = no_rosegment_workaround; if (mmacosx_version_min && mios_version_min) { fprintf(stderr, "-mmacosx-version-min and -mios-version-min options not allowed together\n"); return EXIT_FAILURE; |
