| author | |
| committer | |
| log | fbcb00fbb38715cede40fb4af6b6f99b771ff02a |
| tree | 53709862fe67e2eba89bb08da1866391d11db3a0 |
| parent | e6d2e1641363c97f53d4168b319b4dca6224e25e |
| parent | 41282e7fb2874c3c838e2b00761d6e8b174a7beb |
| signature |
fix llvm-enabled compiler builds with the self-hosted backend5 files changed, 32 insertions(+), 13 deletions(-)
build.zig+4| ... | @@ -861,6 +861,10 @@ fn addCxxKnownPath( | ... | @@ -861,6 +861,10 @@ fn addCxxKnownPath( |
| 861 | } | 861 | } |
| 862 | return error.RequiredLibraryNotFound; | 862 | return error.RequiredLibraryNotFound; |
| 863 | } | 863 | } |
| 864 | // By default, explicit library paths are not checked for being linker scripts, | ||
| 865 | // but libc++ may very well be one, so force all inputs to be checked when passing | ||
| 866 | // an explicit path to libc++. | ||
| 867 | exe.allow_so_scripts = true; | ||
| 864 | exe.addObjectFile(.{ .cwd_relative = path_unpadded }); | 868 | exe.addObjectFile(.{ .cwd_relative = path_unpadded }); |
| 865 | 869 | ||
| 866 | // TODO a way to integrate with system c++ include files here | 870 | // TODO a way to integrate with system c++ include files here |
src/Sema.zig+15-11| ... | @@ -35010,6 +35010,7 @@ fn resolvePeerTypesInner( | ... | @@ -35010,6 +35010,7 @@ fn resolvePeerTypesInner( |
| 35010 | // if there were no actual slices. Else, we want the slice index to report a conflict. | 35010 | // if there were no actual slices. Else, we want the slice index to report a conflict. |
| 35011 | var opt_slice_idx: ?usize = null; | 35011 | var opt_slice_idx: ?usize = null; |
| 35012 | 35012 | ||
| 35013 | var any_abi_aligned = false; | ||
| 35013 | var opt_ptr_info: ?InternPool.Key.PtrType = null; | 35014 | var opt_ptr_info: ?InternPool.Key.PtrType = null; |
| 35014 | var first_idx: usize = undefined; | 35015 | var first_idx: usize = undefined; |
| 35015 | var other_idx: usize = undefined; // We sometimes need a second peer index to report a generic error | 35016 | var other_idx: usize = undefined; // We sometimes need a second peer index to report a generic error |
| ... | @@ -35054,17 +35055,14 @@ fn resolvePeerTypesInner( | ... | @@ -35054,17 +35055,14 @@ fn resolvePeerTypesInner( |
| 35054 | } }; | 35055 | } }; |
| 35055 | 35056 | ||
| 35056 | // Note that the align can be always non-zero; Type.ptr will canonicalize it | 35057 | // Note that the align can be always non-zero; Type.ptr will canonicalize it |
| 35057 | ptr_info.flags.alignment = Alignment.min( | 35058 | if (peer_info.flags.alignment == .none) { |
| 35058 | if (ptr_info.flags.alignment != .none) | 35059 | any_abi_aligned = true; |
| 35059 | ptr_info.flags.alignment | 35060 | } else if (ptr_info.flags.alignment == .none) { |
| 35060 | else | 35061 | any_abi_aligned = true; |
| 35061 | try Type.fromInterned(ptr_info.child).abiAlignmentSema(pt), | 35062 | ptr_info.flags.alignment = peer_info.flags.alignment; |
| 35062 | 35063 | } else { | |
| 35063 | if (peer_info.flags.alignment != .none) | 35064 | ptr_info.flags.alignment = ptr_info.flags.alignment.minStrict(peer_info.flags.alignment); |
| 35064 | peer_info.flags.alignment | 35065 | } |
| 35065 | else | ||
| 35066 | try Type.fromInterned(peer_info.child).abiAlignmentSema(pt), | ||
| 35067 | ); | ||
| 35068 | 35066 | ||
| 35069 | if (ptr_info.flags.address_space != peer_info.flags.address_space) { | 35067 | if (ptr_info.flags.address_space != peer_info.flags.address_space) { |
| 35070 | return generic_err; | 35068 | return generic_err; |
| ... | @@ -35312,6 +35310,12 @@ fn resolvePeerTypesInner( | ... | @@ -35312,6 +35310,12 @@ fn resolvePeerTypesInner( |
| 35312 | }, | 35310 | }, |
| 35313 | } | 35311 | } |
| 35314 | 35312 | ||
| 35313 | if (any_abi_aligned and opt_ptr_info.?.flags.alignment != .none) { | ||
| 35314 | opt_ptr_info.?.flags.alignment = opt_ptr_info.?.flags.alignment.minStrict( | ||
| 35315 | try Type.fromInterned(pointee).abiAlignmentSema(pt), | ||
| 35316 | ); | ||
| 35317 | } | ||
| 35318 | |||
| 35315 | return .{ .success = try pt.ptrTypeSema(opt_ptr_info.?) }; | 35319 | return .{ .success = try pt.ptrTypeSema(opt_ptr_info.?) }; |
| 35316 | }, | 35320 | }, |
| 35317 | 35321 |
src/link/Elf/SharedObject.zig+1| ... | @@ -72,6 +72,7 @@ pub const Parsed = struct { | ... | @@ -72,6 +72,7 @@ pub const Parsed = struct { |
| 72 | 72 | ||
| 73 | pub fn deinit(p: *Parsed, gpa: Allocator) void { | 73 | pub fn deinit(p: *Parsed, gpa: Allocator) void { |
| 74 | gpa.free(p.strtab); | 74 | gpa.free(p.strtab); |
| 75 | gpa.free(p.sections); | ||
| 75 | gpa.free(p.symtab); | 76 | gpa.free(p.symtab); |
| 76 | gpa.free(p.versyms); | 77 | gpa.free(p.versyms); |
| 77 | gpa.free(p.symbols); | 78 | gpa.free(p.symbols); |
src/main.zig+4-2| ... | @@ -984,6 +984,7 @@ fn buildOutputType( | ... | @@ -984,6 +984,7 @@ fn buildOutputType( |
| 984 | .libc_paths_file = try EnvVar.ZIG_LIBC.get(arena), | 984 | .libc_paths_file = try EnvVar.ZIG_LIBC.get(arena), |
| 985 | .native_system_include_paths = &.{}, | 985 | .native_system_include_paths = &.{}, |
| 986 | }; | 986 | }; |
| 987 | defer create_module.link_inputs.deinit(gpa); | ||
| 987 | 988 | ||
| 988 | // before arg parsing, check for the NO_COLOR and CLICOLOR_FORCE environment variables | 989 | // before arg parsing, check for the NO_COLOR and CLICOLOR_FORCE environment variables |
| 989 | // if set, default the color setting to .off or .on, respectively | 990 | // if set, default the color setting to .off or .on, respectively |
| ... | @@ -3682,7 +3683,7 @@ const CreateModule = struct { | ... | @@ -3682,7 +3683,7 @@ const CreateModule = struct { |
| 3682 | /// This one is used while collecting CLI options. The set of libs is used | 3683 | /// This one is used while collecting CLI options. The set of libs is used |
| 3683 | /// directly after computing the target and used to compute link_libc, | 3684 | /// directly after computing the target and used to compute link_libc, |
| 3684 | /// link_libcpp, and then the libraries are filtered into | 3685 | /// link_libcpp, and then the libraries are filtered into |
| 3685 | /// `unresolved_linker_inputs` and `windows_libs`. | 3686 | /// `unresolved_link_inputs` and `windows_libs`. |
| 3686 | cli_link_inputs: std.ArrayListUnmanaged(link.UnresolvedInput), | 3687 | cli_link_inputs: std.ArrayListUnmanaged(link.UnresolvedInput), |
| 3687 | windows_libs: std.StringArrayHashMapUnmanaged(void), | 3688 | windows_libs: std.StringArrayHashMapUnmanaged(void), |
| 3688 | /// The local variable `unresolved_link_inputs` is fed into library | 3689 | /// The local variable `unresolved_link_inputs` is fed into library |
| ... | @@ -3816,7 +3817,8 @@ fn createModule( | ... | @@ -3816,7 +3817,8 @@ fn createModule( |
| 3816 | // to decide whether to trigger native path detection logic. | 3817 | // to decide whether to trigger native path detection logic. |
| 3817 | // Preserves linker input order. | 3818 | // Preserves linker input order. |
| 3818 | var unresolved_link_inputs: std.ArrayListUnmanaged(link.UnresolvedInput) = .empty; | 3819 | var unresolved_link_inputs: std.ArrayListUnmanaged(link.UnresolvedInput) = .empty; |
| 3819 | try unresolved_link_inputs.ensureUnusedCapacity(arena, create_module.cli_link_inputs.items.len); | 3820 | defer unresolved_link_inputs.deinit(gpa); |
| 3821 | try unresolved_link_inputs.ensureUnusedCapacity(gpa, create_module.cli_link_inputs.items.len); | ||
| 3820 | var any_name_queries_remaining = false; | 3822 | var any_name_queries_remaining = false; |
| 3821 | for (create_module.cli_link_inputs.items) |cli_link_input| switch (cli_link_input) { | 3823 | for (create_module.cli_link_inputs.items) |cli_link_input| switch (cli_link_input) { |
| 3822 | .name_query => |nq| { | 3824 | .name_query => |nq| { |
test/behavior/slice.zig+8| ... | @@ -995,3 +995,11 @@ test "sentinel-terminated 0-length slices" { | ... | @@ -995,3 +995,11 @@ test "sentinel-terminated 0-length slices" { |
| 995 | try expect(comptime_known_array_value[0] == 2); | 995 | try expect(comptime_known_array_value[0] == 2); |
| 996 | try expect(runtime_array_value[0] == 2); | 996 | try expect(runtime_array_value[0] == 2); |
| 997 | } | 997 | } |
| 998 | |||
| 999 | test "peer slices keep abi alignment with empty struct" { | ||
| 1000 | var cond: bool = undefined; | ||
| 1001 | cond = false; | ||
| 1002 | const slice = if (cond) &[1]u32{42} else &.{}; | ||
| 1003 | comptime assert(@TypeOf(slice) == []const u32); | ||
| 1004 | try expect(slice.len == 0); | ||
| 1005 | } |