| ... | @@ -746,6 +746,18 @@ const SystemLib = struct { | ... | @@ -746,6 +746,18 @@ const SystemLib = struct { |
| 746 | } | 746 | } |
| 747 | }; | 747 | }; |
| 748 | | 748 | |
| | 749 | const CliModule = struct { |
| | 750 | mod: *Package, |
| | 751 | /// still in CLI arg format |
| | 752 | deps_str: []const u8, |
| | 753 | }; |
| | 754 | |
| | 755 | fn cleanupModules(modules: *std.StringArrayHashMap(CliModule)) void { |
| | 756 | var it = modules.iterator(); |
| | 757 | while (it.next()) |kv| kv.value_ptr.mod.destroy(modules.allocator); |
| | 758 | modules.deinit(); |
| | 759 | } |
| | 760 | |
| 749 | fn buildOutputType( | 761 | fn buildOutputType( |
| 750 | gpa: Allocator, | 762 | gpa: Allocator, |
| 751 | arena: Allocator, | 763 | arena: Allocator, |
| ... | @@ -893,62 +905,30 @@ fn buildOutputType( | ... | @@ -893,62 +905,30 @@ fn buildOutputType( |
| 893 | var error_tracing: ?bool = null; | 905 | var error_tracing: ?bool = null; |
| 894 | var pdb_out_path: ?[]const u8 = null; | 906 | var pdb_out_path: ?[]const u8 = null; |
| 895 | var dwarf_format: ?std.dwarf.Format = null; | 907 | var dwarf_format: ?std.dwarf.Format = null; |
| 896 | | | |
| 897 | // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names. | 908 | // e.g. -m3dnow or -mno-outline-atomics. They correspond to std.Target llvm cpu feature names. |
| 898 | // This array is populated by zig cc frontend and then has to be converted to zig-style | 909 | // This array is populated by zig cc frontend and then has to be converted to zig-style |
| 899 | // CPU features. | 910 | // CPU features. |
| 900 | var llvm_m_args = std.ArrayList([]const u8).init(gpa); | 911 | var llvm_m_args = std.ArrayList([]const u8).init(arena); |
| 901 | defer llvm_m_args.deinit(); | | |
| 902 | | | |
| 903 | var system_libs = std.StringArrayHashMap(SystemLib).init(arena); | 912 | var system_libs = std.StringArrayHashMap(SystemLib).init(arena); |
| 904 | | 913 | var wasi_emulated_libs = std.ArrayList(wasi_libc.CRTFile).init(arena); |
| 905 | var wasi_emulated_libs = std.ArrayList(wasi_libc.CRTFile).init(gpa); | 914 | var clang_argv = std.ArrayList([]const u8).init(arena); |
| 906 | defer wasi_emulated_libs.deinit(); | 915 | var extra_cflags = std.ArrayList([]const u8).init(arena); |
| 907 | | | |
| 908 | var clang_argv = std.ArrayList([]const u8).init(gpa); | | |
| 909 | defer clang_argv.deinit(); | | |
| 910 | | | |
| 911 | var extra_cflags = std.ArrayList([]const u8).init(gpa); | | |
| 912 | defer extra_cflags.deinit(); | | |
| 913 | | | |
| 914 | // These are before resolving sysroot. | 916 | // These are before resolving sysroot. |
| 915 | var lib_dir_args = std.ArrayList([]const u8).init(arena); | 917 | var lib_dir_args = std.ArrayList([]const u8).init(arena); |
| 916 | | 918 | var rpath_list = std.ArrayList([]const u8).init(arena); |
| 917 | var rpath_list = std.ArrayList([]const u8).init(gpa); | | |
| 918 | defer rpath_list.deinit(); | | |
| 919 | | | |
| 920 | var symbol_wrap_set: std.StringArrayHashMapUnmanaged(void) = .{}; | 919 | var symbol_wrap_set: std.StringArrayHashMapUnmanaged(void) = .{}; |
| 921 | | 920 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 922 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(gpa); | 921 | var link_objects = std.ArrayList(Compilation.LinkObject).init(arena); |
| 923 | defer c_source_files.deinit(); | 922 | var framework_dirs = std.ArrayList([]const u8).init(arena); |
| 924 | | | |
| 925 | var link_objects = std.ArrayList(Compilation.LinkObject).init(gpa); | | |
| 926 | defer link_objects.deinit(); | | |
| 927 | | | |
| 928 | var framework_dirs = std.ArrayList([]const u8).init(gpa); | | |
| 929 | defer framework_dirs.deinit(); | | |
| 930 | | | |
| 931 | var frameworks: std.StringArrayHashMapUnmanaged(Compilation.Framework) = .{}; | 923 | var frameworks: std.StringArrayHashMapUnmanaged(Compilation.Framework) = .{}; |
| 932 | | | |
| 933 | // null means replace with the test executable binary | 924 | // null means replace with the test executable binary |
| 934 | var test_exec_args = std.ArrayList(?[]const u8).init(gpa); | 925 | var test_exec_args = std.ArrayList(?[]const u8).init(arena); |
| 935 | defer test_exec_args.deinit(); | 926 | var linker_export_symbol_names = std.ArrayList([]const u8).init(arena); |
| 936 | | | |
| 937 | var linker_export_symbol_names = std.ArrayList([]const u8).init(gpa); | | |
| 938 | defer linker_export_symbol_names.deinit(); | | |
| 939 | | | |
| 940 | // Contains every module specified via --mod. The dependencies are added | 927 | // Contains every module specified via --mod. The dependencies are added |
| 941 | // after argument parsing is completed. We use a StringArrayHashMap to make | 928 | // after argument parsing is completed. We use a StringArrayHashMap to make |
| 942 | // error output consistent. | 929 | // error output consistent. |
| 943 | var modules = std.StringArrayHashMap(struct { | 930 | var modules = std.StringArrayHashMap(CliModule).init(gpa); |
| 944 | mod: *Package, | 931 | defer cleanupModules(&modules); |
| 945 | deps_str: []const u8, // still in CLI arg format | | |
| 946 | }).init(gpa); | | |
| 947 | defer { | | |
| 948 | var it = modules.iterator(); | | |
| 949 | while (it.next()) |kv| kv.value_ptr.mod.destroy(gpa); | | |
| 950 | modules.deinit(); | | |
| 951 | } | | |
| 952 | | 932 | |
| 953 | // The dependency string for the root package | 933 | // The dependency string for the root package |
| 954 | var root_deps_str: ?[]const u8 = null; | 934 | var root_deps_str: ?[]const u8 = null; |