Skip to content

Zig tries to generate MinGW import libraries when targeting MSVC #24766

@squeek502

Description

@squeek502

Zig Version

0.15.0-dev.1495+14f11377c

Steps to Reproduce and Observed Behavior

  • Build a Zig compiler for Windows without -Denable-llvm
  • Create a hello world file with a main that calls std.debug.print
  • zig build-exe hello.zig -fno-llvm -fno-lld -target x86_64-windows-msvc
error: unable to generate DLL import .lib file for kernel32: ZigCompilerNotBuiltWithLLVMExtensions

Relevant code:

zig/src/Compilation.zig

Lines 5173 to 5185 in 14f1137

.windows_import_lib => |index| {
const named_frame = tracy.namedFrame("windows_import_lib");
defer named_frame.end();
const link_lib = comp.windows_libs.keys()[index];
mingw.buildImportLib(comp, link_lib) catch |err| {
// TODO Surface more error details.
comp.lockAndSetMiscFailure(
.windows_import_lib,
"unable to generate DLL import .lib file for {s}: {s}",
.{ link_lib, @errorName(err) },
);
};

Expected Behavior

When targeting MSVC, the .lib files should be gotten from the MSVC lib directories rather than generated from the MinGW .def files. That is, this particular error should be impossible when targeting MSVC.


Note that this is not super relevant right now, will become more relevant once progress on #17751 and #17807 is made

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-windowsMicrosoft Windows

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions