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

    <tr>
        <th>Summary</th>
        <td>
            CLang produces error on compiling assembly files when using plugins like polly
        </td>
    </tr>

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

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

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

<pre>
    Suppose we have a simple test program called test.cxx and we have polly built dynamically along with LLVM (with `LLVM_POLLY_LINK_INTO_TOOLS=OFF`):

```
#include <iostream>

int main() {
        std::cout << "Hello world!" << std::endl;
        return 0;
}
```
Compiling it with `clang++ -fplugin=LLVMPolly.so -mllvm -polly -mllvm -polly-parallel -o test test.cxx` works as expected, but what happens when compiling assembly?

To test it, we create our test assembly `test.S` with `clang++ -fplugin=LLVMPolly.so -mllvm -polly -mllvm -polly-parallel -S -c -o test.S test.cxx` and then we try to compile `test.S` as object, then we get:

```
clang++ -fplugin=LLVMPolly.so -mllvm -polly -mllvm -polly-parallel -c -o test.S.o test.S 
clang (LLVM option parsing): Unknown command line argument '-polly'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--color'?
clang (LLVM option parsing): Unknown command line argument '-polly-parallel'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--ppc-gen-isel'?
```

It seems that it is not loading the plugin and not recognizing the options that worked in previous phases (I assume because they are not needed/used when compiling assembly)

I think this is a bug because in this case it is much better to load and ignore plugin rather than throw an error because polly use flag might be present in `C{XX}FLAGS` making the whole program to fail compile.

One real example of it is the LLVM library itself which when polly flags are used fails to compile with:

```
[126/3501 (  3%)] /usr/lib/ccache/bin/clang -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm_build-abi_x86_64.amd64/lib/Support/BLAKE3 -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm/lib/Support/BLAKE3 -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm_build-abi_x86_64.amd64/include -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm/include  -DNDEBUG -O2 -pipe -march=native -Wno-unused-command-line-argument -O3 -fplugin=LLVMPolly.so -mllvm -polly -mllvm -polly-parallel -mllvm -polly-vectorizer=stripmine -mllvm -polly-run-dce -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-scheduling=dynamic -mllvm -polly-num-threads=32 -mllvm -polly-omp-backend=LLVM -mllvm -polly-invariant-load-hoisting -fopenmp -flto=thin -fPIC -MD -MT lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o -MF lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o.d -o lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o -c /tmp/portage/sys-devel/llvm-18.1.3/work/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
FAILED: lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o 
/usr/lib/ccache/bin/clang -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm_build-abi_x86_64.amd64/lib/Support/BLAKE3 -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm/lib/Support/BLAKE3 -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm_build-abi_x86_64.amd64/include -I/tmp/portage/sys-devel/llvm-18.1.3/work/llvm/include  -DNDEBUG -O2 -pipe -march=native -Wno-unused-command-line-argument -O3 -fplugin=LLVMPolly.so -mllvm -polly -mllvm -polly-parallel -mllvm -polly-vectorizer=stripmine -mllvm -polly-run-dce -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-scheduling=dynamic -mllvm -polly-num-threads=32 -mllvm -polly-omp-backend=LLVM -mllvm -polly-invariant-load-hoisting -fopenmp -flto=thin -fPIC -MD -MT lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o -MF lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o.d -o lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_sse2_x86-64_unix.S.o -c /tmp/portage/sys-devel/llvm-18.1.3/work/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
clang (LLVM option parsing): Unknown command line argument '-polly'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--color'?
clang (LLVM option parsing): Unknown command line argument '-polly-parallel'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--ppc-gen-isel'?
clang (LLVM option parsing): Unknown command line argument '-polly-vectorizer=stripmine'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--slp-vectorize-hor=stripmine'?
clang (LLVM option parsing): Unknown command line argument '-polly-run-dce'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--unroll-runtime'?
clang (LLVM option parsing): Unknown command line argument '-polly-scheduling-chunksize=1'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--cache-line-size=1'?
clang (LLVM option parsing): Unknown command line argument '-polly-scheduling=dynamic'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--post-RA-scheduler=dynamic'?
clang (LLVM option parsing): Unknown command line argument '-polly-num-threads=32'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--xcore-max-threads=32'?
clang (LLVM option parsing): Unknown command line argument '-polly-omp-backend=LLVM'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--pre-RA-sched=LLVM'?
clang (LLVM option parsing): Unknown command line argument '-polly-invariant-load-hoisting'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--licm-control-flow-hoisting'?
```

For more info look the [Gentoo PR](https://github.com/gentoo/gentoo/pull/36158) I did for trying to package `Polly` for Gentoo
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWdlu4zrSfhr6pkDDprxe-CK2ov6N48RBnP7nzJVBSWWJY4oUSCqO--kHpJcsp9NngI4RDCZBIJhb1feRtYni1opCIU5If0r6cYs3rtRmsnLaVNO9w7u7Vqrz_WTV1LW2CDuEkj8icLCiqiWCQ-ugNrowvIKMS4l56GtnT0_AVX5eUWsp95A2QjrI94pXws_eA5daFbATroTF4v9vgLBRaJBBx7fXd8vF4p_rxfz2j_X89mG5flguFysSxcskIYMOYWMSXZFOTDqn56Bz_D80WSRUJpscgUQzoa0zyCsSXb9cI5SDigtF2IiwMZDh9DQ6ti73CqKrTDfOiyDRDAhj_4dSathpI3PCuoSx09h5AapckugoCY5_Bl1jFHTOA2QY_xT3TFe1kEIVIBycNiSTXBWETQmbAt3UsimEIlHs9-nOb2_baqCVlI8V0MN-v2rRmht_QhKoPhzc6aTIoOO5bC1wC_hUY-YwJ2wGaeNgV3IHJa9rVBZ2JSrIzuC4tVilck-i5OWGPhzlC-eF7BAyg9wh6MYcBk7rPKsAYhUgfDjPFdDsxLa9esXXG6fzbHYIzuzB6SMvfA2KW9DpvzALVE4LCnS_truPo_ACf_tM5IUS7zHBc3TthFZQc2OF1-09A76rrdK7cGSVZyyFQuCmaCpUDggbHvQRNmwDPJi9X0PY8G8kA6Ulypqw4X8MJBY57HUDFXIV9NJMS228iJPtfByd8_Z9Bq-6zmiBigob9D-7xpvIFJ5zBxaxsuC8lwkHwoLSDqTmuXcwVyIcrCcYrB8ymOlCiR-n4QOsowTvxZiDUFAbfBS6sVCX3KL1LObe75oK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