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

mesa_noglu: fix build #52772

Merged
merged 2 commits into from Dec 25, 2018
Merged

mesa_noglu: fix build #52772

merged 2 commits into from Dec 25, 2018

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Dec 24, 2018

Motivation for this change

LLVM’s LLVM_TARGETS_TO_BUILD build flag defauls to all, which contains AMDGPU among others. Changes in llvm switched to explicitly listing host and target platforms, excluding the AMDGPU target, which is required for Mesa to build.

I am not sure if passing the extra targets as a string is a good idea but other than keeping a list of all supported targets, I do not really see a solution.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • 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 nox --run "nox-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.

Mesa requires AMDGPU target but previously, we only allowed a pre-defined set
of targets.
@@ -46,6 +46,13 @@ let
optionals stdenv.isLinux (if (stdenv.isAarch32 || stdenv.isAarch64)
then []
else ["intel"] ++ lib.optional enableRadv "radeon");
llvm = llvmPackages.llvm.override {
Copy link
Member

Choose a reason for hiding this comment

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

You can do

llvm.override (old: {
  enableTargets = old.enableTargets ++ [ "AMDGPU" ]; 
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does not seem to work for me: attribute 'enableTargets' missing

Copy link
Member

Choose a reason for hiding this comment

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

Oh right, because callPackage is blind to ? default ugh.

Copy link
Member

Choose a reason for hiding this comment

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

Since mesa is a common package many users will end up with two llvm versions.
For that reason, I would propose to include that target by default.

Copy link
Member

Choose a reason for hiding this comment

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

in pkgs/development/compilers/llvm/7/llvm.nix I would add enableTargets ? [ stdenv.hostPlatform stdenv.targetPlatform "AMDGPU" ]

Copy link
Member

Choose a reason for hiding this comment

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

Ideally with a comment why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mesa uses llvm 6 at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I add it to both, or switch mesa to LLVM 7?

Copy link
Member

@Mic92 Mic92 Dec 24, 2018

Choose a reason for hiding this comment

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

For consistency we can add the target to both but keep llvm6 since as default for mesa since we also use it as default in other places.

Copy link
Member

Choose a reason for hiding this comment

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

For the next release we could look in to making llvm7 the new default since we depend on llvm7 with rustc anyway.

LLVM’s `LLVM_TARGETS_TO_BUILD` build flag defauls to `all`, which contains
`AMDGPU` among others. [1] Changes in llvm [2] switched to explicitly listing
host and target platforms, excluding the AMDGPU target, which is required
for Mesa to build.

[1]: https://github.com/llvm-mirror/llvm/blob/db50b6fe399b8ad8caef80fd8ee77607fb051fa5/CMakeLists.txt#L286-L302
[2]: NixOS#52031
@@ -2,7 +2,9 @@

rec {
llvmBackend = platform:
if platform.parsed.cpu.family == "x86" then
if builtins.typeOf platform == "string" then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. But I still do not like this.

Copy link
Member

@Mic92 Mic92 Dec 24, 2018

Choose a reason for hiding this comment

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

We could stringify our default targets before passing them to the list, then it won't be part of the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the ability to pass platform attribute sets to enabledTargets is useful and convenient. We might want to move the llvm target name to lib/platforms.nix; it already contains gcc keys. Then we might simplify the function to

 llvmBackend = platform:
    if builtins.typeOf platform == "string" then
      platform
    else if stdenv.lib.hasAttrByPath ["llvm" "targetName" ] then
      platform.llvm.targetName
    else
      throw "Unsupported system";

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's a good point. CC @matthewbauer.

@jtojnar
Copy link
Contributor Author

jtojnar commented Dec 25, 2018

Let’s just merge it to unbreak staging and we can discuss the proper fix later.

@jtojnar jtojnar merged commit d406ea6 into NixOS:staging Dec 25, 2018
@jtojnar jtojnar deleted the mesa-noglu-fix branch December 25, 2018 15:08
@veprbl veprbl mentioned this pull request Dec 25, 2018
9 tasks
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

4 participants