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

Fixes meson for systemd-boot AArch64 cross-build #61847

Closed
wants to merge 3 commits into from

Conversation

samueldr
Copy link
Member

@samueldr samueldr commented May 22, 2019

Note about cpu_family:

As documented, it should be aarch64 for AArch64.

 $ nix eval '((import <nixpkgs> {}).pkgsCross.aarch64-multiplatform.stdenv.targetPlatform.parsed.cpu.family)'
"arm"

This explains the new conditional. family seems fine for at least
x86_64, i686 and armv7.


This should be merged together with #61321; dropping the systemd AArch64 change on one of the PRs.

Things done

This was tested when rebased on nixos-unstable. In the current state of staging, something (glib) doesn't build for at-leat cross-compilation, it looks like.

  • ☑️ Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • ☑️ NixOS
    • 🔲 other Linux distributions
  • 🔲 Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 🔲 Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • 🔲 Tested execution of all binary files (usually in ./result/bin/)
  • 🔲 Determined the impact on package closure size (by running nix path-info -S before and after)
  • ☑️ Assured whether relevant documentation is up to date
  • ☑️ Fits CONTRIBUTING.md.

cc @andir

@samueldr samueldr mentioned this pull request May 22, 2019
10 tasks
@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label May 22, 2019
@matthewbauer
Copy link
Member

It looks like it's incorrect for x86_64 as well? parsed.cpu.family gives x86 but it looks like meson expected x86_64.

@samueldr
Copy link
Member Author

Oops! You're right, that's bad sleuthing on my part.

Do you have an alternative to special casing both of those? It seems a bit clunky.


[properties]
needs_exe_wrapper = true

[host_machine]
system = '${targetPackages.stdenv.targetPlatform.parsed.kernel.name}'
cpu_family = '${targetPackages.stdenv.targetPlatform.parsed.cpu.family}'
# http://mesonbuild.com/Reference-tables.html#cpu-families
cpu_family = '${if targetPackages.stdenv.isAarch64 then "aarch64" else targetPackages.stdenv.targetPlatform.parsed.cpu.family}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Peeking at lib/systems/parse.nix, targetPackages.stdenv.targetPlatform.parsed.cpu.name looks more correct in most cases - for example, for riscv32 and riscv64 targetPackages.stdenv.targetPlatform.parsed.cpu.family is just riscv, but targetPackages.stdenv.targetPlatform.parsed.cpu.name is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct for x86_64 too - x86 would need to be special-cased, given cpu.name is i686 there, and while it might work, it's not guaranteed to stay, according to meson docs.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not guaranteed to stay, according to meson docs.

I'm not sure I follow, I don't see anything special about x86 in their docs, but I don't really know where too look.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I would make the condition something like:

if targetPackages.stdenv.targetPlatform.isAarch32 then "arm"
else targetPackages.stdenv.targetPlatform.parsed.cpu.name

there's a few more cases like powerpc, riscv, that we probably should handle, but this will take care of most cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wanted to suggest using ….cpu.name for mesons cpu_family instead of what we get from ….cpu.family, as it seemed to fit better.

I did take a closer look:

….cpu.name is correct for the following meson CPU families:

  • aarch64
  • riscv32
  • riscv64

….cpu.name is wrong for the following meson CPU families

  • 32 bit arm flavours (the armv7*) ones at least
  • i686 instead of x86
  • powerpc / powerpcle instead of ppc
  • `armv7l

I ignored the ones not available in nixpkgs via pkgsCross.

In general, this looks very messy, and hard to test / ensure to keep working.

I'd suggest to instead provide a fixed lookup table / lookup attrset in the meson drv, translating from parsed.cpu.name to mesons cpu_family.

Copy link
Member Author

@samueldr samueldr May 23, 2019

Choose a reason for hiding this comment

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

You replied just as I was pushing a new revision :). Yeah I think the attrset approach might end up being better considering the different discrepancies.

Should the attrset only implement overrides from cpu.name, a missing attribute assumed to be the value of cpu.name or should the attrset list all known values, and a missing attribute be a throw?

As documented, it should be `aarch64` for AArch64.

 * https://mesonbuild.com/Reference-tables.html#cpu-families

```
 $ nix eval '((import <nixpkgs> {}).pkgsCross.aarch64-multiplatform.stdenv.targetPlatform.parsed.cpu.family)'
"arm"
```

The lookup table will ensure that, at any point, meson does not pick the
wrong family.
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

This looks good now. Thanks!

@andir
Copy link
Member

andir commented May 26, 2019 via email

@samueldr
Copy link
Member Author

Leaving the PR up as a draft until #61321 is finalized and merged (I think if the PR body says it closes #61847 this PR will be closed automatically).

@flokli
Copy link
Contributor

flokli commented May 27, 2019

@samueldr isn't this relatively independent from each other? Or do we just want to avoid one world rebuild and merge this in together with the systemd bump for that reason?

@samueldr
Copy link
Member Author

It's to avoid the rebuild. Though in practice the meson changes could go in. I think it could even go in to master since it should be a no-op for native builds. So, I guess I leave that to @andir depending on how he wants to proceed.

@andir
Copy link
Member

andir commented May 28, 2019

@samueldr Go ahead an merge it into master. I am all for having changes outside of the systemd PR, if they make sense on their own. I'll happily rebase my PR a few more times if that means we can get changes into nixpkgs incrementally without a big bang change :-)

@samueldr
Copy link
Member Author

samueldr commented May 28, 2019

Closing in favor of a PR targeting master.

@samueldr samueldr closed this May 28, 2019
@samueldr samueldr deleted the fix/meson-systemd-cross branch May 28, 2019 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants