Skip to content

systemd: Detect ELF ABI version for bpf build on powerpc64#426919

Merged
flokli merged 1 commit intoNixOS:masterfrom
OPNA2608:fix/systemd-bpf-ppc64-elfv1
Jul 30, 2025
Merged

systemd: Detect ELF ABI version for bpf build on powerpc64#426919
flokli merged 1 commit intoNixOS:masterfrom
OPNA2608:fix/systemd-bpf-ppc64-elfv1

Conversation

@OPNA2608
Copy link
Contributor

With the BPF feature enabled, SystemD assumes that ELFv2 ABI will be used on 64-bit POWER:

https://github.com/systemd/systemd/blob/879ed340a1e80ab64890f8f473df406fd0c80b76/meson.build#L1731

On ELFv1, this causes a compilation failure. Patch this so it no longer means ELFv2. The check for this is usually defined(_CALL_ELF) && _CALL_ELF == 2, so setting the define to 1 should do the trick.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • powerpc64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and others READMEs.

Add a 👍 reaction to pull requests you find important.

@OPNA2608 OPNA2608 added the 6.topic: exotic Exotic hardware or software platform label Jul 20, 2025
@nixpkgs-ci nixpkgs-ci 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. 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. labels Jul 20, 2025
@OPNA2608 OPNA2608 force-pushed the fix/systemd-bpf-ppc64-elfv1 branch from 824cad0 to 3418f05 Compare July 20, 2025 13:22
@arianvp
Copy link
Member

arianvp commented Jul 21, 2025

This feels like this should be a patch to systemd's meson.build instead? Why don't we send them a PR with these changes?

We can make sure they get backported 257. That's not an issue.

@OPNA2608
Copy link
Contributor Author

That'll need abit more work then, because _CALL_ELF=2 by itself isn't wrong… depending on the ABI that the compiler is built to (be able to) target. Can try.

@arianvp
Copy link
Member

arianvp commented Jul 23, 2025

Just to explain: Our philosophy is to only accept patches that are required to make systemd work with the nix package manager and the nix store. This way we keep our maintenance burden low. If this is fixing a bug in systemd then I would highly prefer you either open an issue or a pull request there.

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Jul 23, 2025

Makes sense!

Will convert this to a draft for now, just so I don't forget about this matter.

Why don't we send them a PR with these changes?

Moved the decision of what ABI version to use into the Meson code, and submitted it upstream: systemd/systemd#38307

@OPNA2608 OPNA2608 marked this pull request as draft July 23, 2025 10:20
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 24, 2025
@flokli
Copy link
Member

flokli commented Jul 25, 2025

@OPNA2608 the upstream PR already landed, I asked about it being backported to 257.x in systemd/systemd#38307 (comment).

In the meantime, can you update this PR to be a lib.optionals fetchpatch'ed https://github.com/systemd/systemd/commit/b676aeaee18044f51f9644d8e5ae4e7497581a44.patch, including a link to systemd/systemd#38307 (comment) in a comment above.

Considering the upstream PR is already merged, the URL won't disappear, and if it stays conditionalized on the platform it could go to master directly, without a staging round.

@OPNA2608 OPNA2608 force-pushed the fix/systemd-bpf-ppc64-elfv1 branch from 3418f05 to 3742a72 Compare July 26, 2025 11:14
@OPNA2608 OPNA2608 changed the title systemd: Change _CALL_ELF value for ELFv1 ppc64 systemd: Detect ELF ABI version for bpf build on powerpc64 Jul 26, 2025
@OPNA2608 OPNA2608 marked this pull request as ready for review July 26, 2025 11:16
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 26, 2025
@OPNA2608
Copy link
Contributor Author

Done, though I opted to use systemd/systemd@f950919 instead, which is the commit that's actually in the upstream repository now.

@flokli
Copy link
Member

flokli commented Jul 26, 2025

I assume you're building natively?

I tried pkgsCross.ppc64-elfv1.systemdMinimal, but it fails with ncurses and kexec-tools…

@OPNA2608
Copy link
Contributor Author

I assume you're building natively?

I'm building natively yeah.

I tried pkgsCross.ppc64-elfv1.systemdMinimal

systemdMinimal doesn't enable withLibBPF, so it won't actually test what the patch is doing.

it fails with ncurses and kexec-tools…

You can give this branch a try if you want, but I haven't checked if there are any cross-specific issues anywhere: https://github.com/OPNA2608/nixpkgs/tree/wip/ppc64-elfv1.

Fixes for these packages are submitted to Nixpkgs in #427495 and #422007 respectively. You can find some more submitted ones by searching is:open is:pr author:OPNA2608 powerpc64. I think there should be enough submitted already that you're able to build up to systemd if you apply the PRs locally, and maybe cherry-pick some things that already landed in staging.

@flokli
Copy link
Member

flokli commented Jul 27, 2025

I tried pkgsCross.ppc64-elfv1.systemdMinimal

systemdMinimal doesn't enable withLibBPF, so it won't actually test what the patch is doing.

Yeah, this was more of a "I don't even get past systemdMinimal".

it fails with ncurses and kexec-tools…

You can give this branch a try if you want, but I haven't checked if there are any cross-specific issues anywhere: https://github.com/OPNA2608/nixpkgs/tree/wip/ppc64-elfv1.

Fixes for these packages are submitted to Nixpkgs in #427495 and #422007 respectively. You can find some more submitted ones by searching is:open is:pr author:OPNA2608 powerpc64. I think there should be enough submitted already that you're able to build up to systemd if you apply the PRs locally, and maybe cherry-pick some things that already landed in staging.

I'll try to chery-pick things together later, thanks!

@flokli
Copy link
Member

flokli commented Jul 29, 2025

With da9a49a, then #427495 and #422007, and this one cherry-picked on top, I was able to successfully compile all the way up to nix-build -A pkgsCross.ppc64-elfv{1,2}.systemd (from aarch64-linux), but building pkgsCross.ppc64-elfv{1,2}.systemd itself still fails:

       > meson.build:1114:28: ERROR: Command `/nix/store/2z38g8x06c0sliq48ajpq7z1d9pa6q97-powerpc64-unknown-linux-gnuabielfv2-clang-wrapper-19.1.7/bin/powerpc64-unknown-linux-gnuabielfv2-clang --version` failed with status 1.

@OPNA2608
Copy link
Contributor Author

[...]clang --version` failed with status 1

Can you give the errors that running this command interactively is causing? I imagine this is likely Clang not recognising the explicit ABI part of the target triplet and erroring out when it tries to interpret the value as something different. Try applying #297425 if that's the case.

@flokli
Copy link
Member

flokli commented Jul 30, 2025

[...]clang --version` failed with status 1

Can you give the errors that running this command interactively is causing? I imagine this is likely Clang not recognising the explicit ABI part of the target triplet and erroring out when it tries to interpret the value as something different. Try applying #297425 if that's the case.

Yup:

❯ /nix/store/2z38g8x06c0sliq48ajpq7z1d9pa6q97-powerpc64-unknown-linux-gnuabielfv2-clang-wrapper-19.1.7/bin/powerpc64-unknown-linux-gnuabielfv2-clang --version
clang: error: version 'abielfv2' in target triple 'powerpc64-unknown-linux-gnuabielfv2' is invalid
clang version 19.1.7
Target: powerpc64-unknown-linux-gnuabielfv2
Thread model: posix
InstalledDir: /nix/store/zxyvh8psxzbidvskh8cqn8dvxagz1lkl-clang-19.1.7/bin

… and cherry-picking #297425 fixes that, thanks!

@flokli
Copy link
Member

flokli commented Jul 30, 2025

With all these other PRs, now both pkgsCross.ppc64-elfv{1,2}.systemd succeeds in building. Thanks!

@flokli flokli merged commit 1cbe084 into NixOS:master Jul 30, 2025
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: exotic Exotic hardware or software platform 6.topic: systemd Software suite that provides an array of system components for Linux operating systems. 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.

3 participants