Skip to content

Commit 9db6d95

Browse files
the-horothewilsonator
authored andcommitted
Add -lz when PHOBOS_SYSTEM_ZLIB=on and -link-defaultlib-shared
Some projects use the zlib C function directly and, given that those symbols are available when phobos embeds zlib (the default) and when linking the stdlib statically, the projects often don't include a `-lz` in their build settings. This omission then prevents a successful build with PHOBOS_SYSTEM_ZLIB=on and -link-defaultlib-shared. Until a permanent decision is made if those projects should change their build scripts or if the compiler should always add `-lz`, add the library anyway, to minimize breakages. This also makes the behavior consistent with gdc which also adds an unconditional `-lz` when zlib is not embedded. See-Also: #4742 Signed-off-by: Andrei Horodniceanu <[email protected]>
1 parent 0fddfc5 commit 9db6d95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

driver/linker-gcc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
594594
args.push_back("-l" + name);
595595
}
596596
#ifdef PHOBOS_SYSTEM_ZLIB
597-
if (!defaultLibNames.empty() && !linkAgainstSharedDefaultLibs())
597+
if (!defaultLibNames.empty())
598598
args.push_back("-lz");
599599
#endif
600600

0 commit comments

Comments
 (0)