| ... | ... | @@ -885,12 +885,17 @@ static void init(CodeGen *g, Buf *source_path) { |
| 885 | 885 | g->is_native_target = true; |
| 886 | 886 | char *native_triple = LLVMGetDefaultTargetTriple(); |
| 887 | 887 | |
| 888 | g->module = LLVMModuleCreateWithName(buf_ptr(source_path)); |
| 889 | |
| 890 | LLVMSetTarget(g->module, native_triple); |
| 891 | |
| 888 | 892 | LLVMTargetRef target_ref; |
| 889 | 893 | char *err_msg = nullptr; |
| 890 | 894 | if (LLVMGetTargetFromTriple(native_triple, &target_ref, &err_msg)) { |
| 891 | 895 | zig_panic("unable to get target from triple: %s", err_msg); |
| 892 | 896 | } |
| 893 | 897 | |
| 898 | |
| 894 | 899 | char *native_cpu = LLVMZigGetHostCPUName(); |
| 895 | 900 | char *native_features = LLVMZigGetNativeFeatures(); |
| 896 | 901 | |
| ... | ... | @@ -904,8 +909,9 @@ static void init(CodeGen *g, Buf *source_path) { |
| 904 | 909 | |
| 905 | 910 | g->target_data_ref = LLVMGetTargetMachineData(g->target_machine); |
| 906 | 911 | |
| 912 | char *layout_str = LLVMCopyStringRepOfTargetData(g->target_data_ref); |
| 913 | LLVMSetDataLayout(g->module, layout_str); |
| 907 | 914 | |
| 908 | | g->module = LLVMModuleCreateWithName("ZigModule"); |
| 909 | 915 | |
| 910 | 916 | g->pointer_size_bytes = LLVMPointerSize(g->target_data_ref); |
| 911 | 917 | |