| author | |
| committer | |
| log | b8ee3a8143c91bcc7ba5d7166dd88c217db89b25 |
| tree | e9dde7cf42c1263c9da49798f89858f39ad60d12 |
| parent | faaaf8832772108b240a277f984c9dbdd046f98e |
useful for debugging crashes in llvm optimizer6 files changed, 34 insertions(+), 0 deletions(-)
src/all_types.hpp+3| ... | @@ -1524,6 +1524,9 @@ struct CodeGen { | ... | @@ -1524,6 +1524,9 @@ struct CodeGen { |
| 1524 | size_t clang_argv_len; | 1524 | size_t clang_argv_len; |
| 1525 | ZigList<const char *> lib_dirs; | 1525 | ZigList<const char *> lib_dirs; |
| 1526 | 1526 | ||
| 1527 | const char **llvm_argv; | ||
| 1528 | size_t llvm_argv_len; | ||
| 1529 | |||
| 1527 | ZigList<FnTableEntry *> test_fns; | 1530 | ZigList<FnTableEntry *> test_fns; |
| 1528 | TypeTableEntry *test_fn_type; | 1531 | TypeTableEntry *test_fn_type; |
| 1529 | 1532 |
src/codegen.cpp+16| ... | @@ -152,6 +152,11 @@ void codegen_set_clang_argv(CodeGen *g, const char **args, size_t len) { | ... | @@ -152,6 +152,11 @@ void codegen_set_clang_argv(CodeGen *g, const char **args, size_t len) { |
| 152 | g->clang_argv_len = len; | 152 | g->clang_argv_len = len; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | void codegen_set_llvm_argv(CodeGen *g, const char **args, size_t len) { | ||
| 156 | g->llvm_argv = args; | ||
| 157 | g->llvm_argv_len = len; | ||
| 158 | } | ||
| 159 | |||
| 155 | void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt) { | 160 | void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt) { |
| 156 | g->omit_zigrt = omit_zigrt; | 161 | g->omit_zigrt = omit_zigrt; |
| 157 | } | 162 | } |
| ... | @@ -4918,6 +4923,17 @@ static void init(CodeGen *g) { | ... | @@ -4918,6 +4923,17 @@ static void init(CodeGen *g) { |
| 4918 | if (g->module) | 4923 | if (g->module) |
| 4919 | return; | 4924 | return; |
| 4920 | 4925 | ||
| 4926 | |||
| 4927 | if (g->llvm_argv_len > 0) { | ||
| 4928 | const char **args = allocate_nonzero<const char *>(g->llvm_argv_len + 2); | ||
| 4929 | args[0] = "zig (LLVM option parsing)"; | ||
| 4930 | for (size_t i = 0; i < g->llvm_argv_len; i += 1) { | ||
| 4931 | args[i + 1] = g->llvm_argv[i]; | ||
| 4932 | } | ||
| 4933 | args[g->llvm_argv_len + 1] = nullptr; | ||
| 4934 | ZigLLVMParseCommandLineOptions(g->llvm_argv_len + 1, args); | ||
| 4935 | } | ||
| 4936 | |||
| 4921 | if (g->is_test_build) { | 4937 | if (g->is_test_build) { |
| 4922 | g->windows_subsystem_windows = false; | 4938 | g->windows_subsystem_windows = false; |
| 4923 | g->windows_subsystem_console = true; | 4939 | g->windows_subsystem_console = true; |
src/codegen.hpp+1| ... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
| 17 | CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode); | 17 | CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode); |
| 18 | 18 | ||
| 19 | void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len); | 19 | void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len); |
| 20 | void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len); | ||
| 20 | void codegen_set_is_test(CodeGen *codegen, bool is_test); | 21 | void codegen_set_is_test(CodeGen *codegen, bool is_test); |
| 21 | void codegen_set_each_lib_rpath(CodeGen *codegen, bool each_lib_rpath); | 22 | void codegen_set_each_lib_rpath(CodeGen *codegen, bool each_lib_rpath); |
| 22 | 23 |
src/main.cpp+8| ... | @@ -50,6 +50,7 @@ static int usage(const char *arg0) { | ... | @@ -50,6 +50,7 @@ static int usage(const char *arg0) { |
| 50 | " --zig-std-dir [path] directory where zig standard library resides\n" | 50 | " --zig-std-dir [path] directory where zig standard library resides\n" |
| 51 | " -dirafter [dir] same as -isystem but do it last\n" | 51 | " -dirafter [dir] same as -isystem but do it last\n" |
| 52 | " -isystem [dir] add additional search path for other .h files\n" | 52 | " -isystem [dir] add additional search path for other .h files\n" |
| 53 | " -mllvm [arg] additional arguments to forward to LLVM's option processing\n" | ||
| 53 | "Link Options:\n" | 54 | "Link Options:\n" |
| 54 | " --ar-path [path] set the path to ar\n" | 55 | " --ar-path [path] set the path to ar\n" |
| 55 | " --dynamic-linker [path] set the path to ld.so\n" | 56 | " --dynamic-linker [path] set the path to ld.so\n" |
| ... | @@ -190,6 +191,7 @@ int main(int argc, char **argv) { | ... | @@ -190,6 +191,7 @@ int main(int argc, char **argv) { |
| 190 | const char *zig_std_dir = nullptr; | 191 | const char *zig_std_dir = nullptr; |
| 191 | const char *dynamic_linker = nullptr; | 192 | const char *dynamic_linker = nullptr; |
| 192 | ZigList<const char *> clang_argv = {0}; | 193 | ZigList<const char *> clang_argv = {0}; |
| 194 | ZigList<const char *> llvm_argv = {0}; | ||
| 193 | ZigList<const char *> lib_dirs = {0}; | 195 | ZigList<const char *> lib_dirs = {0}; |
| 194 | ZigList<const char *> link_libs = {0}; | 196 | ZigList<const char *> link_libs = {0}; |
| 195 | ZigList<const char *> frameworks = {0}; | 197 | ZigList<const char *> frameworks = {0}; |
| ... | @@ -420,6 +422,11 @@ int main(int argc, char **argv) { | ... | @@ -420,6 +422,11 @@ int main(int argc, char **argv) { |
| 420 | } else if (strcmp(arg, "-dirafter") == 0) { | 422 | } else if (strcmp(arg, "-dirafter") == 0) { |
| 421 | clang_argv.append("-dirafter"); | 423 | clang_argv.append("-dirafter"); |
| 422 | clang_argv.append(argv[i]); | 424 | clang_argv.append(argv[i]); |
| 425 | } else if (strcmp(arg, "-mllvm") == 0) { | ||
| 426 | clang_argv.append("-mllvm"); | ||
| 427 | clang_argv.append(argv[i]); | ||
| 428 | |||
| 429 | llvm_argv.append(argv[i]); | ||
| 423 | } else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) { | 430 | } else if (strcmp(arg, "--library-path") == 0 || strcmp(arg, "-L") == 0) { |
| 424 | lib_dirs.append(argv[i]); | 431 | lib_dirs.append(argv[i]); |
| 425 | } else if (strcmp(arg, "--library") == 0) { | 432 | } else if (strcmp(arg, "--library") == 0) { |
| ... | @@ -604,6 +611,7 @@ int main(int argc, char **argv) { | ... | @@ -604,6 +611,7 @@ int main(int argc, char **argv) { |
| 604 | codegen_set_each_lib_rpath(g, each_lib_rpath); | 611 | codegen_set_each_lib_rpath(g, each_lib_rpath); |
| 605 | 612 | ||
| 606 | codegen_set_clang_argv(g, clang_argv.items, clang_argv.length); | 613 | codegen_set_clang_argv(g, clang_argv.items, clang_argv.length); |
| 614 | codegen_set_llvm_argv(g, llvm_argv.items, llvm_argv.length); | ||
| 607 | codegen_set_strip(g, strip); | 615 | codegen_set_strip(g, strip); |
| 608 | codegen_set_is_static(g, is_static); | 616 | codegen_set_is_static(g, is_static); |
| 609 | if (libc_lib_dir) | 617 | if (libc_lib_dir) |
src/zig_llvm.cpp+4| ... | @@ -602,6 +602,10 @@ void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn_ref) { | ... | @@ -602,6 +602,10 @@ void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn_ref) { |
| 602 | func->setAttributes(new_attr_set); | 602 | func->setAttributes(new_attr_set); |
| 603 | } | 603 | } |
| 604 | 604 | ||
| 605 | void ZigLLVMParseCommandLineOptions(int argc, const char *const *argv) { | ||
| 606 | llvm::cl::ParseCommandLineOptions(argc, argv); | ||
| 607 | } | ||
| 608 | |||
| 605 | 609 | ||
| 606 | static_assert((Triple::ArchType)ZigLLVM_LastArchType == Triple::LastArchType, ""); | 610 | static_assert((Triple::ArchType)ZigLLVM_LastArchType == Triple::LastArchType, ""); |
| 607 | static_assert((Triple::VendorType)ZigLLVM_LastVendorType == Triple::LastVendorType, ""); | 611 | static_assert((Triple::VendorType)ZigLLVM_LastVendorType == Triple::LastVendorType, ""); |
src/zig_llvm.hpp+2| ... | @@ -164,6 +164,8 @@ void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); | ... | @@ -164,6 +164,8 @@ void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state); |
| 164 | void ZigLLVMAddFunctionAttr(LLVMValueRef fn, const char *attr_name, const char *attr_value); | 164 | void ZigLLVMAddFunctionAttr(LLVMValueRef fn, const char *attr_name, const char *attr_value); |
| 165 | void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn); | 165 | void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn); |
| 166 | 166 | ||
| 167 | void ZigLLVMParseCommandLineOptions(int argc, const char *const *argv); | ||
| 168 | |||
| 167 | 169 | ||
| 168 | // copied from include/llvm/ADT/Triple.h | 170 | // copied from include/llvm/ADT/Triple.h |
| 169 | 171 |