[clang] [Clang] Make `-Xarch_` handling generic for all toolchains (PR #125421)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 3 11:13:42 PST 2025
jhuber6 wrote:
> > Summary: Currently, `-Xarch_` is used to forward argument specially to certain toolchains. Currently, this is only supported by the Darwin toolchain. We want to be able to use this generically, and for offloading too. This patch moves the handling out of the Darwin Toolchain and places it in the `getArgsForToolchain` helper which is run before the arguments get passed to the tools.
>
> I think this could use some editing. `-Xarch` is intended to set flags per _target_. Same toolchain may handle more than one target. Perhaps rephrase along the lines of "forward argument to the toolchain used for the given target architecture"?
I don't think a single `ToolChain` can have multiple targets in the driver, but you can make separate `ToolChain` objects with a different triple, I think that's where the confusion lies. Right now this is just for the Triple.
> > this is only supported by the Darwin toolchain.
>
> This is the confusing part. I'm pretty sure `-Xarch_host` `-Xarch_device` and variety of `-Xarch_{gfx,sm}..` variants are also supported by HIP/Cuda toolchains right now.
>
> IMO, a better way to describe the situation is that MachO is the last remaining special case implementation of Xarch and the patch folds it into a common `Xarch` handling that's already used by offloading toolchains.
Yeah, I wasn't counting the host / device parts since they're separate flags. We do support the architecture part already but it's a special case that doesn't need to be there. Realistically this is just removing the MachO handling to simplify it and make it work everywhere.
https://github.com/llvm/llvm-project/pull/125421
More information about the cfe-commits
mailing list