<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/97517>97517</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang: Support for `-Xassembler -target-feature`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alexrp
      </td>
    </tr>
</table>

<pre>
    Zig needs the ability to pass target features along to the integrated assembler - see https://github.com/ziglang/zig/issues/10411.

For C files, Zig uses `-Xclang -target-feature`. For assembly, the only option at the moment is to switch to `clang -cc1as` but that would require massive surgery in Zig's driver code since it has a shared code path (with tons of logic) for both at the moment.

There is a very simple change that would solve this headache: Update Clang's [`CollectArgsForIntegratedAssembler()`](https://github.com/llvm/llvm-project/blob/6a992bc89f5ca25d132abd044d78ecf27ae6e162/clang/lib/Driver/ToolChains/Clang.cpp#L2464) to accept `-target-feature` and pass it along. (Or even pass *anything* along, as `-Xclang` [does](https://github.com/llvm/llvm-project/blob/6a992bc89f5ca25d132abd044d78ecf27ae6e162/clang/lib/Driver/ToolChains/Clang.cpp#L7553).)

Alternatively, if `-Xassembler` has to be kept GNU-compatible only, we could imagine adding a new `-Xclangas` that just passes the arguments through like `-Xclang`.

Would either of these options be acceptable? If so, I could probably do a PR.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlE-P5DQQxT-N-1LqluP8P-TQO6OgkRAg2BWIW8WuJN5128F2emg-PXLSO0wLhMSNS3cSx86r935VGIKeLFHHyg-sfD7gGmfnOzT0u18Og1O37lc9gSVSAeJMgIM2Ot4gOlgwBIjoJ4owEsbVUwA0zk5pNb2sbaTJYyQFGAJdBkMejhCIYI5xCSw_M9Ez0U86zutwku7CRP-Hngzaab9iotchrBSY6DNeZNmJ8WfGz_tv7zw8wahNWn-CJHUNFIBV_PiLTKfAcVd4vCtkFT9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