Skip to content

Conversation

@jonathonpenix
Copy link
Contributor

@jonathonpenix jonathonpenix commented Jan 7, 2026

LLVM_DISTRIBUTION_COMPONENTS seems to require that each component have
a) install-* and install-*-stripped targets and b) a component associated with
the things to install.

So, there's a few separate changes made to add this support into eld:

  • For each of the components we want to support, add_llvm_install_targets
    is used to create the install* and install-*-stripped targets. I think this
    is the easiest (and a recommended) way to do this.

  • I think eld has five components we need to handle: ld.eld, LW,
    PluginAPIHeaders, linker-script (templates), and YAMLMapParser. Each
    of these had the appropriate install targets and components added, as
    needed. Hopefully I'm not missing any additional components we need to
    consider for distributions.

    It might make sense to more aggressively couple some of these, but I
    think the granularity here matches pretty well with available CMake
    options (to ex: disable the YAMLMapParser) and current toolchains with
    eld included (where the PluginAPIHeaders, templates, etc. may be stripped
    out). So, I left this as-is.

  • A dependency was added between the ld.eld and LW install targets--without
    these ld.eld would always fail at runtime about the missing LW library, if
    only ex: ninja install-ld.eld was run. Which, doesn't seem that helpful.
    So, make ld.eld's install depend on LW's.

Expected usage looks something like:

-DLLVM_DISTRIBUTION_COMPONENTS='...;ld.eld;LW;PluginAPIHeaders;linker-script;YAMLMapParser'

and these items can generally be added/removed based on what people want in
the distribution (modulo ld.eld's dependency on LW).

And, as per the install-* target requirement mentioned above, each of
these components can now be individually installed with ex: install-ld.eld.

Fixes #693

@quic-k
Copy link
Contributor

quic-k commented Jan 7, 2026

will this patch allow me to do ninja install-ld.eld same as ninja install-clang?

@jonathonpenix
Copy link
Contributor Author

Yep!

Playing with this a bit though now that you mention it, it looks like doing just a ninja install-ld.eld doesn't also install LW which kind of breaks things (errors when running eld unless ninja install-LW is also run). Will look at that and see if that can be changed.

@quic-k
Copy link
Contributor

quic-k commented Jan 7, 2026

Yep!

great, this is useful

Playing with this a bit though now that you mention it, it looks like doing just a ninja install-ld.eld doesn't also install LW which kind of breaks things (errors when running eld unless ninja install-LW is also run). Will look at that and see if that can be changed.

probably need to add LW as ld.eld's dependency

@jonathonpenix jonathonpenix marked this pull request as ready for review January 7, 2026 23:56
@jonathonpenix
Copy link
Contributor Author

probably need to add LW as ld.eld's dependency

Yep! I think that works

@quic-seaswara
Copy link
Contributor

quic-seaswara commented Jan 8, 2026

The header files for linker plugin API need to be in the distribution too. How will that work ?

The header files are installed from llvm/tools/eld/include/eld

@jonathonpenix
Copy link
Contributor Author

Oh, whoops. It should just be adding the relevant install targets again (llvm projects do similar things, ex: https://github.com/llvm/llvm-project/blob/de3e9b04178cc8fca77ef6396ba604f47ffdeb6f/clang/CMakeLists.txt#L408-L414) then ex: -DLLVM_DISTRIBUTION_COMPONENTS='...;ld.eld;LW;PluginAPIHeaders'. So, I think that shouldn't be much of an issue/I'll make that change.

As a more general question though, does it make sense that these should all be installed/listed separately? Seems like LW is essentially required by eld and the plugin headers are basically always enabled as far as I can tell (the cache var is FORCE'ed to be on)

LLVM_DISTRIBUTION_COMPONENTS seems to require that each component have
a) install-* and install-*-stripped targets and b) a component associated with
the things to install.

So, there's a few separate changes made to add this support into eld:
- For each of the components we want to support, `add_llvm_install_targets`
  is used to create the install* and install-*-stripped targets. I think this
  is the easiest (and a recommended) way to do this.
- I think eld has five components we need to handle: ld.eld, LW,
  PluginAPIHeaders, linker-script (templates), and YAMLMapParser. Each
  of these had the appropriate install targets and components added, as
  needed. Hopefully I'm not missing any additional components we need to
  consider for distributions.

  It might make sense to more aggressively couple some of these, but I
  think the granularity here matches pretty well with available CMake
  options (to ex: disable the YAMLMapParser) and current toolchains with
  eld included (where the PluginAPIHeaders, templates, etc. may be stripped
  out). So, I left this as-is.
- A dependency was added between the ld.eld and LW install targets--without
  these ld.eld would always fail at runtime about the missing LW library, if
  only ex: `ninja install-ld.eld` was run. Which, doesn't seem that helpful.
  So, make ld.eld's install depend on LW's.

Expected usage looks something like:

`-DLLVM_DISTRIBUTION_COMPONENTS='...;ld.eld;LW;PluginAPIHeaders;linker-script;YAMLMapParser'`

and these items can generally be added/removed based on what people want in
the distribution (modulo ld.eld's dependency on LW).

And, as per the install-* target requirement mentioned above, each of
these components can now be individually installed with ex: install-ld.eld.

Fixes qualcomm#693

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
Copy link
Contributor

@quic-areg quic-areg left a comment

Choose a reason for hiding this comment

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

LGTM

@quic-akaryaki
Copy link
Contributor

I just don't know how this is supposed to work so take my comment with a grain of salt.
Is it true that whoever creates "distributions" needs to know the full list of components to get the "default" i.e. full distribution? So if we ever add a new component, those people will need be alerted, like "we added a new component in eld, please consider if you want it your distribution". Maybe it would be easier create one component (ELD) that includes everything?
I'm just thinking if someone would build and install elf just for YAMLMapParser...

@jonathonpenix
Copy link
Contributor Author

jonathonpenix commented Jan 15, 2026

I just don't know how this is supposed to work so take my comment with a grain of salt. Is it true that whoever creates "distributions" needs to know the full list of components to get the "default" i.e. full distribution? So if we ever add a new component, those people will need be alerted, like "we added a new component in eld, please consider if you want it your distribution". ... I'm just thinking if someone would build and install elf just for YAMLMapParser...

Yep, that is correct. To some degree I think that is just a part of the LLVM_DISTRIBUTION_COMPONENTS model--the person specifying it is expected to understand which components are available and which they want in their final distribution. And, there's not really any requirement that a distribution contain a "reasonable" set of components besides that dependencies for the selected components are satisfied.

Maybe it would be easier create one component (ELD) that includes everything?

Overall, I'm a bit split on this--I do think, as-is, things are a bit verbose and needing to ex: explicitly specify both ld.eld and LW seems a bit unnecessary given that I don't think LW is that helpful outside of ld.eld, and ld.eld requires LW. But:

  • This level of granularity mirrors how some past toolchains have interacted with eld (ex: plugin headers included in the normal build/install, but stripped from the final distribution). It's unclear to me if that was an intentional decision, but that was the behavior IIUC--not sure how important this is to preserve.
  • There are some components that I think ex: CPULLVM wouldn't want. The linker-script templates for example are not helpful for us--as-is we can drop this from the distribution. As mentioned above, past toolchains haven't actually distributed the plugin headers (but eld FORCEs these on)--unclear to me what behavior we want going forward. But, I think ex: making these regular options that could be excluded from both the normal install and install-distribution targets would be ok too (and having just the singular eld install-distribution target)

@quic-seaswara and others, do you have thoughts here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compatibility with LLVM_DISTRIBUTION_COMPONENTS

5 participants