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

llvmPackages: Drop buildLlvmTools from llvm package derivations #359967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pwaller
Copy link
Contributor

@pwaller pwaller commented Nov 28, 2024

This an RFC in the form of a patch.

I've noticed that if you try to build a (buildPlatform != hostPlatform)
llvmPackages which aren't available via hydra, you incur a build of
LLVM.

(For example, pkgsStatic.llvmPackages_git.llvm does two builds of LLVM).
(OK, bad example, because it turns out llvmPackages_git is built by hydra! I didn't know that when I first wrote the message; However, if you change the hash of the compiler built, then it would result in a double build).

LLVM has the capability of cross-building an llvm-tblgen internally. And
tablegen is relatively cheap to rebuild, only requiring 8 CPU minutes or
so to build. LLVM is much more expensive to build.

So I propose to drop LLVM_TABLEGEN_EXE and related variables and let the
LLVM build system do its thing. It does mean that a buildPlatform
llvm-tblgen will get built (and discarded) repeatedly in different
derivations (e.g. in .llvm and .clang), but at least it is less
expensive than building LLVM and Clang twice.

Note that I haven't interfered with the cross compiler wrapper logic,
I think buildLlvmTools must remain there, only the llvm packages
themselves.

Signed-off-by: Peter Waller [email protected]

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

This an RFC in the form of a patch.

I've noticed that if you try to build a (buildPlatform != hostPlatform)
llvmPackages which aren't available via hydra, you incur a build of
LLVM.

(For example, pkgsStatic.llvmPackages_git.llvm does two builds of LLVM).

LLVM has the capability of cross-building an llvm-tblgen internally. And
tablegen is relatively cheap to rebuild, only requiring 8 CPU minutes or
so to build. LLVM is much more expensive to build.

So I propose to drop LLVM_TABLEGEN_EXE and related variables and let the
LLVM build system do its thing. It does mean that a buildPlatform
llvm-tblgen will get built (and discarded) repeatedly in different
derivations (e.g. in .llvm and .clang), but at least it is less
expensive than building LLVM and Clang twice.

Note that I haven't interfered with the cross compiler wrapper logic,
I think buildLlvmTools must remain there, only the llvm packages
themselves.

Signed-off-by: Peter Waller <[email protected]>
@github-actions github-actions bot added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label Nov 28, 2024
@pwaller
Copy link
Contributor Author

pwaller commented Nov 28, 2024

Another option could be to do a build of just tablegen in its own derivation, for a sort of best of both worlds with the tradeoff 🤔, but this would also mean a small amount of repeat building for the things which go into tablegen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant