Skip to content

llvmPackages.libclang: add enableClangToolsExtra flag#446207

Merged
emilazy merged 1 commit intoNixOS:masterfrom
LunNova:push-mrwnnkwxxwso
Sep 26, 2025
Merged

llvmPackages.libclang: add enableClangToolsExtra flag#446207
emilazy merged 1 commit intoNixOS:masterfrom
LunNova:push-mrwnnkwxxwso

Conversation

@LunNova
Copy link
Member

@LunNova LunNova commented Sep 26, 2025

rocmPackages needs a clang at runtime, it would be nice to avoid including clang-tools-extra/clang-tidy related files in clang to reduce the runtime closure size of packages that support ROCm.

The approach in this change avoids rebuilds and is messy, I will make a followup in staging that changes this to more idiomatic optionalString usage if this is merged

I've been working on closure size reduction for rocmPackages in #444860 and figured it'd be nicer on reviewers to separate out this clang change.

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 446207 --extra-nixpkgs-config '{ allowAliases = true; }' --package llvmPackages.libclang.tests.withoutOptionalFeatures --package llvmPackages_18.libclang.tests.withoutOptionalFeatures --package llvmPackages_21.libclang.tests.withoutOptionalFeatures --package llvmPackages_git.libclang.tests.withoutOptionalFeatures
Commit: 1f4626619139ff66e420b8446c25e93dc8903b3f


x86_64-linux

✅ 20 packages built:
  • llvmPackages.libclang.tests.withoutOptionalFeatures
  • llvmPackages.libclang.tests.withoutOptionalFeatures.debug (llvmPackages.libclang.tests.withoutOptionalFeatures.debug.debug, llvmPackages.libclang.tests.withoutOptionalFeatures.debug.dev, llvmPackages.libclang.tests.withoutOptionalFeatures.debug.lib, llvmPackages.libclang.tests.withoutOptionalFeatures.debug.python)
  • llvmPackages.libclang.tests.withoutOptionalFeatures.dev (llvmPackages.libclang.tests.withoutOptionalFeatures.dev.debug, llvmPackages.libclang.tests.withoutOptionalFeatures.dev.dev, llvmPackages.libclang.tests.withoutOptionalFeatures.dev.lib, llvmPackages.libclang.tests.withoutOptionalFeatures.dev.python)
  • llvmPackages.libclang.tests.withoutOptionalFeatures.lib (llvmPackages.libclang.tests.withoutOptionalFeatures.lib.debug, llvmPackages.libclang.tests.withoutOptionalFeatures.lib.dev, llvmPackages.libclang.tests.withoutOptionalFeatures.lib.lib, llvmPackages.libclang.tests.withoutOptionalFeatures.lib.python)
  • llvmPackages.libclang.tests.withoutOptionalFeatures.python (llvmPackages.libclang.tests.withoutOptionalFeatures.python.debug, llvmPackages.libclang.tests.withoutOptionalFeatures.python.dev, llvmPackages.libclang.tests.withoutOptionalFeatures.python.lib, llvmPackages.libclang.tests.withoutOptionalFeatures.python.python)
  • llvmPackages_18.libclang.tests.withoutOptionalFeatures
  • llvmPackages_18.libclang.tests.withoutOptionalFeatures.debug (llvmPackages_18.libclang.tests.withoutOptionalFeatures.debug.debug, llvmPackages_18.libclang.tests.withoutOptionalFeatures.debug.dev, llvmPackages_18.libclang.tests.withoutOptionalFeatures.debug.lib, llvmPackages_18.libclang.tests.withoutOptionalFeatures.debug.python)
  • llvmPackages_18.libclang.tests.withoutOptionalFeatures.dev (llvmPackages_18.libclang.tests.withoutOptionalFeatures.dev.debug, llvmPackages_18.libclang.tests.withoutOptionalFeatures.dev.dev, llvmPackages_18.libclang.tests.withoutOptionalFeatures.dev.lib, llvmPackages_18.libclang.tests.withoutOptionalFeatures.dev.python)
  • llvmPackages_18.libclang.tests.withoutOptionalFeatures.lib (llvmPackages_18.libclang.tests.withoutOptionalFeatures.lib.debug, llvmPackages_18.libclang.tests.withoutOptionalFeatures.lib.dev, llvmPackages_18.libclang.tests.withoutOptionalFeatures.lib.lib, llvmPackages_18.libclang.tests.withoutOptionalFeatures.lib.python)
  • llvmPackages_18.libclang.tests.withoutOptionalFeatures.python (llvmPackages_18.libclang.tests.withoutOptionalFeatures.python.debug, llvmPackages_18.libclang.tests.withoutOptionalFeatures.python.dev, llvmPackages_18.libclang.tests.withoutOptionalFeatures.python.lib, llvmPackages_18.libclang.tests.withoutOptionalFeatures.python.python)
  • llvmPackages_21.libclang.tests.withoutOptionalFeatures
  • llvmPackages_21.libclang.tests.withoutOptionalFeatures.debug (llvmPackages_21.libclang.tests.withoutOptionalFeatures.debug.debug, llvmPackages_21.libclang.tests.withoutOptionalFeatures.debug.dev, llvmPackages_21.libclang.tests.withoutOptionalFeatures.debug.lib, llvmPackages_21.libclang.tests.withoutOptionalFeatures.debug.python)
  • llvmPackages_21.libclang.tests.withoutOptionalFeatures.dev (llvmPackages_21.libclang.tests.withoutOptionalFeatures.dev.debug, llvmPackages_21.libclang.tests.withoutOptionalFeatures.dev.dev, llvmPackages_21.libclang.tests.withoutOptionalFeatures.dev.lib, llvmPackages_21.libclang.tests.withoutOptionalFeatures.dev.python)
  • llvmPackages_21.libclang.tests.withoutOptionalFeatures.lib (llvmPackages_21.libclang.tests.withoutOptionalFeatures.lib.debug, llvmPackages_21.libclang.tests.withoutOptionalFeatures.lib.dev, llvmPackages_21.libclang.tests.withoutOptionalFeatures.lib.lib, llvmPackages_21.libclang.tests.withoutOptionalFeatures.lib.python)
  • llvmPackages_21.libclang.tests.withoutOptionalFeatures.python (llvmPackages_21.libclang.tests.withoutOptionalFeatures.python.debug, llvmPackages_21.libclang.tests.withoutOptionalFeatures.python.dev, llvmPackages_21.libclang.tests.withoutOptionalFeatures.python.lib, llvmPackages_21.libclang.tests.withoutOptionalFeatures.python.python)
  • llvmPackages_git.libclang.tests.withoutOptionalFeatures
  • llvmPackages_git.libclang.tests.withoutOptionalFeatures.debug (llvmPackages_git.libclang.tests.withoutOptionalFeatures.debug.debug, llvmPackages_git.libclang.tests.withoutOptionalFeatures.debug.dev, llvmPackages_git.libclang.tests.withoutOptionalFeatures.debug.lib, llvmPackages_git.libclang.tests.withoutOptionalFeatures.debug.python)
  • llvmPackages_git.libclang.tests.withoutOptionalFeatures.dev (llvmPackages_git.libclang.tests.withoutOptionalFeatures.dev.debug, llvmPackages_git.libclang.tests.withoutOptionalFeatures.dev.dev, llvmPackages_git.libclang.tests.withoutOptionalFeatures.dev.lib, llvmPackages_git.libclang.tests.withoutOptionalFeatures.dev.python)
  • llvmPackages_git.libclang.tests.withoutOptionalFeatures.lib (llvmPackages_git.libclang.tests.withoutOptionalFeatures.lib.debug, llvmPackages_git.libclang.tests.withoutOptionalFeatures.lib.dev, llvmPackages_git.libclang.tests.withoutOptionalFeatures.lib.lib, llvmPackages_git.libclang.tests.withoutOptionalFeatures.lib.python)
  • llvmPackages_git.libclang.tests.withoutOptionalFeatures.python (llvmPackages_git.libclang.tests.withoutOptionalFeatures.python.debug, llvmPackages_git.libclang.tests.withoutOptionalFeatures.python.dev, llvmPackages_git.libclang.tests.withoutOptionalFeatures.python.lib, llvmPackages_git.libclang.tests.withoutOptionalFeatures.python.python)

Things done

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

Add a 👍 reaction to pull requests you find important.

@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: llvm/clang Issues related to llvmPackages, clangStdenv and related labels Sep 26, 2025
rocmPackages needs a clang at runtime but has no need to include
clang-tidy.

The approach in this change avoids rebuilds and is messy, I will
make a followup in staging that changes this to more idiomatic
optionalString usage if this is merged
@emilazy
Copy link
Member

emilazy commented Sep 26, 2025

Is a separate output not an option here? That would generally be cleaner, I think. (But of course require going through staging.)

@LunNova
Copy link
Member Author

LunNova commented Sep 26, 2025

Is a separate output not an option here? That would generally be cleaner, I think. (But of course require going through staging.)

That seems like it should be possible but is non-trivial, clang-tools-extra ends up with both headers in $dev/include and absolute paths of clang tidy related static libs and binaries in $dev/lib/cmake/clang.

darwin's bootstrap may be somewhat faster to iterate on with the option to skip building clang-tools-extra as it could be disabled for all but the final stage.

I think the ideal option if we want to do something non-trivial might be going further and trying to put clang-tools-extra in a separate package in llvmPackages.

@emilazy
Copy link
Member

emilazy commented Sep 26, 2025

I think the ideal option if we want to do something non-trivial might be going further and trying to put clang-tools-extra in a separate package in llvmPackages.

Yeah, that would be great. But if it’s a pain I don’t want to block this if others think it’s a good idea. Maybe an incremental step would be to disable building the tools in the first place when this flag is off, since that would be desirable for a split package anyway?

@LunNova
Copy link
Member Author

LunNova commented Sep 26, 2025

But if it’s a pain

clang-tools-extra doesn't have any of the project_BUILT_STANDALONE infra that lld/clang have; seems like it counts as a pain.

Maybe an incremental step would be to disable building the tools in the first place when this flag is off

The diff in this PR should already disable them when that flag's false unless I messed it up. ~600 less build steps and the following files/folders are no longer installed:

-result-1-lib/lib/libclangApplyReplacements.a
-result-1-lib/lib/libclangChangeNamespace.a
-result-1-lib/lib/libclangDaemon.a
-result-1-lib/lib/libclangDaemonTweaks.a
-result-1-lib/lib/libclangdMain.a
-result-1-lib/lib/libclangDoc.a
-result-1-lib/lib/libclangDocSupport.a
-result-1-lib/lib/libclangdRemoteIndex.a
-result-1-lib/lib/libclangdSupport.a
-result-1-lib/lib/libclangIncludeCleaner.a
-result-1-lib/lib/libclangIncludeFixer.a
-result-1-lib/lib/libclangIncludeFixerPlugin.a
-result-1-lib/lib/libclangMove.a
-result-1-lib/lib/libclangQuery.a
-result-1-lib/lib/libclangReorderFields.a
-result-1-lib/lib/libclangTidy.a
-result-1-lib/lib/libclangTidyAbseilModule.a
-result-1-lib/lib/libclangTidyAlteraModule.a
-result-1-lib/lib/libclangTidyAndroidModule.a
-result-1-lib/lib/libclangTidyBoostModule.a
-result-1-lib/lib/libclangTidyBugproneModule.a
-result-1-lib/lib/libclangTidyCERTModule.a
-result-1-lib/lib/libclangTidyConcurrencyModule.a
-result-1-lib/lib/libclangTidyCppCoreGuidelinesModule.a
-result-1-lib/lib/libclangTidyDarwinModule.a
-result-1-lib/lib/libclangTidyFuchsiaModule.a
-result-1-lib/lib/libclangTidyGoogleModule.a
-result-1-lib/lib/libclangTidyHICPPModule.a
-result-1-lib/lib/libclangTidyLinuxKernelModule.a
-result-1-lib/lib/libclangTidyLLVMLibcModule.a
-result-1-lib/lib/libclangTidyLLVMModule.a
-result-1-lib/lib/libclangTidyMain.a
-result-1-lib/lib/libclangTidyMiscModule.a
-result-1-lib/lib/libclangTidyModernizeModule.a
-result-1-lib/lib/libclangTidyMPIModule.a
-result-1-lib/lib/libclangTidyObjCModule.a
-result-1-lib/lib/libclangTidyOpenMPModule.a
-result-1-lib/lib/libclangTidyPerformanceModule.a
-result-1-lib/lib/libclangTidyPlugin.a
-result-1-lib/lib/libclangTidyPortabilityModule.a
-result-1-lib/lib/libclangTidyReadabilityModule.a
-result-1-lib/lib/libclangTidyUtils.a
-result-1-lib/lib/libclangTidyZirconModule.a
-result-1-lib/lib/libfindAllSymbols.a
-result-2-dev/bin/clang-tidy-confusable-chars-gen
-result-2-dev/include/clang-tidy/
-result/bin/clang-apply-replacements
-result/bin/clang-change-namespace
-result/bin/clangd
-result/bin/clang-doc
-result/bin/clang-include-cleaner
-result/bin/clang-include-fixer
-result/bin/clang-move
-result/bin/clang-query
-result/bin/clang-reorder-fields
-result/bin/clang-tidy
-result/bin/find-all-symbols
-result/bin/modularize
-result/bin/pp-trace
-result/bin/run-clang-tidy
-result/share/clang/clang-include-fixer.el
-result/share/clang-doc/

@LunNova
Copy link
Member Author

LunNova commented Sep 26, 2025

@emilazy how do you feel about this attempt at splitting it up?

5a5ad6f#diff-e418126c856bf1baf0bb8e13be497b81adec5a2c76efae030ca666c369c33c4b

@emilazy
Copy link
Member

emilazy commented Sep 26, 2025

Wow, amazing work! That would certainly be great for us if upstream is open to it – but until then I’m happy to go with the current approach here if you still think it’s the best short‐term option, especially with the potential wins for Darwin bootstrap 😅

(I thought we did some funny thing with the monorepo sources that avoided relying on the standalone build infrastructure, but I could be totally wrong there.)

@LunNova
Copy link
Member Author

LunNova commented Sep 26, 2025

Landing the simple flag to turn off clang-tools-extra for now and later trying to upstream proper support for splitting it into a separate project makes the most sense to me.

Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

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

SGTM.

@emilazy emilazy added this pull request to the merge queue Sep 26, 2025
Merged via the queue into NixOS:master with commit 84a03aa Sep 26, 2025
31 of 33 checks passed
@LunNova LunNova deleted the push-mrwnnkwxxwso branch September 28, 2025 06:13
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 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.

2 participants