Skip to content

Commit

Permalink
mingw: update build logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ypsvlq committed Jan 20, 2024
1 parent b126978 commit 398ab5f
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 401 deletions.
42 changes: 40 additions & 2 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2636,14 +2636,52 @@ pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool {
if (target.isMinGW()) {
if (eqlIgnoreCase(ignore_case, name, "m"))
return true;
if (eqlIgnoreCase(ignore_case, name, "uuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "mingw32"))
return true;
if (eqlIgnoreCase(ignore_case, name, "msvcrt-os"))
return true;
if (eqlIgnoreCase(ignore_case, name, "mingwex"))
return true;
if (eqlIgnoreCase(ignore_case, name, "uuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "bits"))
return true;
if (eqlIgnoreCase(ignore_case, name, "dmoguids"))
return true;
if (eqlIgnoreCase(ignore_case, name, "dxerr8"))
return true;
if (eqlIgnoreCase(ignore_case, name, "dxerr9"))
return true;
if (eqlIgnoreCase(ignore_case, name, "mfuuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "msxml2"))
return true;
if (eqlIgnoreCase(ignore_case, name, "msxml6"))
return true;
if (eqlIgnoreCase(ignore_case, name, "amstrmid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "wbemuuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "wmcodecdspuuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "dxguid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "ksguid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "locationapi"))
return true;
if (eqlIgnoreCase(ignore_case, name, "portabledeviceguids"))
return true;
if (eqlIgnoreCase(ignore_case, name, "mfuuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "dloadhelper"))
return true;
if (eqlIgnoreCase(ignore_case, name, "strmiids"))
return true;
if (eqlIgnoreCase(ignore_case, name, "mfuuid"))
return true;
if (eqlIgnoreCase(ignore_case, name, "adsiid"))
return true;

return false;
}
Expand Down
12 changes: 2 additions & 10 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,7 @@ pub const MiscTask = enum {

@"mingw-w64 crt2.o",
@"mingw-w64 dllcrt2.o",
@"mingw-w64 mingw32.lib",
@"mingw-w64 msvcrt-os.lib",
@"mingw-w64 mingwex.lib",
@"mingw-w64 uuid.lib",
};

pub const MiscError = struct {
Expand Down Expand Up @@ -1816,14 +1813,9 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
if (comp.wantBuildMinGWFromSource()) {
if (!target_util.canBuildLibC(target)) return error.LibCUnavailable;

const static_lib_jobs = [_]Job{
.{ .mingw_crt_file = .mingw32_lib },
.{ .mingw_crt_file = .mingwex_lib },
.{ .mingw_crt_file = .uuid_lib },
};
const crt_job: Job = .{ .mingw_crt_file = if (is_dyn_lib) .dllcrt2_o else .crt2_o };
try comp.work_queue.ensureUnusedCapacity(static_lib_jobs.len + 1);
comp.work_queue.writeAssumeCapacity(&static_lib_jobs);
try comp.work_queue.ensureUnusedCapacity(2);
comp.work_queue.writeItemAssumeCapacity(.{ .mingw_crt_file = .mingwex_lib });
comp.work_queue.writeItemAssumeCapacity(crt_job);

// When linking mingw-w64 there are some import libs we always need.
Expand Down
9 changes: 0 additions & 9 deletions src/link/Coff/lld.zig
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node)
try argv.append(try comp.get_libc_crt_file(arena, "crt2.obj"));
}

try argv.append(try comp.get_libc_crt_file(arena, "mingw32.lib"));
try argv.append(try comp.get_libc_crt_file(arena, "mingwex.lib"));
try argv.append(try comp.get_libc_crt_file(arena, "uuid.lib"));

for (mingw.always_link_libs) |name| {
if (!comp.system_libs.contains(name)) {
const lib_basename = try allocPrint(arena, "{s}.lib", .{name});
try argv.append(try comp.get_libc_crt_file(arena, lib_basename));
}
}
} else {
const lib_str = switch (comp.config.link_mode) {
.Dynamic => "",
Expand Down
Loading

0 comments on commit 398ab5f

Please sign in to comment.