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

python3: add support for netbsd #344157

Closed
wants to merge 1 commit into from
Closed

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Sep 24, 2024

Description of changes

This is needed for NixOS/nix#11566

Things done

  • Built on platform(s)
    • x86_64-linux (pkgsCross.x86_64-freebsd.python3 and pkgsCross.x86_64-netbsd.python3)
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@Mic92 Mic92 requested a review from natsukium as a code owner September 24, 2024 08:10
@Mic92 Mic92 marked this pull request as draft September 24, 2024 08:11
@Mic92 Mic92 marked this pull request as ready for review September 24, 2024 08:47
@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

cc @rhelmot

# Cross compilation only supports a limited number of "known good"
# configurations. If you're reading this and it's been a long time
# since this diff, consider submitting this patch upstream!
./freebsd-cross.patch
Copy link
Member Author

Choose a reason for hiding this comment

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

I also made a PR for cpython + freebsd here: python/cpython#124424

@Mic92 Mic92 requested a review from alyssais September 24, 2024 08:54
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 24, 2024
@alyssais
Copy link
Member

Have you tested the NetBSD binary actually works? Last time I tried this it didn't, which suggests upstream has this disabled for a reason.

@alyssais
Copy link
Member

Why does Nix need a cross compiled Python anyway?

@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

We cannot build libpsl -> libcurl without it:

nix-env % nix build .\#packages.x86_64-linux.nix-x86_64-unknown-netbsd -L --show-trace
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'nix-x86_64-unknown-netbsd-2.25.0pre20240924_dirty'
         whose name attribute is located at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'buildInputs' of derivation 'nix-x86_64-unknown-netbsd-2.25.0pre20240924_dirty'
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:383:7:
          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'curl-x86_64-unknown-netbsd-8.9.1'
         whose name attribute is located at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'propagatedBuildInputs' of derivation 'curl-x86_64-unknown-netbsd-8.9.1'
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:390:7:
          389|       depsHostHostPropagated      = elemAt (elemAt propagatedDependencies 1) 0;
          390|       propagatedBuildInputs       = elemAt (elemAt propagatedDependencies 1) 1;
             |       ^
          391|       depsTargetTargetPropagated  = elemAt (elemAt propagatedDependencies 2) 0;

       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'libpsl-x86_64-unknown-netbsd-0.21.5'
         whose name attribute is located at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'buildInputs' of derivation 'libpsl-x86_64-unknown-netbsd-0.21.5'
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/make-derivation.nix:383:7:
          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … in the condition of the assert statement
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/lib/customisation.nix:352:23:
          351|             drvPath = assert condition; drv.${outputName}.drvPath;
          352|             outPath = assert condition; drv.${outputName}.outPath;
             |                       ^
          353|           } //

       … while evaluating the attribute 'handled'
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/check-meta.nix:507:7:
          506|       # or, alternatively, just output a warning message.
          507|       handled =
             |       ^
          508|         (

       … from call site
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/check-meta.nix:511:13:
          510|           else if valid == "no" then (
          511|             handleEvalIssue { inherit meta attrs; } { inherit (validity) reason errormsg; }
             |             ^
          512|           )

       … while calling 'handleEvalIssue'
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/check-meta.nix:269:38:
          268|
          269|   handleEvalIssue = { meta, attrs }: { reason , errormsg ? "" }:
             |                                      ^
          270|     let

       … while calling the 'throw' builtin
         at /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/stdenv/generic/check-meta.nix:281:8:
          280|         else throw;
          281|     in handler msg;
             |        ^
          282|

       error: Package ‘python3-3.12.5’ in /nix/store/5n0kgjjm07z3gvz912i5gviig1qh4d4w-source/pkgs/development/interpreters/python/cpython/default.nix:675 is not available on the requested hostPlatform:
         hostPlatform.config = "x86_64-unknown-netbsd"
         package.meta.platforms = [
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
           "i686-cygwin"
           "x86_64-cygwin"
           "x86_64-windows"
           "i686-windows"
           "i686-freebsd"
           "x86_64-freebsd"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

I haven't tested the actual interpreter because it's not actually used in nix.
However if basic things like python already don't cross compile than we might need to disable netbsd cross compilation for nix ci.

@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

It's the second time this psl-make-dafsa script makes life as a cross-compiler hard...
I think it would be overall useful not depend on python for libcurl and have the script package separately.

@alyssais
Copy link
Member

Before we've talked about not including the Python parts of libpsl when we can't cross compile Python. Can't we do that?

@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

Before we've talked about not including the Python parts of libpsl when we can't cross compile Python. Can't we do that?

Sure, but I actually, I don't want this dependency at all in libcurl. As far as I can see, no package really needs it.

@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

#344209

@Mic92
Copy link
Member Author

Mic92 commented Sep 24, 2024

Here it's just disabled for cross-compilation: #344211

@Mic92 Mic92 closed this Sep 25, 2024
@Mic92
Copy link
Member Author

Mic92 commented Sep 25, 2024

Opened an issue instead: #344423

@alyssais
Copy link
Member

Sure, but I actually, I don't want this dependency at all in libcurl. As far as I can see, no package really needs it.

Why not just disable it universally then?

@Mic92
Copy link
Member Author

Mic92 commented Sep 25, 2024

I did this here: #344209 feel free to pick or not.

@alyssais
Copy link
Member

I don't understand from that what it's needed for.

@Mic92 Mic92 deleted the python3-netbsd branch September 25, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants