From b41a0b4768d368d81d0d33c779f919d8f315e622 Mon Sep 17 00:00:00 2001 From: mlugg Date: Wed, 6 Mar 2024 21:24:38 +0000 Subject: Package.Module: deduplicate identical builtin modules Previously, when multiple modules had builtin modules with identical sources, two distinct `Module`s and `File`s were created pointing at the same file path. This led to a bug later in the frontend. These modules are now deduplicated with a simple hashmap on the builtin source. --- src/Compilation.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 539a11faa0..798fbc9a4c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1325,6 +1325,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .global = options.config, .parent = options.root_mod, .builtin_mod = options.root_mod.getBuiltinDependency(), + .builtin_modules = null, // `builtin_mod` is set }); try options.root_mod.deps.putNoClobber(arena, "compiler_rt", compiler_rt_mod); } @@ -1429,6 +1430,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil .global = options.config, .parent = options.root_mod, .builtin_mod = options.root_mod.getBuiltinDependency(), + .builtin_modules = null, // `builtin_mod` is set }); const zcu = try arena.create(Module); @@ -6104,6 +6106,7 @@ fn buildOutputFromZig( .cc_argv = &.{}, .parent = null, .builtin_mod = null, + .builtin_modules = null, // there is only one module in this compilation }); const root_name = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len]; const target = comp.getTarget(); @@ -6216,6 +6219,7 @@ pub fn build_crt_file( .cc_argv = &.{}, .parent = null, .builtin_mod = null, + .builtin_modules = null, // there is only one module in this compilation }); for (c_source_files) |*item| { -- cgit v1.2.3