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

lib.systems.examples: deprecate in preparation for removal #250073

Closed
wants to merge 27 commits into from
Closed

lib.systems.examples: deprecate in preparation for removal #250073

wants to merge 27 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 19, 2023

Migrates pkgsCross to pkgsOn, which does not require a "blessed" list of approved platforms (lib.systems.examples).

  • Before: pkgsCross.aarch64-multiplatform.bash
  • After: pkgsOn.aarch64.unknown.linux.gnu.bash

Tasks

  • Provide pkgsOn
  • Change all uses of pkgsCross to pkgsOn
  • Add lib.warn to pkgsCross
  • Eliminate direct uses of lib.systems.examples
    • The Hydra build scripts use builtins.attrNames lib.systems.examples to pre-populate a cache... migrating this is tricky for me to test correctly.
  • Add lib.warn to lib.systems.examples

Includes:

Note: this doesn't try fix the "cognitive ugliness" of pkgsCross/pkgsOn being "inside" of pkgs. That's an orthogonal problem, which is worth solving but also going to be a harder sell to the community because .pkgsSomething.blah is so syntactically convenient. I don't want that debate to obstruct the removal of lib.systems.examples.

Adam Joseph added 2 commits August 19, 2023 03:15
For almost a decade nixpkgs has parsed `*-*-{cygwin,msvc}` as being
ABIs for a common kernel (windows), rather than as kernels.  It
isn't really reasonable to change nixpkgs' handling at this point,
so this commit replicates the special-case hack when unparsing, in
order to ensure that `(unparse . parse)==id`.
tripleFromSkeleton contains the same logic found in
tripleFromSystem, but is capable of operating on unvalidated
attrsets-of-strings.
Adam Joseph added 25 commits August 19, 2023 03:15
gnu-config does not recognize `none` as a vendor -- that string
describes a *kernel*
Unfortunately gnu-config triples are, in some rare cases, sensitive
to whether the vendor was specified as `unknown` or was omitted.  In
other words, there are situations where these are not handled
exactly the same way:

- `mips-linux-gnu`
- `mips-unknown-linux-gnu`

This commit introduces `lib.systems.tripleFromSystemLossy`, which
returns `"mips-unknown-linux-gnu"` for both of the platforms above.
This is almost always what you want to use.
Since 4aa1ffa we have been shipping
reverse-engineered out-of-tree forks of gcc and binutils for the
Broadcom VC4.  Upstream for those forks chose the nonstandard
`vc4-elf` triple to identify their system.  GNU config rejects this
triple (and all `vc4-*` triples).

This commit deals with the fallout from that.

Mainly this commit ensures that we are consistent in using `vc4-elf`
instead of `vc4-none`, and makes sure that parsing->unparsing
round-trips properly.
GNU config (correctly) considers Solaris to be a BSD, and therefore
appends its version to the kernel name, which should be `solaris2`
not `solaris`.

This commit updates `lib/systems` to do the same.
Each kernel supports only a subset of the universe of possible ABIs.
This commit explicitly lists (opt-in) the allowable abis for each
kernel.  Attempting to parse a kernel with an abi which is not on
the list will fail.  This "search space pruning" is essential to
getting our gnu-config agreement tests down to a manageable set of
test cases.  It also lets us reject nonsense triples instead of
trying to handle them exactly the same way gnu-config does.
In PR #182807 we decided that big-endian PowerPC64 should default to
the new elfv2 ABI.  The implementation in that PR did the defaulting
by adding two lines in the *triple parser*, which is turning out to
be problematic; it means that our parse-then-unparse roundtrip
disagrees with gnu-config.

This commit therefore reverts just those two lines.  If the
defaulting logic needs to be moved elsewhere that should be done.

https://github.com/NixOS/nixpkgs/pull/182807/files#r1234650738
This is required for agreement with gnu-config.
gnu-config doesn't include this.
This commit fixes the logic for handling missing/unknown vendor
fields in triples, and extends it to handle mmix and microblaze
CPU-types.
This commit adds lib/tests/triples.nix, which exhaustively tests
that our platform triple parse-then-unparse round-trip agrees with
gnu-config for all inputs that it accepts (it may -- and does --
reject triples which `gnu-config` accepts).
With this commit, we now parse or reject the following identically
to gnu-config:

- aarch64-solo5-none (accept)
- aarch64-solo5-none-elf (reject)

Closes #165836.
This commit adds support for triples with a missing kernel, rather
than kernel="none".  It also adds a parser case for triples which
have a vendor and abi, but no kernel.

This allows to parse "*-unknown-elf" triples.

Closes #230160.
`kernel=windows` is sort of a nixpkgs-ism; we parse triples
differently than gnu-config but then undo the difference when
unparsing in order to match its behavior.

However when platform objects are constructed internally they don't
have access to this hackery, so we need to permit direct
construction of gnu-config-invalid platform objects in order to
cover this case.
This commit adds `pkgs.pkgsOn`, which serves the same purpose as
`pkgs.pkgsCross`, except that *it does not rely on a
pre-approved/blessed list of acceptable platforms*
(i.e. `lib.systems.examples`).

This is intended to replace `pkgs.pkgsCross` so that
`lib.systems.examples` can be deprecated.
This reverts commit 71e9c903c1bccdb9c94f8e0e28370571815b8950.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: haskell 6.topic: lib The Nixpkgs function library 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: rust 6.topic: systemd 8.has: clean-up 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 10.rebuild-linux: 11-100
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants