Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cygwin fixes #26021

Merged
merged 23 commits into from Jun 26, 2017
Merged

Cygwin fixes #26021

merged 23 commits into from Jun 26, 2017

Conversation

corngood
Copy link
Contributor

Motivation for this change

This was enough to get git building on cygwin.

The changes should all be limited to stdenv.isCygwin.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@corngood, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zimbatm, @jagajaga and @durko to be potential reviewers.

@@ -35,7 +35,7 @@ _linkDLLs() {
local dllPath2
for dllPath2 in "$dllPath" "$(dirname $(readlink "$dllPath" || echo "$dllPath"))"/*.dll; do
if [ -e ./"$(basename "$dllPath2")" ]; then continue; fi
ln -sr "$dllPath2" .
CYGWIN+=\ winsymlinks:nativestrict ln -sr "$dllPath2" .
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This forces cygwin to use real symlinks, which are needed for the windows library loader. Unfortunately it depends on having elevated permissions in some cases.

@@ -71,7 +71,7 @@ rec {
kernels = with execFormats; with kernelFamilies; setTypesAssert "kernel"
(x: isExecFormat x.execFormat && all isKernelFamily (attrValues x.families))
{
cygwin = { execFormat = pe; families = { inherit /*unix*/ windows-nt; }; };
cygwin = { execFormat = pe; families = { inherit unix windows-nt; }; };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also add cygwin support per-package, but it seems to be that cygwin is as unixy as the others here.

name = "LocaleGettext-1.05";
buildInputs = stdenv.lib.optional (stdenv.isFreeBSD || stdenv.isDarwin || stdenv.isCygwin) pkgs.gettext;
NIX_CFLAGS_LINK = stdenv.lib.optional (stdenv.isFreeBSD || stdenv.isDarwin || stdenv.isCygwin) "-lintl";
src = fetchurl {
url = mirror://cpan/authors/id/P/PV/PVANDRY/gettext-1.05.tar.gz;
sha256 = "15262a00vx714szpx8p2z52wxkz46xp7acl72znwjydyq4ypydi7";
};
};
} // stdenv.lib.optionalAttrs stdenv.isCygwin {
LANG="C";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail without this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is safe to set this on all platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return
fi
find $out -name "*.dll" | while read DLL; do
find "$prefix" -name "*.dll" -type f | while read DLL; do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop it from rebasing linked libs that have already been rebased.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

I don't think that cygwin is really supported right now so we might as well merge that in quickly.

Do you have anything specific you want to tackle before merging into master?

@corngood corngood changed the title WIP: Cygwin fixes Cygwin fixes May 25, 2017
@corngood
Copy link
Contributor Author

@zimbatm I just wanted to make sure it good a solid review, but I'm not aware of any problems, so I removed WIP.

Unfortunately, there's an non trivial conflict now (the cygwin kernel was removed), so I'll have to resolve that and test with latest master.

@zimbatm
Copy link
Member

zimbatm commented May 26, 2017

Thanks, ping me when you fixed the rebase conflicts

@corngood
Copy link
Contributor Author

corngood commented Jun 9, 2017

@Ericson2314 This patch currently adds back the cygwin kernel you recently removed. The intention was to allow cygwin to inherit 'unix' packages. Perhaps 'unix' doesn't really make sense as a kernel family... What do you think?

@Ericson2314
Copy link
Member

@corngood Thanks for the @-mention and good work! So I originally had a cygwin kernel too, but then, following LLVM's example took it out. For now, perhaps you can modify the definition of isUnix instead?

Also, I've been meaning to deprecate stdenv.is*, and use {build,host,target}Platform.is* instead, as the latter are more precise. If you could preempt my deprecation by using that, it would be much appreciated.

@@ -1,4 +1,4 @@
{ stdenv, fetchurl }:
{ stdenv, lib, fetchurl }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For just one use of lib, it's more idiomatic to just do stdenv.lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was one other use of stdenv.lib, so I shortened it.

@@ -41,6 +41,8 @@ stdenv.mkDerivation rec {
moveToOutput lib/python2.7 "$py"
'';

makeFlags = optionalString stdenv.isCygwin "LDFLAGS=-no-undefined";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be passed to configure instead? Not sure which is better, but somehow curious.

@@ -22,7 +22,6 @@ let
++ [ ./nix-ssl-cert-file.patch ]
++ optional (versionOlder version "1.1.0")
(if stdenv.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
++ optional stdenv.isCygwin ./1.0.1-cygwin64.patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you delete this patch file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@corngood
Copy link
Contributor Author

corngood commented Jun 9, 2017

@Ericson2314 Rewriting isUnix and removing the unix kernel family seems like a good idea. I'm thinking it's best to define Unix as a whitelist of:

    Darwin       = { kernel = kernels.darwin; };
    Linux        = { kernel = kernels.linux; };
    SunOS        = { kernel = kernels.solaris; };
    FreeBSD      = { kernel = kernels.freebsd; };
    Hurd         = { kernel = kernels.hurd; };
    NetBSD       = { kernel = kernels.netbsd; };
    OpenBSD      = { kernel = kernels.openbsd; };
    Cygwin       = { kernel = kernels.cygwin; abi = abis.cygnus; };

@Ericson2314
Copy link
Member

@corngood yeah feel free to remove the whole notion of "kernel familes" if you like. matchAttrs doesn't really provide much notion of "or"---you can either just define isUnix as a function predicate, or maybe make a matchAnyAttrs that uses list for or?

@corngood corngood force-pushed the cygwin-wip branch 2 times, most recently from 715adca to f851fba Compare June 12, 2017 17:32
@corngood
Copy link
Contributor Author

corngood commented Jun 12, 2017

@Ericson2314 f851fba is what I came up with for isUnix. If I made all the patterns lists, then matchAnyAttrs might make sense in attrsets.nix, but I left it local for now.

I didn't completely remove kernel families, because there is at least a conceivable use for them, but I can do that if you'd prefer.

BSD = { kernel = { families = { inherit (kernelFamilies) bsd; }; }; };
Unix = [ BSD Linux SunOS Hurd Cygwin ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you either remove the inner rec and do with patterns; here, or remove the existing patterns. below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the redundant patterns., aside from the string indexed ones. I'm not aware of a better way to deal with them. I don't really have strong feelings on this vs. with patterns;, but this is slightly more concise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was the string ones that led me to avoid the inner rec to begin with, but that was probably an overkill move on my part :).

@Ericson2314
Copy link
Member

@corngood good decisions on both counts. I just left you one tiny nit---hardly worth mentioning. Other than that, there is the notes on stdenv.is vs hostPlatform.is* on #26021 (comment) . I suppose it's fine to just to deal with that latter, but it would be useful if anyone wants to cross compile for cygwin.

@corngood corngood force-pushed the cygwin-wip branch 3 times, most recently from e89ad85 to 24a3b34 Compare June 12, 2017 19:36
@corngood
Copy link
Contributor Author

@Ericson2314 Is 974df1f what you had in mind? I'm pretty sure those are all correct as hostPlatform.

I can squash them into the original changes if you prefer.

@Ericson2314
Copy link
Member

Ericson2314 commented Jun 12, 2017

@corngood a quick skim found one that should actually be buildPlatform.isCygwin but the rest I think are good. Thanks for making these changes!

No preference on redoing the history or not.

@corngood
Copy link
Contributor Author

corngood commented Jun 13, 2017

@Ericson2314 good catch. I made that one change and squashed each package.

Looks like CI is failing due to timeout / log limit?

@Ericson2314
Copy link
Member

CI is failing because travis sucks and the hydra channels are broken for days, sniff. I suppose I could just throw my hands in the error and merge this like other PRs, but I was waiting in hopes the channels would eventually be fixed and then it could be properly tested.

It's really awful that

  1. We allow master to be broken
  2. We allow merging PRs unrelated to fixing it once it is

@corngood
Copy link
Contributor Author

@Ericson2314 rebased on staging.

Building stdenv (especially gcc) is a can of worms. I'll keep plugging away at it in my spare time, but there's no point in holding this up.

@Ericson2314
Copy link
Member

@corngood Fair enough. So is this PR just progress then? Or does git still build?

@corngood
Copy link
Contributor Author

@Ericson2314 git doesn't currently build due to breakage in ruby, via docbook.

@corngood
Copy link
Contributor Author

@Ericson2314 actually looks like gitMinimal does build, so it's sufficient for fetchgit, which is what I was originally looking for.

@Ericson2314
Copy link
Member

Sounds great; I'm going to merge! Sorry this took so long, @corngood, but excellent job!

@Ericson2314 Ericson2314 merged commit b686fd1 into NixOS:staging Jun 26, 2017
@vcunat
Copy link
Member

vcunat commented Jul 3, 2017

@Ericson2314, @corngood: this made all darwin packages evaluate as broken, stopping Hydra builds. Any ideas? I bisected the error to 4ac1901, but I don't understand the changes enough (yet).

@Ericson2314
Copy link
Member

Ericson2314 commented Jul 3, 2017

The Unix list should include Darwin, but doesn't. Sorry I didn't catch this the first time around.

@corngood
Copy link
Contributor Author

corngood commented Jul 3, 2017

Shit, sorry about that. I prepared a PR to fix isUnix: #27089. I'm just in the process of reproducing it.

@corngood corngood mentioned this pull request Jul 3, 2017
8 tasks
@vcunat
Copy link
Member

vcunat commented Jul 3, 2017

Thanks for the quick fixup. Job counts on Hydra seem OK now.

@Ericson2314 Ericson2314 added the 6.topic: windows Running, or buiding, packages on Windows label Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: windows Running, or buiding, packages on Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants