| author | |
| committer | |
| log | a1817f462a06cca5cb25609b892dbff73db8a938 |
| tree | 46f281e9b2e22e7ee53a9bc3799f575ad77efa36 |
| parent | 1eafc85f1f0643ca2594247615a14b7a34343a14 |
5 files changed, 18 insertions(+), 3 deletions(-)
src/all_types.hpp+1| ... | @@ -1220,6 +1220,7 @@ struct CodeGen { | ... | @@ -1220,6 +1220,7 @@ struct CodeGen { |
| 1220 | Buf *libc_lib_dir; | 1220 | Buf *libc_lib_dir; |
| 1221 | Buf *libc_static_lib_dir; | 1221 | Buf *libc_static_lib_dir; |
| 1222 | Buf *libc_include_dir; | 1222 | Buf *libc_include_dir; |
| 1223 | Buf *zig_std_dir; | ||
| 1223 | Buf *dynamic_linker; | 1224 | Buf *dynamic_linker; |
| 1224 | Buf *linker_path; | 1225 | Buf *linker_path; |
| 1225 | Buf *ar_path; | 1226 | Buf *ar_path; |
src/codegen.cpp+9-2| ... | @@ -84,6 +84,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { | ... | @@ -84,6 +84,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { |
| 84 | g->libc_lib_dir = buf_create_from_str(""); | 84 | g->libc_lib_dir = buf_create_from_str(""); |
| 85 | g->libc_static_lib_dir = buf_create_from_str(""); | 85 | g->libc_static_lib_dir = buf_create_from_str(""); |
| 86 | g->libc_include_dir = buf_create_from_str(""); | 86 | g->libc_include_dir = buf_create_from_str(""); |
| 87 | g->zig_std_dir = buf_create_from_str(""); | ||
| 87 | g->linker_path = buf_create_from_str(""); | 88 | g->linker_path = buf_create_from_str(""); |
| 88 | g->ar_path = buf_create_from_str(""); | 89 | g->ar_path = buf_create_from_str(""); |
| 89 | g->darwin_linker_version = buf_create_from_str(""); | 90 | g->darwin_linker_version = buf_create_from_str(""); |
| ... | @@ -96,6 +97,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { | ... | @@ -96,6 +97,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) { |
| 96 | g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR); | 97 | g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR); |
| 97 | g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR); | 98 | g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR); |
| 98 | g->libc_include_dir = buf_create_from_str(ZIG_LIBC_INCLUDE_DIR); | 99 | g->libc_include_dir = buf_create_from_str(ZIG_LIBC_INCLUDE_DIR); |
| 100 | g->zig_std_dir = buf_create_from_str(ZIG_STD_DIR); | ||
| 99 | g->linker_path = buf_create_from_str(ZIG_LD_PATH); | 101 | g->linker_path = buf_create_from_str(ZIG_LD_PATH); |
| 100 | g->ar_path = buf_create_from_str(ZIG_AR_PATH); | 102 | g->ar_path = buf_create_from_str(ZIG_AR_PATH); |
| 101 | g->darwin_linker_version = buf_create_from_str(ZIG_HOST_LINK_VERSION); | 103 | g->darwin_linker_version = buf_create_from_str(ZIG_HOST_LINK_VERSION); |
| ... | @@ -165,6 +167,11 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) { | ... | @@ -165,6 +167,11 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) { |
| 165 | g->libc_include_dir = libc_include_dir; | 167 | g->libc_include_dir = libc_include_dir; |
| 166 | } | 168 | } |
| 167 | 169 | ||
| 170 | void codegen_set_zig_std_dir(CodeGen *g, Buf *zig_std_dir) { | ||
| 171 | g->zig_std_dir = zig_std_dir; | ||
| 172 | g->std_package->root_src_dir = *zig_std_dir; | ||
| 173 | } | ||
| 174 | |||
| 168 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker) { | 175 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker) { |
| 169 | g->dynamic_linker = dynamic_linker; | 176 | g->dynamic_linker = dynamic_linker; |
| 170 | } | 177 | } |
| ... | @@ -4752,7 +4759,7 @@ void codegen_render_ast(CodeGen *g, FILE *f, int indent_size) { | ... | @@ -4752,7 +4759,7 @@ void codegen_render_ast(CodeGen *g, FILE *f, int indent_size) { |
| 4752 | 4759 | ||
| 4753 | 4760 | ||
| 4754 | static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package, const char *basename) { | 4761 | static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package, const char *basename) { |
| 4755 | Buf *std_dir = buf_create_from_str(ZIG_STD_DIR); | 4762 | Buf *std_dir = g->zig_std_dir; |
| 4756 | Buf *code_basename = buf_create_from_str(basename); | 4763 | Buf *code_basename = buf_create_from_str(basename); |
| 4757 | Buf path_to_code_src = BUF_INIT; | 4764 | Buf path_to_code_src = BUF_INIT; |
| 4758 | os_path_join(std_dir, code_basename, &path_to_code_src); | 4765 | os_path_join(std_dir, code_basename, &path_to_code_src); |
| ... | @@ -4770,7 +4777,7 @@ static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package | ... | @@ -4770,7 +4777,7 @@ static ImportTableEntry *add_special_code(CodeGen *g, PackageTableEntry *package |
| 4770 | } | 4777 | } |
| 4771 | 4778 | ||
| 4772 | static PackageTableEntry *create_bootstrap_pkg(CodeGen *g) { | 4779 | static PackageTableEntry *create_bootstrap_pkg(CodeGen *g) { |
| 4773 | PackageTableEntry *package = new_package(ZIG_STD_DIR, ""); | 4780 | PackageTableEntry *package = new_package(buf_ptr(g->zig_std_dir), ""); |
| 4774 | package->package_table.put(buf_create_from_str("std"), g->std_package); | 4781 | package->package_table.put(buf_create_from_str("std"), g->std_package); |
| 4775 | package->package_table.put(buf_create_from_str("@root"), g->root_package); | 4782 | package->package_table.put(buf_create_from_str("@root"), g->root_package); |
| 4776 | return package; | 4783 | return package; |
src/codegen.hpp+1| ... | @@ -30,6 +30,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name); | ... | @@ -30,6 +30,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name); |
| 30 | void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir); | 30 | void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir); |
| 31 | void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir); | 31 | void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir); |
| 32 | void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); | 32 | void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); |
| 33 | void codegen_set_zig_std_dir(CodeGen *codegen, Buf *zig_std_dir); | ||
| 33 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker); | 34 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker); |
| 34 | void codegen_set_linker_path(CodeGen *g, Buf *linker_path); | 35 | void codegen_set_linker_path(CodeGen *g, Buf *linker_path); |
| 35 | void codegen_set_ar_path(CodeGen *g, Buf *ar_path); | 36 | void codegen_set_ar_path(CodeGen *g, Buf *ar_path); |
src/link.cpp+1-1| ... | @@ -33,7 +33,7 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) { | ... | @@ -33,7 +33,7 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) { |
| 33 | 33 | ||
| 34 | static Buf *build_o(CodeGen *parent_gen, const char *oname) { | 34 | static Buf *build_o(CodeGen *parent_gen, const char *oname) { |
| 35 | Buf *source_basename = buf_sprintf("%s.zig", oname); | 35 | Buf *source_basename = buf_sprintf("%s.zig", oname); |
| 36 | Buf *std_dir_path = buf_create_from_str(ZIG_STD_DIR); | 36 | Buf *std_dir_path = parent_gen->zig_std_dir; |
| 37 | 37 | ||
| 38 | ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target; | 38 | ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target; |
| 39 | CodeGen *child_gen = codegen_create(std_dir_path, child_target); | 39 | CodeGen *child_gen = codegen_create(std_dir_path, child_target); |
src/main.cpp+6| ... | @@ -35,6 +35,7 @@ static int usage(const char *arg0) { | ... | @@ -35,6 +35,7 @@ static int usage(const char *arg0) { |
| 35 | " --libc-lib-dir [path] directory where libc crt1.o resides\n" | 35 | " --libc-lib-dir [path] directory where libc crt1.o resides\n" |
| 36 | " --libc-static-lib-dir [path] directory where libc crtbegin.o resides\n" | 36 | " --libc-static-lib-dir [path] directory where libc crtbegin.o resides\n" |
| 37 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" | 37 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" |
| 38 | " --zig-std-dir [path] directory where zig standard library resides\n" | ||
| 38 | " --dynamic-linker [path] set the path to ld.so\n" | 39 | " --dynamic-linker [path] set the path to ld.so\n" |
| 39 | " --ld-path [path] set the path to the linker\n" | 40 | " --ld-path [path] set the path to the linker\n" |
| 40 | " --ar-path [path] set the path to ar\n" | 41 | " --ar-path [path] set the path to ar\n" |
| ... | @@ -117,6 +118,7 @@ int main(int argc, char **argv) { | ... | @@ -117,6 +118,7 @@ int main(int argc, char **argv) { |
| 117 | const char *libc_lib_dir = nullptr; | 118 | const char *libc_lib_dir = nullptr; |
| 118 | const char *libc_static_lib_dir = nullptr; | 119 | const char *libc_static_lib_dir = nullptr; |
| 119 | const char *libc_include_dir = nullptr; | 120 | const char *libc_include_dir = nullptr; |
| 121 | const char *zig_std_dir = nullptr; | ||
| 120 | const char *dynamic_linker = nullptr; | 122 | const char *dynamic_linker = nullptr; |
| 121 | const char *linker_path = nullptr; | 123 | const char *linker_path = nullptr; |
| 122 | const char *ar_path = nullptr; | 124 | const char *ar_path = nullptr; |
| ... | @@ -194,6 +196,8 @@ int main(int argc, char **argv) { | ... | @@ -194,6 +196,8 @@ int main(int argc, char **argv) { |
| 194 | libc_static_lib_dir = argv[i]; | 196 | libc_static_lib_dir = argv[i]; |
| 195 | } else if (strcmp(arg, "--libc-include-dir") == 0) { | 197 | } else if (strcmp(arg, "--libc-include-dir") == 0) { |
| 196 | libc_include_dir = argv[i]; | 198 | libc_include_dir = argv[i]; |
| 199 | } else if (strcmp(arg, "--zig-std-dir") == 0) { | ||
| 200 | zig_std_dir = argv[i]; | ||
| 197 | } else if (strcmp(arg, "--dynamic-linker") == 0) { | 201 | } else if (strcmp(arg, "--dynamic-linker") == 0) { |
| 198 | dynamic_linker = argv[i]; | 202 | dynamic_linker = argv[i]; |
| 199 | } else if (strcmp(arg, "--ld-path") == 0) { | 203 | } else if (strcmp(arg, "--ld-path") == 0) { |
| ... | @@ -356,6 +360,8 @@ int main(int argc, char **argv) { | ... | @@ -356,6 +360,8 @@ int main(int argc, char **argv) { |
| 356 | codegen_set_libc_static_lib_dir(g, buf_create_from_str(libc_static_lib_dir)); | 360 | codegen_set_libc_static_lib_dir(g, buf_create_from_str(libc_static_lib_dir)); |
| 357 | if (libc_include_dir) | 361 | if (libc_include_dir) |
| 358 | codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir)); | 362 | codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir)); |
| 363 | if (zig_std_dir) | ||
| 364 | codegen_set_zig_std_dir(g, buf_create_from_str(zig_std_dir)); | ||
| 359 | if (dynamic_linker) | 365 | if (dynamic_linker) |
| 360 | codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker)); | 366 | codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker)); |
| 361 | if (linker_path) | 367 | if (linker_path) |