zlib: use default configure script on windows#428871
zlib: use default configure script on windows#428871greg-hellings wants to merge 1 commit intoNixOS:stagingfrom
Conversation
|
Change target branch to |
4099757 to
54692b1
Compare
Done |
|
The PR's base branch is set to master, but 259 commits from the staging branch are included. Make sure you know the right base branch for your changes, then:
|
There was a problem hiding this comment.
Can this be a symlink instead like before?
There was a problem hiding this comment.
I have written about the details of why extensively in other PRs related to Windows cross builds, but the short answer is no. DLL files properly belong under the bin/ folder on Windows, not symlinked there.
There was a problem hiding this comment.
I thought there was a setup hook that did this for you, but I guess not.
There was a problem hiding this comment.
I thought there was a setup hook that did this for you, but I guess not.
Most packages seem to have it automatically done, but I believe that is because of updates to autotools over the years and setting the destination folders properly nowadays. In the early days of MinGW, the post fixup had to be done to every single package as autotools didn't have any real knowledge of DLL files. However, zlib uses its own homegrown system so as not to rely on autotools, so I think that's why it is not handled by the standard scripts and options. If there is an automatic hook that would handle this properly, then I would be happy to use it, instead.
There was a problem hiding this comment.
It happens with my Rust projects, which do not use autotools. Looks like it's called win-dll-link
There was a problem hiding this comment.
If it's fine to symlink transitive DLLs I don't get why it's not fine to symlink DLLs from lib.
I would but the static libs / stub libs in $dev/lib, and the DLLs in $out/lib.
There was a problem hiding this comment.
Can also change the hook (in a future PR)
There was a problem hiding this comment.
DLLs properly belong in the bin/ folder on Windows targets. This is because Windows has an extremely limited search path for loading dynamic libraries, but it will always look in the same directory alongside the executing binary. Therefore, the DLLs do not belong in $out/lib but instead belong in $out/bin. This has been established practice for the MinGW packages due to the limitations in Windows search paths and it is how every other package in pkgsCross.mingwW64 handles it, it's how autotools handles it, it's how CMake handles it. The final target's $out/bin when building a .exe gets the dependency and transitive dependency DLL files symlinked into place because there is no equivalent to setting LD paths for Windows. There simply is no precedent anywhere else, including in other nixpkgs Windows targets, for putting the DLL file in lib/. It doesn't belong there. It is not a linker-related file, it is a binary executable on Windows.
Stub libraries and fully static libraries end up in lib/ because they are used at link time but are not necessary to distribute alongside binary files unless you are intentionally distributing build products to enable a downstream dev environment. They could live in $dev/lib or $out/lib depending on the purpose of the parent package, but that's a moot discussion here.
The only reason this difference is exposed here is because zlib has a custom, hand-rolled build system instead of using something like autotools. This change is just maintaining how the library already works, but enabling it to be built for Windows with LLVM compilers. This move is not introducing anything new or altering existing behavior. Here is the current output of building pkgsCross.mingwW64.zlib without this patch:
We really should put this information up in the packaging guidelines somewhere so it doesn't need to be reiterated on every pull request.
There was a problem hiding this comment.
I am very aware how windows search paths work. I am just wondering out loud if we can automate it, because us devs who care about Windows is a much much smaller population than the other major platforms.
There was a problem hiding this comment.
I am opening a separate issue for this point, which is a general disagreement on policy separate from zlib in particular.
There was a problem hiding this comment.
fwiw you can probably reduce the # of rebuilds if you gate the patch.
| patches = [ | |
| ./mingw-shared.patch | |
| ]; | |
| patches = lib.optional stdenv.hostPlatform.isMingw ./mingw-shared.patch; |
There was a problem hiding this comment.
Unsure if it really matters.
There was a problem hiding this comment.
That has been suggested before on other cross build package fixes and was found to still cause rebuilds. I believe this is because previously it was null and the conditional will return an empty array when false. If there was already a list of patches, gating it like that would prevent rebuilds but when adding a new patches field it doesn't seem to have any beneficial effect, sadly.
There was a problem hiding this comment.
If that's the case then you could try it as an optionalAttrs instead, or an if ... then ... else null
There was a problem hiding this comment.
Is that preferred? At other times I've been suggested to leave it in place if the patch file is cross-platform friendly, but if you want it conditional then I'm happy to change it here.
There was a problem hiding this comment.
Looking through the code this doesn't really improve anything in terms of the rebuilds. The three differences are still going to all result in a change - the unconditional list, the conditional list, or the conditional null will all be read as different inputs for the simple fact that they have a key defined at all, even if it is defined as null.
However, now that the code is in with the conditional, it at least reduces the likelihood of a breakage to other targets resulting from this patch having unwanted side effects.
There was a problem hiding this comment.
I've been told that conditionally applied patches are generally not desired in nixpkgs since we want to catch the breakage if a patch no longer applies to a new version of the source as soon as possible. Conditional patches are acceptable if the patch's behavior would affect other systems' behavior in undesirable ways.
There was a problem hiding this comment.
That is consistent with what I have been told in the past, but I haven't kept pace with the latest in the guidelines for that. Seeing as this commit has been languishing since December when it was first submitted and it keeps getting the the point of consensus and then ignored and not merged, I will do absolutely anything a reviewer says which might finally convince one of them to merge it at this point, though.
There was a problem hiding this comment.
I would merge it if I could
54692b1 to
ee973e1
Compare
This avoids the pitfalls of win32/Makefile.gcc (which prevents building on compilers other than gcc without patching and has non-standard installation behavior) and fixes cross compilation for ucrtAarch64
ee973e1 to
3da2ec7
Compare
|
I'm sorry @greg-hellings that this has been held up so long, and now there are merge conflicts. There are issues with zlib on Windows now which are more urgent, and should be fixed here: I think we can look into this patch of yours afterwards. FYI, see also: |
|
This is unblocked now, right? |
This avoids the pitfalls of win32/Makefile.gcc (which prevents building
on compilers other than gcc without patching and has non-standard
installation behavior) and fixes cross compilation for ucrtAarch64
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.