Skip to content

Commit ba7f40c

Browse files
committed
stage2: fix ELF linking to include compiler_rt
There was duplicated logic for whether to include compiler_rt in the linker line both in the frontend and in the linker backends. Now the logic is only in the frontend; the linker puts it on the linker line if the frontend provides it. Fixes the CI failures.
1 parent bdbedff commit ba7f40c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/link/Elf.zig

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,20 +1282,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
12821282
const gc_sections = self.base.options.gc_sections orelse !is_obj;
12831283
const stack_size = self.base.options.stack_size_override orelse 16777216;
12841284
const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os;
1285-
const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt) blk: {
1286-
// TODO: remove when stage2 can build compiler_rt.zig
1287-
if (!self.base.options.use_llvm) break :blk null;
1288-
1289-
// In the case of build-obj we include the compiler-rt symbols directly alongside
1290-
// the symbols of the root source file, in the same compilation unit.
1291-
if (is_obj) break :blk null;
1292-
1293-
if (is_exe_or_dyn_lib) {
1294-
break :blk comp.compiler_rt_static_lib.?.full_object_path;
1295-
} else {
1296-
break :blk comp.compiler_rt_obj.?.full_object_path;
1297-
}
1298-
} else null;
1285+
const compiler_rt_path: ?[]const u8 = blk: {
1286+
if (comp.compiler_rt_static_lib) |x| break :blk x.full_object_path;
1287+
if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
1288+
break :blk null;
1289+
};
12991290

13001291
// Here we want to determine whether we can save time by not invoking LLD when the
13011292
// output is unchanged. None of the linker options or the object files that are being

0 commit comments

Comments
 (0)