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

makeWrapper doesn't cross-compile to windows #120726

Open
Radvendii opened this issue Apr 26, 2021 · 4 comments
Open

makeWrapper doesn't cross-compile to windows #120726

Radvendii opened this issue Apr 26, 2021 · 4 comments
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: windows Running, or buiding, packages on Windows

Comments

@Radvendii
Copy link
Contributor

Describe the bug
makeWrapper depends on bash, which doesn't build for windows (see #119206)
It makes sense that bash doesn't build for windows, since it's not supported, and it makes sense that makeWrapper depends on bash, since that's how the wrapper is run.

The problem is many packages depend on makeWrapper, including many libraries which also happen to build executables. What should be done about this? Should we build something into makeWrapper that just no-ops when cross-compiling to windows? Is there a way to get that same functionality working on windows?

see also #120076, where i fixed a specific instance of this

To Reproduce
Steps to reproduce the behavior:

  1. build something that uses makeWrapper for windows (e.g. nix-build '<nixpkgs>' --arg crossSystem '{ config = "x86_64-w64-mingw32"; libc = "msvcrt"; }' -A smpeg2
  2. it tries to build "hook", which tries to build bash and fails

Expected behavior
The package would build at least the library. Not sure if the executables are just not workable or if there's some way to get them working on windows.

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.10.27, NixOS, 21.05pre281538.9e377a6ce42 (Okapi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20210326_dd77f71
  • channels(root): "nixos-21.05pre281538.9e377a6ce42, nixos-hardware"
  • channels(qolen): "home-manager"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: makeWrapper
# a list of nixos modules affected by the problem
module:
@Radvendii Radvendii added the 0.kind: bug Something is broken label Apr 26, 2021
@Radvendii Radvendii changed the title makeWrapper on windows makeWrapper doesn't cross-compile to windows Apr 26, 2021
@veprbl veprbl added 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin labels Apr 26, 2021
@Radvendii Radvendii added 6.topic: windows Running, or buiding, packages on Windows and removed 6.topic: darwin Running or building packages on Darwin labels Apr 26, 2021
@FRidh
Copy link
Member

FRidh commented Apr 27, 2021

replace makewrapper with something creating a binary, such as #95569 (https://github.com/FRidh/make-binary-wrapper)

@Radvendii
Copy link
Contributor Author

Ooh, thanks for the tip.
Is the idea there to replace all instances of makeWrapper with makeBinaryWrapper?
Also, how close are we to actually doing that?

@Mindavi
Copy link
Contributor

Mindavi commented Apr 19, 2022

I think it would be nice to convert makeWrapper over to makeBinaryWrapper for the whole of nixpkgs at some point. I feel there's still some discussion going on whether or not we want to do that for everything, but we probably want to since there's also other issues that are solved by makeBinaryWrapper (Darwin shebang issues).

@marius851000
Copy link
Contributor

marius851000 commented Apr 23, 2023

It is easy to replace every makeWrapper by makeBinarywrapper just by replacing the function in all-packages.nix.

It turns out makeBinaryWrapper doesn’t work directly out of the box for Windows, for seemingly 2 different reason:

  1. there is no setenv function on Windows, but there is some equivalent, that can be quite easily put there.
  2. execv seems to behave differently. In particular, it doesn’t seems to pass stdin. I’m trying to make this work with the CreateProcessA functions, but it’s more complicated, and requite generating a string command line where it doesn’t provide a function to convert from argv to an escaped string.

(Turns out execv is not even valid in Windows: https://learn.microsoft.com/en-gb/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: windows Running, or buiding, packages on Windows
Projects
None yet
Development

No branches or pull requests

5 participants