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

    <tr>
        <th>Summary</th>
        <td>
            SPARC -target-feature +vis breaks flang build on Linux/sparc64
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

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

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

<pre>
    A 2-stage build with `flang` included is currently broken on Linux/sparc64 with tons of errors like
```
error: current translation unit is compiled with the target feature '+vis' but the AST file 'tools/flang/lib/Parser/CMakeFiles/FortranParser.dir/cmake_pch.hxx.pch' was not
```
I could trace this to the fact that the object file creating is run with `clang-21 -cc1 -triple sparc64-unknown-linux-gnu -emit-obj -target-feature +vis` while the pch generation uses `clang-21 -cc1 -triple sparc64-unknown-linux-gnu -emit-pch` without the `-target-feature +vis`, thus the inconsistency.

Even without `flang`, there are three testsuite regressions showing the same error:
```
  Clang :: ClangScanDeps/modules-symlink.c
  Clang :: ClangScanDeps/prebuilt-modules-in-stable-dirs.c
  Clang :: SemaCXX/warn-unused-local-typedef-serialize.cpp
```
While I managed to get further along with the attached preliminary patch, which adds the missing option for `-emit-pch` and `-emit-llvm` (which fixes the `flang` build), this introduces tons of new regressions instead:
```
  Clang :: ClangScanDeps/module-format.c
  Clang :: ClangScanDeps/modules-pch-common-submodule.c
  Clang :: ClangScanDeps/modules-pch-common-via-submodule.c
  Clang :: ClangScanDeps/modules-pch-dangling.c
  Clang :: ClangScanDeps/modules-pch-imports.c
  Clang :: ClangScanDeps/modules-pch.c
 Clang :: ClangScanDeps/optimize-vfs-pch.m
  Clang :: Index/pch-with-errors.c
  Clang :: PCH/different-diagnostic-level.c
  Clang :: PCH/gch-probe.c
  Clang :: PCH/pch-dir.c
  Clang :: Tooling/pch.cpp
```
Now the `.pch` files are correctly built with `-target-feature +vis`, but the TUs are claimed to be not and I have no idea what's going on.

Fortunately, Solaris/sparcv9 isn't affected because for unknown reasons commit 385311625945e65990bd60bea76a045dcaf3f47b, which introduced `-target-feature +vis`, doesn't pass that option on Solaris.

It seems other targets are less affected because unlike the `sparcv9` case they only enable `-target-feature` with special flags and not in general.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVt9v274R_2vkl4MMmbbs-MEP_qYzFmAbiqXD-jacyJPEhiIFHmXH_euHk-Ska9N23yABDJF3x7vPfe4HMtvGEx2y8o-s_LDAIbUhHmKIqV1UwVwPR1A5J2wIqsE6AxebWsi2Re3QN9m2AOu1GwwZsAx6iJF8cleoYngiD8HD36wfnjN14h6j3m4mAyl4hlADxRgig7NPlBXHbFvM_8VxvMnWx5tNSBE9O0w2eBi8TeN7oeuto9mr1BIkjA0lqAnTEAkytcvUH2fLmdpBNaRR5vj4CWrrxtsUguNMnaZw1MnZKlOnjxiZYqZO93_HJzpZRyJzClGcmC6XxoqA7vCJ_tPrdtk-Py973cpDF2TwIX0X0QPoMDgjgWiC1FqGFEaHatTiGU7uheoL6TR5qCNhsr6RYOPgX9DX4m6uVpBrvYI8Rds7ghnifPBPPlx87gT6vPED5NTZlIfqC-QTQvkrQiM82wIurbwoHvS6hYY8xRltJn7_o4KJWLepDXMCsm3xUzcydQ-pHXgUtF4Hz5YTeX1dCp7F8S9n8i_WviHipEiRAKOEEYkgEScebCKI1ERitsI7bsNFMJUXGDuCG9e-SxjAvdgGuVkfp49Hjf4D9UKHLpjBEed87Zz1T0v9e5U-klRRym-61ktxVY5yYyO_ZeKROrz__DlTpwtGnw9-YDK5Cxpdnq49GapzpmjR2a-01H3_XRD_HrP6AB16bMgI5cYCGaKABeiCb17LB1NC3ZKBPpKznfUYr9BjEl7fC0N0C2jMlJ3OMguOoR9pUoc4ZvbbrKM3r2fOnTs5zNTdZKm2z8Q3Rrw0lLHPZGo_JdQyWJ9iMIMW2blveLr8T0qt50Ro3pnDvA6xw_T_ZPCWuF63u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