std.Build: Install Windows DLLs to <prefix>/bin/ by default

Windows does not support RPATH and only searches for DLLs in a small
number of predetermined paths by default, with one of them being the
directory from which the application loaded.

Installing both executables and DLLs to `bin/` by default helps ensure
that the executable can find any DLL artifacts it has linked to.
DLL import libraries are still installed to `lib/`.

These defaults match CMake's behavior.
This commit is contained in:
Carl Åstholm
2024-04-22 22:13:49 +02:00
committed by Andrew Kelley
parent c947e79d73
commit e8f28cda9e
2 changed files with 9 additions and 8 deletions

View File

@@ -614,6 +614,10 @@ pub fn isStaticLibrary(self: *const Compile) bool {
return self.kind == .lib and self.linkage != .dynamic;
}
pub fn isDll(self: *Compile) bool {
return self.isDynamicLibrary() and self.rootModuleTarget().os.tag == .windows;
}
pub fn producesPdbFile(self: *Compile) bool {
const target = self.rootModuleTarget();
// TODO: Is this right? Isn't PDB for *any* PE/COFF file?
@@ -632,7 +636,7 @@ pub fn producesPdbFile(self: *Compile) bool {
}
pub fn producesImplib(self: *Compile) bool {
return self.isDynamicLibrary() and self.rootModuleTarget().os.tag == .windows;
return self.isDll();
}
pub fn linkLibC(self: *Compile) void {