-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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: add as a cross-compilation target, and get bash.exe to compile #354137
base: master
Are you sure you want to change the base?
Conversation
meta = { | ||
platforms = lib.platforms.windows; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be folded to just meta.platforms
but it might be good to fill in the rest of the typical metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had been marked as resolved but doesn't seem to have actually been?
@@ -3,7 +3,7 @@ | |||
, updateAutotoolsGnuConfigScriptsHook | |||
, ncurses, termcap | |||
, curses-library ? | |||
if stdenv.hostPlatform.isWindows | |||
if stdenv.hostPlatform.isMinGW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the exact reason for changing from checking for windows in general to mingw? Would isWindows || isMinGW
work better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isWindows
includes Cygwin. Under Cygwin we want to use ncurses, not termcap.
patches = lib.optionals (curses-library.pname == "ncurses") [ | ||
./link-against-ncurses.patch | ||
] ++ [ | ||
./no-arch_only-8.2.patch | ||
] | ||
++ upstreamPatches | ||
++ lib.optionals stdenv.hostPlatform.isWindows [ | ||
++ lib.optionals stdenv.hostPlatform.isMinGW [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the exact reason for changing from checking for windows in general to mingw? Would isWindows || isMinGW
work better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to apply these patches under Cygwin. Cywin provides a POSIX API under Windows, so we want to use the normal POSIX calls which readline would usually make.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could be something like (stdenv.hostPlatform.isWindows && !stdenv.hostPlatform.isUnix)
if we wanted to mark Cygwin as the technically‐correct Windows + Unix and confuse everyone for the rest of time?
(Because after all there could theoretically be e.g. an MSVC platform too…)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilazy yeah really good point, MSVC is on its way. I actually like the suggestion of isWindows && !isUnix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just be prepared for the fact that there’s probably a lot of things in the tree that assume the two are disjoint. But it’d be great to deconfuse that along the way.
And hey, it’ll prepare us for when midipix releases in 2038…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash specific changes amongst your commits. You can make several commits and use git rebase -i
to do that. Also, please format your nix files so CI can pass.
Check out git-absorb for this @puffnfresh |
@@ -99,6 +99,8 @@ stdenv.mkDerivation (finalAttrs: { | |||
CFLAGS=-D_XOPEN_SOURCE_EXTENDED | |||
''; | |||
|
|||
hardeningDisable = lib.optionals stdenv.hostPlatform.isCygwin [ "fortify" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the error? Include it as a ~1 line verbatim comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this needs to be set for every package, why not globally disable fortify for cygwin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alyssais I wanted to, but I'm not sure where the best place to do that would be. Should it be an additional condition in the default value of defaultHardeningFlags
in pkgs/build-support/bintools-wrapper
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also have the added benefit of making it not a mass rebuild, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved this to bintools-wrapper
and added a few things to avoid the mass rebuild.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commits that set it individually for packages need to be updated then.
9a9998b
to
05826a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be more than two commits. One logical change at a time, that gets it a bit further.
@@ -99,6 +99,8 @@ stdenv.mkDerivation (finalAttrs: { | |||
CFLAGS=-D_XOPEN_SOURCE_EXTENDED | |||
''; | |||
|
|||
hardeningDisable = lib.optionals stdenv.hostPlatform.isCygwin [ "fortify" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this needs to be set for every package, why not globally disable fortify for cygwin?
05826a1
to
3495b2e
Compare
I've split this into 10 commits now. Also resolved conflicts. |
then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; } | ||
then mkSkeletonFromList [ (elemAt l 0) "pc" "cygwin" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is purely a matter of style, not behavior, right?
(I kinda wonder if we can just drop this case, as the older cygwin stuff is bit-rotted for years at this point.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favour of getting rid of all the older Cygwin support, since it just doesn't work anymore (I tried).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's well over a decade old
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a go at removing the hack altogether: puffnfresh@16e9e8b
It feels a little bit wrong to add Cygwin as a "kernel" but it does seem to work. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead patch configure.ac
and regen with autoreconfHook
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. This was copied from Microsoft's Windows-on-ARM-Experiments repository. Not sure why it was done that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh probably because they are lazy af lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why copied and not fetched? If you used fetchpatch you could even use extraPrefix
to make it so you can just put it in patches
.
The size of various things don't line up when enabling fortification. This might be able to be fixed by looking at the Cywin builds, because I think they don't generally disable fortify.
Oh is this |
@ofborg eval |
OK this is evaluating now! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/dropping-cygwin-support/3425/19 |
@@ -242,6 +242,10 @@ let | |||
# cc1: error: fp software completion requires '-mtrap-precision=i' [-Werror] | |||
"--disable-werror" | |||
] | |||
++ lib.optionals targetPlatform.isCygwin [ | |||
# doesn't cross-compile under Cygwin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "for Cygwin" (when running under some other platform)? Otherwise the check is wrong.
}; | ||
|
||
patches = [ | ||
(fetchpatch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a static file, so there's no need for patch normalization and fetchurl can be used.
meta = { | ||
platforms = lib.platforms.windows; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had been marked as resolved but doesn't seem to have actually been?
|
||
nativeBuildInputs = [ bison ]; | ||
|
||
patches = [ ./remove-lto.patch ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could do with some explanation, ideally in the patch file.
url = "https://git.code.sf.net/p/cocom/git"; | ||
sha256 = "sha256-utLafkznMC4LrZgF6vKehtIGMwNMwLP9M9Nwu/RyWio="; | ||
rev = "64ee80224aa13f9944d439f3f90862ca76158705"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not the release tarball?
ln -fs w32api/libpsapi.a . | ||
ln -fs w32api/libuserenv.a . | ||
ln -fs w32api/libnetapi32.a . | ||
ln -fs w32api/libdbghelp.a . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would w32api/*.a be wrong?
Changing directory without changing back at the end also makes me worry about fixupPhase not working.
]; | ||
}; | ||
in | ||
# TODO: Is there something like nix-support which would achieve this better? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just link the appropriate paths in postInstall in the main derivation?
@@ -99,6 +99,8 @@ stdenv.mkDerivation (finalAttrs: { | |||
CFLAGS=-D_XOPEN_SOURCE_EXTENDED | |||
''; | |||
|
|||
hardeningDisable = lib.optionals stdenv.hostPlatform.isCygwin [ "fortify" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commits that set it individually for packages need to be updated then.
@@ -474,6 +474,7 @@ stdenvNoCC.mkDerivation { | |||
echo addToSearchPath "LINK_DLL_FOLDERS" "${cc_solib}/lib" > $out | |||
echo addToSearchPath "LINK_DLL_FOLDERS" "${cc_solib}/lib64" >> $out | |||
echo addToSearchPath "LINK_DLL_FOLDERS" "${cc_solib}/lib32" >> $out | |||
echo addToSearchPath "LINK_DLL_FOLDERS" "${libc_bin}/bin" > $out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit surprising that it's in bin — is that definitely right?
@@ -107,6 +107,8 @@ stdenv.mkDerivation rec { | |||
|
|||
enableParallelBuilding = true; | |||
|
|||
makeFlags = [ ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make the code more complicated just to avoid a mass rebuild. Mass rebuilds are fine. The bash changes can do to staging separately from the rest of this if you want.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.