| author | |
| committer | |
| log | e18170ee0bf32996635397e8e919a14a21c88b56 |
| tree | 25bf619190be8e936e44a5f5051828b60d066a9a |
| parent | 62a689f7f534beb237c634683cee50da86c439f0 |
4 files changed, 18 insertions(+), 4 deletions(-)
src/all_types.hpp+1| ... | @@ -1106,6 +1106,7 @@ struct CodeGen { | ... | @@ -1106,6 +1106,7 @@ struct CodeGen { |
| 1106 | Buf *libc_lib_dir; | 1106 | Buf *libc_lib_dir; |
| 1107 | Buf *libc_static_lib_dir; | 1107 | Buf *libc_static_lib_dir; |
| 1108 | Buf *libc_include_dir; | 1108 | Buf *libc_include_dir; |
| 1109 | Buf *dynamic_linker; | ||
| 1109 | bool is_release_build; | 1110 | bool is_release_build; |
| 1110 | bool is_test_build; | 1111 | bool is_test_build; |
| 1111 | LLVMTargetMachineRef target_machine; | 1112 | LLVMTargetMachineRef target_machine; |
src/codegen.cpp+10-4| ... | @@ -33,6 +33,9 @@ CodeGen *codegen_create(Buf *root_source_dir) { | ... | @@ -33,6 +33,9 @@ CodeGen *codegen_create(Buf *root_source_dir) { |
| 33 | g->is_test_build = false; | 33 | g->is_test_build = false; |
| 34 | g->root_source_dir = root_source_dir; | 34 | g->root_source_dir = root_source_dir; |
| 35 | g->error_value_count = 1; | 35 | g->error_value_count = 1; |
| 36 | if (ZIG_DYNAMIC_LINKER) { | ||
| 37 | g->dynamic_linker = buf_create_from_str(ZIG_DYNAMIC_LINKER); | ||
| 38 | } | ||
| 36 | 39 | ||
| 37 | g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR); | 40 | g->libc_lib_dir = buf_create_from_str(ZIG_LIBC_LIB_DIR); |
| 38 | g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR); | 41 | g->libc_static_lib_dir = buf_create_from_str(ZIG_LIBC_STATIC_LIB_DIR); |
| ... | @@ -90,6 +93,10 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) { | ... | @@ -90,6 +93,10 @@ void codegen_set_libc_include_dir(CodeGen *g, Buf *libc_include_dir) { |
| 90 | g->libc_include_dir = libc_include_dir; | 93 | g->libc_include_dir = libc_include_dir; |
| 91 | } | 94 | } |
| 92 | 95 | ||
| 96 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker) { | ||
| 97 | g->dynamic_linker = dynamic_linker; | ||
| 98 | } | ||
| 99 | |||
| 93 | void codegen_add_lib_dir(CodeGen *g, const char *dir) { | 100 | void codegen_add_lib_dir(CodeGen *g, const char *dir) { |
| 94 | g->lib_dirs.append(dir); | 101 | g->lib_dirs.append(dir); |
| 95 | } | 102 | } |
| ... | @@ -4157,13 +4164,12 @@ void codegen_link(CodeGen *g, const char *out_file) { | ... | @@ -4157,13 +4164,12 @@ void codegen_link(CodeGen *g, const char *out_file) { |
| 4157 | args.append(buf_ptr(g->libc_static_lib_dir)); | 4164 | args.append(buf_ptr(g->libc_static_lib_dir)); |
| 4158 | } | 4165 | } |
| 4159 | 4166 | ||
| 4160 | // TODO don't pass this parameter unless linking with libc | 4167 | if (g->dynamic_linker) { |
| 4161 | if (ZIG_DYNAMIC_LINKER[0] == 0) { | ||
| 4162 | args.append("-dynamic-linker"); | 4168 | args.append("-dynamic-linker"); |
| 4163 | args.append(buf_ptr(get_dynamic_linker(g->target_machine))); | 4169 | args.append(buf_ptr(g->dynamic_linker)); |
| 4164 | } else { | 4170 | } else { |
| 4165 | args.append("-dynamic-linker"); | 4171 | args.append("-dynamic-linker"); |
| 4166 | args.append(ZIG_DYNAMIC_LINKER); | 4172 | args.append(buf_ptr(get_dynamic_linker(g->target_machine))); |
| 4167 | } | 4173 | } |
| 4168 | 4174 | ||
| 4169 | if (g->out_type == OutTypeLib) { | 4175 | if (g->out_type == OutTypeLib) { |
src/codegen.hpp+1| ... | @@ -28,6 +28,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name); | ... | @@ -28,6 +28,7 @@ void codegen_set_out_name(CodeGen *codegen, Buf *out_name); |
| 28 | void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir); | 28 | void codegen_set_libc_lib_dir(CodeGen *codegen, Buf *libc_lib_dir); |
| 29 | void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir); | 29 | void codegen_set_libc_static_lib_dir(CodeGen *g, Buf *libc_static_lib_dir); |
| 30 | void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); | 30 | void codegen_set_libc_include_dir(CodeGen *codegen, Buf *libc_include_dir); |
| 31 | void codegen_set_dynamic_linker(CodeGen *g, Buf *dynamic_linker); | ||
| 31 | void codegen_add_lib_dir(CodeGen *codegen, const char *dir); | 32 | void codegen_add_lib_dir(CodeGen *codegen, const char *dir); |
| 32 | 33 | ||
| 33 | void codegen_add_root_code(CodeGen *g, Buf *source_dir, Buf *source_basename, Buf *source_code); | 34 | void codegen_add_root_code(CodeGen *g, Buf *source_dir, Buf *source_basename, Buf *source_code); |
src/main.cpp+6| ... | @@ -32,6 +32,7 @@ static int usage(const char *arg0) { | ... | @@ -32,6 +32,7 @@ static int usage(const char *arg0) { |
| 32 | " --libc-lib-dir [path] set the C compiler data path\n" | 32 | " --libc-lib-dir [path] set the C compiler data path\n" |
| 33 | " --libc-static-lib-dir [path] set the C compiler data path\n" | 33 | " --libc-static-lib-dir [path] set the C compiler data path\n" |
| 34 | " --libc-include-dir [path] set the C compiler data path\n" | 34 | " --libc-include-dir [path] set the C compiler data path\n" |
| 35 | " --dynamic-linker [path] set the path to ld.so\n" | ||
| 35 | " -isystem [dir] add additional search path for other .h files\n" | 36 | " -isystem [dir] add additional search path for other .h files\n" |
| 36 | " -dirafter [dir] same as -isystem but do it last\n" | 37 | " -dirafter [dir] same as -isystem but do it last\n" |
| 37 | " --library-path [dir] add a directory to the library search path\n" | 38 | " --library-path [dir] add a directory to the library search path\n" |
| ... | @@ -62,6 +63,7 @@ int main(int argc, char **argv) { | ... | @@ -62,6 +63,7 @@ int main(int argc, char **argv) { |
| 62 | const char *libc_lib_dir = nullptr; | 63 | const char *libc_lib_dir = nullptr; |
| 63 | const char *libc_static_lib_dir = nullptr; | 64 | const char *libc_static_lib_dir = nullptr; |
| 64 | const char *libc_include_dir = nullptr; | 65 | const char *libc_include_dir = nullptr; |
| 66 | const char *dynamic_linker = nullptr; | ||
| 65 | ZigList<const char *> clang_argv = {0}; | 67 | ZigList<const char *> clang_argv = {0}; |
| 66 | ZigList<const char *> lib_dirs = {0}; | 68 | ZigList<const char *> lib_dirs = {0}; |
| 67 | int err; | 69 | int err; |
| ... | @@ -114,6 +116,8 @@ int main(int argc, char **argv) { | ... | @@ -114,6 +116,8 @@ int main(int argc, char **argv) { |
| 114 | libc_static_lib_dir = argv[i]; | 116 | libc_static_lib_dir = argv[i]; |
| 115 | } else if (strcmp(arg, "--libc-include-dir") == 0) { | 117 | } else if (strcmp(arg, "--libc-include-dir") == 0) { |
| 116 | libc_include_dir = argv[i]; | 118 | libc_include_dir = argv[i]; |
| 119 | } else if (strcmp(arg, "--dynamic-linker") == 0) { | ||
| 120 | dynamic_linker = argv[i]; | ||
| 117 | } else if (strcmp(arg, "-isystem") == 0) { | 121 | } else if (strcmp(arg, "-isystem") == 0) { |
| 118 | clang_argv.append("-isystem"); | 122 | clang_argv.append("-isystem"); |
| 119 | clang_argv.append(argv[i]); | 123 | clang_argv.append(argv[i]); |
| ... | @@ -210,6 +214,8 @@ int main(int argc, char **argv) { | ... | @@ -210,6 +214,8 @@ int main(int argc, char **argv) { |
| 210 | codegen_set_libc_static_lib_dir(g, buf_create_from_str(libc_static_lib_dir)); | 214 | codegen_set_libc_static_lib_dir(g, buf_create_from_str(libc_static_lib_dir)); |
| 211 | if (libc_include_dir) | 215 | if (libc_include_dir) |
| 212 | codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir)); | 216 | codegen_set_libc_include_dir(g, buf_create_from_str(libc_include_dir)); |
| 217 | if (dynamic_linker) | ||
| 218 | codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker)); | ||
| 213 | codegen_set_verbose(g, verbose); | 219 | codegen_set_verbose(g, verbose); |
| 214 | codegen_set_errmsg_color(g, color); | 220 | codegen_set_errmsg_color(g, color); |
| 215 | 221 |