Skip to content

mesa: Only build OpenCL stuff on platforms where it works, fix build on ppc64#456839

Open
OPNA2608 wants to merge 2 commits intoNixOS:masterfrom
OPNA2608:fix/mesa-ppc64
Open

mesa: Only build OpenCL stuff on platforms where it works, fix build on ppc64#456839
OPNA2608 wants to merge 2 commits intoNixOS:masterfrom
OPNA2608:fix/mesa-ppc64

Conversation

@OPNA2608
Copy link
Contributor

@OPNA2608 OPNA2608 commented Oct 29, 2025

OpenCL support doesn't work when building natively on non-LE platforms: https://catfox.life/2024/11/29/the-complexities-of-enabling-opencl-support/

Eventually, the SPIRV stuff that comes before this might need to be marked broken on non-LE just to communicate this properly. But the first place where I've directly stumbled into this is when building mesa.

OpenCL stuff is only needed when building specific drivers, so we need to exclude those when this option is set to false.

(this is untested beyond "it builds", I'm not super familiar with all this stuff)

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • powerpc64-linux (native)
    • 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 other READMEs.

Add a 👍 reaction to pull requests you find important.

@OPNA2608 OPNA2608 added the 6.topic: exotic Exotic hardware or software platform label Oct 29, 2025
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Oct 29, 2025
@nix-owners nix-owners bot requested review from K900 and vcunat October 29, 2025 22:54
@OPNA2608 OPNA2608 changed the base branch from staging to master October 29, 2025 23:02
@nixpkgs-ci nixpkgs-ci bot closed this Oct 29, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Oct 29, 2025
@OPNA2608 OPNA2608 marked this pull request as draft October 30, 2025 13:09
@OPNA2608 OPNA2608 changed the title mesa: Add withOpenCL option, fix build on ppc64 mesa: Only build OpenCL stuff on platforms where it works, fix build on ppc64 Oct 30, 2025
@OPNA2608 OPNA2608 marked this pull request as ready for review October 30, 2025 15:07
@OPNA2608
Copy link
Contributor Author

(Back on a computer, evals again)

@nix-owners nix-owners bot requested a review from gloaming October 30, 2025 15:08
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 16, 2025
@OPNA2608 OPNA2608 marked this pull request as draft December 16, 2025 20:56
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 16, 2025
@OPNA2608 OPNA2608 force-pushed the fix/mesa-ppc64 branch 2 times, most recently from 3445189 to 1f61280 Compare January 1, 2026 18:46
@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Jan 1, 2026

Merge conflicts resolved, and made it build on powerpc64-linux hardware again.

@OPNA2608 OPNA2608 marked this pull request as ready for review January 1, 2026 18:52
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 2, 2026
@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Jan 6, 2026

Resolved merge conflict.

@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 6, 2026
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 27, 2026
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 29, 2026
"zink" # generic OpenGL over Vulkan, experimental
]
# See platformOpenCLWorks
++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform spirv-llvm-translator) [
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if there's a way to DRY this condition. Maybe making it a function argument with a default isn't that bad after all...

Copy link
Contributor Author

@OPNA2608 OPNA2608 Jan 31, 2026

Choose a reason for hiding this comment

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

Would have to move the default list into at least the let block I think?

{
  # ...
  galliumDrivers ? null,
  vulkanDrivers ? null,
  # ...
}:

let
  platformOpenCLWorks = /* ... */;
  galliumDrivers' =
    if galliumDrivers != null then
      galliumDrivers
    else (
      [
        # ...
      ]
      ++ lib.optionals platformOpenCLWorks [
        # ...
      ]
    );
  vulkanDrivers' =
    /* same pattern as above */;
  # ...
in
stdenv.mkDerivation {
  # ...
}

Don't think this it great… but it would DRY this without introducing a function argument.

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Feb 9, 2026

Patches to mesa got merged upstream, switched to fetchpatching them instead.

@K900
Copy link
Contributor

K900 commented Feb 10, 2026

Are those patches only in Mesa main or also 26.0.0? Do you have a link to the PRs? I can ask around about getting them backported so we don't have to ship them.

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Feb 10, 2026

Are those patches only in Mesa main or also 26.0.0?

In main (1, 2), cherry-picked to staging/26.0 (3, 4). You prolly know better than me how their backporting pipeline works, if that's enough etc.

Do you have a link to the PRs?

PR links are in the comments above each fetchpatch call.

@K900
Copy link
Contributor

K900 commented Feb 11, 2026

OK so that means it'll be in 26.0.0 in a few days.

Somewhere in OpenCL-related code (SPIRV-LLVM-Translator at minimum), things go wrong when running `mesa_clc` for OpenCL-using drivers on big-endian:

  Invalid extended instruction import ‘nepOs.LC’

Based on upstream issues and blog posts, the issue is likely in at least SPIRV-LLVM-Translator, so this one will have BE added to
its badPlatforms in the future.

When SPIRV-LLVM-Translator is unavailable, don't bother with any OpenCL stuff.
@OPNA2608
Copy link
Contributor Author

image

Rebased on master for Mesa 26.0.0, dropped fetchpatches of now-shipped fixes.

With the idea from #473862 (comment), pkgsCross.ppc64-elfv1.mesa builds.

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 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants