Skip to content

lib/systems/parse.nix: add removeAbiSuffix, use it#262838

Merged
Ericson2314 merged 1 commit intomasterfrom
unknown repository
Oct 25, 2023
Merged

lib/systems/parse.nix: add removeAbiSuffix, use it#262838
Ericson2314 merged 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 23, 2023

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • 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/)
  • 23.11 Release Notes (or backporting 23.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.

gnu-config ignores the portion of a triple matching the regex e?abi.*$

In other words, i386-linuxabichickenlips is a valid triple.

This commit updates our parsing routines to match gnu-config.

I was recently surprised to discover that it is in fact possible to shoehorn ABI flavors into nix doubles in a way which preserves their property of being a (non-canonical) subset of the valid gnu-config triples. This commit is required in order to exploit that discovery to add automatic detection of ILP32 platforms (64-bit void*, 32-bit int, like the Apple Watch and MIPS n32) to Nix.

gnu-config will ignore the portion of a triple matching the regex
`e?abi.*$` when determining the validity of a triple.  In other
words, `i386-linuxabichickenlips` is a valid triple.

This commit updates our parsing routines to match gnu-config.

I was recently surprised to discover that it is in fact possible to
shoehorn ABI flavors into nix doubles in a way which preserves their
property of being a (non-canonical) subset of the valid gnu-config
triples.  This commit is required in order to exploit that discovery
to add automatic detection of ILP32 platforms (64-bit void*, 32-bit
int, like the Apple Watch and MIPS n32) to Nix.
@ghost ghost requested review from Ericson2314 and alyssais as code owners October 23, 2023 00:06
@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Oct 23, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Oct 23, 2023
@delroth delroth added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 25, 2023
@Ericson2314
Copy link
Copy Markdown
Member

This commit is required in order to exploit that discovery to add automatic detection of ILP32 platforms (64-bit void*, 32-bit int, like the Apple Watch and MIPS n32) to Nix.

I thought GNU config was handling those in a different (also weird) way?

@Ericson2314
Copy link
Copy Markdown
Member

@Ericson2314 Ericson2314 merged commit 791c147 into NixOS:master Oct 25, 2023
@ghost
Copy link
Copy Markdown
Author

ghost commented Oct 26, 2023

If curious, the hack is:

$ config.sub mips64el-linuxabin32
mips64el-unknown-linux-gnuabin32

Since mips64el-linuxabin32 has only one hyphen, Nix will accept it as a value for builtins.currentSystem.

@ghost ghost deleted the pr/lib/systems/abi-suffix branch October 26, 2023 05:29
@ghost
Copy link
Copy Markdown
Author

ghost commented Oct 26, 2023

https://reviews.llvm.org/D125412

This is so totally frustrating.

gnu-config had support for this six years ago and calls it aarch64-*-*_ilp32. Support was merged to GCC and binutils; the Linux patches to add the ABI did not get merged but Debian was shipping them for a while.

So when LLVM decides to add support in 2022 do they use the same triple? Noooo, they have to do their own thing apparently. So they call it arm64_32-*-*. Which is really bonkers because it isn't a different CPU or even a different mode on a CPU. It's just an ABI change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants