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

    <tr>
        <th>Summary</th>
        <td>
            configuration file: how to specify linker flags without causing compilation failure when running clang -v
        </td>
    </tr>

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

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

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

<pre>
    If I create a configuration file for clang containing a linker flag like

```
$ cat config
-Wl,-rpath,/path/to/llvm/runtime/lib
```

I cannot run `clang -v` without it invoking the linker and erroring out:

```
$ clang --config=./config -v
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu...
 "/usr/bin/ld" ... -rpath /path/to/llvm/runtime/lib ...
/usr/bin/ld: /lib/x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

Without a config file, `clang -v` dumps the version info and exits with exit code 0. It does not error.

I'm aware `--version` exists which does early exits, but it looks like `-v` is common enough to figure out the compiler version

So, is it possible to create a config file that adds useful default linker flags, but does *not* cause `clang -v` without input files to error?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE1vo0gQ_TXtSwkEhY3tA4dMIqScZ1dzHDVQQG-abqs_HOffr6ohzkxmVjuSZUFT_erVq1clvVeTIWrE4Ys4PO1kDLN1zSzlclG06-zw1jyP8Ay9IxkIJPTWjGqKTgZlDYxKE4zWQa-lmfhjkMooM4EErcwLORi1nECrFxLFkygetv-62H7rK-6hl2EDX8-yb1rgY-YuMswCHwW261MbrMBW6-sisHXRBLUQH6ju99Dp_xl6aYwN4KIBURcr3ewq6gJeVZhtDKACKHO1L8w-zPTOX5oByDnr-NzGIKqH_6tkBc-2aqqnXGC7vnDKFPd3F02IW-iVnGc1y1Ne5hUIPJUxfS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