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

rpm: add openmp when building with clang #97630

Merged
merged 1 commit into from Sep 10, 2020
Merged

Conversation

treed
Copy link
Contributor

@treed treed commented Sep 10, 2020

The Darwin build has been broken with a missing header file "omp.h";
llvmPackages.openmp provides it.

I'm unsure why this isn't necessary on Linux.

Motivation for this change

This fixes a broken build on Darwin, as part of ZHF for 20.09.

ZHF: #97479

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@treed
Copy link
Contributor Author

treed commented Sep 10, 2020

This is my first attempt to contribute to Nix. I'm unsure if pulling in llvmPackages like that is the correct thing, and am generally open to feedback. :)

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Sep 10, 2020
@ofborg ofborg bot requested a review from copumpkin September 10, 2020 05:31
@risicle
Copy link
Contributor

risicle commented Sep 10, 2020

I'm unsure why this isn't necessary on Linux.

The default compiler on linux is gcc, on darwin it's clang.

I'm unsure if pulling in llvmPackages like that is the correct thing

It's no massive sin, it's just in this case instead of making this conditional on stdenv.isDarwin, I'd instead test stdenv.cc.isClang, because it means if some linux person tries to build this with clang it'll work. Probably.

Or if a darwin person tries to build it with gcc, I guess...

@risicle
Copy link
Contributor

risicle commented Sep 10, 2020

Also, welcome!

The Darwin build has been broken with a missing header file "omp.h";
llvmPackages.openmp provides it.

Including this library is only necessary when clang is used.
@treed
Copy link
Contributor Author

treed commented Sep 10, 2020

The default compiler on linux is gcc, on darwin it's clang.

Ah, yes. That would explain it. It might also explain a few other failures I saw when looking through the Darwin build failures that looked like syntax errors. I bet they only compile with gcc.

I'd instead test stdenv.cc.isClang, because it means if some linux person tries to build this with clang it'll work. Probably.

And, yeah, that then seems the reasonable answer. Thanks!

I've made the change locally and am rebuilding it to verify; I'll push an update shortly.

@treed treed changed the title rpm: add openmp on darwin rpm: add openmp when building with clang Sep 10, 2020
@risicle
Copy link
Contributor

risicle commented Sep 10, 2020

You'll probably find that it won't rebuild because it will evaluate down to exactly the same thing.

@risicle risicle merged commit 140b871 into NixOS:master Sep 10, 2020
@risicle risicle added the 9.needs: port to stable A PR needs a backport to the stable release. label Sep 10, 2020
@treed
Copy link
Contributor Author

treed commented Sep 10, 2020

Yeah, I had to rm the result and garbage collect to force it to rebuild. Thanks for the advice and the merge!

@risicle
Copy link
Contributor

risicle commented Sep 10, 2020

In such cases, you don't generally need to bother with a rebuild. In weird cases where you do (maybe debugging a randomly unreliable build?) you can use nix-build's --check flag.

@treed
Copy link
Contributor Author

treed commented Sep 10, 2020

Ah, cool. I thought that might be the case but wanted to be certain I wasn't breaking anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 9.needs: port to stable A PR needs a backport to the stable release. 10.rebuild-darwin: 11-100 10.rebuild-linux: 0 12. first-time contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants