Skip to content

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Sep 11, 2025

Summary:
Currently the runtimes builds works by creating separate CMake projects
that build the respetive runtime. Right now we have a separate handling
for the 'default' target and manually specific runtimes via the
-DLLVM_RUNTIME_TARGETS option.

This patch changes the behavior to put all runtimes through the
LLVM_RUNTIME_TARGETS pipeline. The old "default" argument is now a
shorthand for LLVM_DEFAULT_TARGET_TRIPLE and corresponds to a sane
default.

In practical terms, this means the old runtimes-bins directory will
now be runtimes-x86_64-unknown-linux-gnu-bins for the majority of
users. We will not have check-<name> targets, but I have made
a top-level target that invokes all of the enabled targets check lines
to keep this backward compatible. So ninja check-cxx will still work.

There's likely some edge cases I missed here, but it seems to work in
the typical case for me. We'll see what CI thinks of this.

Fixes: #98897

@jhuber6 jhuber6 added llvm Umbrella label for LLVM issues cmake Build system in general and CMake in particular labels Sep 11, 2025
Summary:
Currently the runtimes builds works by creating separate CMake projects
that build the respetive runtime. Right now we have a separate handling
for the 'default' target and manually specific runtimes via the
`-DLLVM_RUNTIME_TARGETS` option.

This patch changes the behavior to put all runtimes through the
`LLVM_RUNTIME_TARGETS` pipeline. The old `"default"` argument is now a
shorthand for `LLVM_DEFAULT_TARGET_TRIPLE` and corresponds to a sane
default.

In practical terms, this means the old `runtimes-bins` directory will
now be `runtimes-x86_64-unknown-linux-gnu-bins` for the majority of
users. We will not have `check-<name>-<triple>` targets, but I have made
a top-level target that invokes all of the enabled targets check lines
to keep this backward compatible.

There's likely some edge cases I missed here, but it seems to work in
the typical case for me. We'll see what CI thinks of this.
@mgorny
Copy link
Member

mgorny commented Sep 13, 2025

Oh, that's llvm/runtimes and not top-level runtimes, so I guess it won't affect Gentoo.

@jhuber6
Copy link
Contributor Author

jhuber6 commented Sep 13, 2025

Oh, that's llvm/runtimes and not top-level runtimes, so I guess it won't affect Gentoo.

Yes, ideally this change doesn't affect anyone that isn't depending on the name of directories in the build tree. Fundamentally I'm hoping to make our runtimes infrastructure more predictable by removing this weird disconnect we have between the generic and specific targets. More or less, this change is equivalent to the user putting -DRUNTIME_TARGETS=${LLVM_DEFAULT_TARGET_TRIPLE}. I want to keep the functionality of default because it's very important that things like cache files can target the user's default system.

I added the check targets to give an interface that looks the same as what we have now for the majority of users.

set(install-${runtime_name}-${name}-stripped install-${runtime_name}-stripped)
list(APPEND ${name}_extra_targets ${runtime_name}-${name} install-${runtime_name}-${name} install-${runtime_name}-${name}-stripped)
if(LLVM_INCLUDE_TESTS)
set(check-${runtime_name}-${name} check-${runtime_name} )
Copy link
Member

Choose a reason for hiding this comment

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

[nit] unrelated change

@jhuber6
Copy link
Contributor Author

jhuber6 commented Sep 18, 2025

Ping, I'm hoping this change is NFC in practice. Also I forgot to mention that this solves #98897.

@petrhosek
Copy link
Member

Ping, I'm hoping this change is NFC in practice. Also I forgot to mention that this solves #98897.

Unfortunately it's not, this change would break builds on Apple platforms because they don't use target triple for building runtimes, that's the reason why the default target was originally introduced. I have an idea for addressing this but that's going to require more significant changes to the build and Clang.

@jhuber6
Copy link
Contributor Author

jhuber6 commented Sep 19, 2025

Ping, I'm hoping this change is NFC in practice. Also I forgot to mention that this solves #98897.

Unfortunately it's not, this change would break builds on Apple platforms because they don't use target triple for building runtimes, that's the reason why the default target was originally introduced. I have an idea for addressing this but that's going to require more significant changes to the build and Clang.

Interesting, could you elaborate on this? As far as I understand, each target has a default target triple. The main difference here is the directory naming and the fact that it passes --target= to the internal CMake job. Is this the part that causes issues? Whatever solution we end up with it will be very important that users can use default or similar to target the user's default environment, because we'd want to provide build scripts and cache files that don't require users to fully understand the concept of an LLVM triple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular llvm Umbrella label for LLVM issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Runtimes] Builtins target forces runtime targets to reconfigure every build
4 participants