<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116278>116278</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] `clang -mpopcnt hello.c <link flag>` fails to generate warning when file precedes link flag
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
paparodeo
</td>
</tr>
</table>
<pre>
on aarch64 darwin using the `-mpopcnt` flag will result in a warning on clang 16 and error on clang 19.1.3. however, if a linker flag trails the file name no warning / error is generated. eg:
```console
$ clang -mpopcnt hello.c -lc
$ ./a.out
hello world
```
however, re-ordering the command line so the file name comes after `-lc` will generate the expected error
```console
$ clang -mpopcnt -lc hello.c
clang: error: unsupported option '-mpopcnt' for target 'aarch64-apple-darwin'
```
this behavior is not seen with all link flags, eg `-flat_namespace` always will generate an error, but when used in conjunction with `-Wl` will generate an error (as do other flags, like `-v`)
```console
$ clang -mpopcnt -flat_namespace hello.c
clang: error: unsupported option '-mpopcnt' for target 'aarch64-apple-darwin'
$ clang -mpopcnt hello.c -flat_namespace
clang: error: unsupported option '-mpopcnt' for target 'aarch64-apple-darwin'
$ clang -mpopcnt -Wl,-flat_namespace hello.c
clang: error: unsupported option '-mpopcnt' for target 'aarch64-apple-darwin'
$ clang -mpopcnt hello.c -Wl,-flat_namespace
$ ./a.out
hello world
```
```console
$ clang -v
clang version 19.1.3
Target: aarch64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /nix/store/6b4vxqc16xq1nq8jhdsylfml244vah22-clang-19.1.3/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVV1vrDYQ_TXelxEIzFf2gYfbpEh9v1IfqwEP4FxjE9vsJv--smGTNE1v1VZqK60WyR8zc84cz0Hn5KSJWlb9wKqHE25-NrZdcUVrBJlTb8RLazQg2mGuSxBor1LD5qSewM8ErM6SZTXroD2r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