[clang] cc1: Report an error for multiple actions unless separated by -main-file-name (PR #91140)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon May 27 21:06:11 PDT 2024


MaskRay wrote:

> I don't really understand the rationale for this, and it's kind of annoying. Most of the compiler's flags behave in the "last one wins" fashion (such as `-O2` and `-O0`) and it's always been convenient to add the flag you want at the end. Why treat action flags any differently? Also, even if this is worthwhile for some reason I haven't considered, why is it an error rather than a warning?

@bogner Some action options are shared between driver and cc1 but the behaviors could be quite different. See my example in the description.

```
%clang_cc1 -S -emit-llvm a.c     # -S is overridden
%clang_cc1 -emit-llvm -S a.c     # -emit-llvm is overridden
%clang_cc1 -fsyntax-only -S a.c  # -fsyntax-only is overridden
```

The strictness helps ensure that `%clang_cc1` tests do not have misleading, overridden action options.

https://github.com/llvm/llvm-project/pull/91140


More information about the cfe-commits mailing list