69

Where can I find a complete list of Clang flags?

There are some, like -include-pch, that don't appear to be even listed in the man page. :(

I know that GCC uses some of the same flags, but it doesn't include documentation for stuff like -Os which I believe is only available in Clang. Is there a place where I can find a single, consolidated list of all the Clang options ever?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Colen
  • 12,918
  • 21
  • 74
  • 101
  • 2
    See [this answer by Chandler Carruth, clang developer](https://softwareengineering.stackexchange.com/questions/122608/clang-warning-flags-for-objective-c-development/124574#124574). – ShreevatsaR Aug 09 '17 at 03:56

3 Answers3

88

I don't know if this is exactly what you want. Maybe more options are described elsewhere, but I think you are interested in the Clang frontend options. By default, the options displayed seem to describe the "GCC-compatible driver".

clang -cc1 --help should give you what you want.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Guillaume Papin
  • 1,360
  • 11
  • 16
  • 1
    Thanks, this is the best option I've seen so far. – Colen Oct 26 '11 at 22:00
  • 8
    is there a way to list all possible warnings for `-W`? – marcin May 12 '13 at 21:22
  • 1
    I don't think so. There is `-Weverything` if you want to activate all of them though. Since Clang tries to be compatible with GCC you can take a look at GCC's ones (`gcc --help=warnings`). – Guillaume Papin May 12 '13 at 21:52
  • 2
    Some more info here http://programmers.stackexchange.com/a/124574 and here http://www.noxeos.com/2012/01/10/warning-flags-clang/. Note that `-Weverything` that I mentioned earlier is not for everyday use but more for 'experimentation'. – Guillaume Papin May 12 '13 at 22:03
  • @GuillaumePapin can you eleborate on what the '-cc1' option does? I can't find it documented anywhere – tjk213 Oct 28 '14 at 17:56
  • 1
    You can see at the [Clang - FAQ](http://clang.llvm.org/docs/FAQ.html#i-run-clang-cc1-and-get-weird-errors-about-missing-headers) that `clang -cc1` is the frontend. `clang` is the GCC-compatible driver. And recently, a new driver has appeared, `clang-cl`, which is a CL-compatible driver. I don't know how to explain `clang -cc1` properly but the word that matters is **frontend**. You should get answers by looking for "compiler frontend", "clang frontend". – Guillaume Papin Oct 28 '14 at 23:55
  • How come none of these places document -shared or -dynamiclib? – Jake Oct 11 '19 at 02:26
7

For Clang, they are listed in the diagnostics reference, which can be found on the documentation website here

  • Better: https://clang.llvm.org/docs/ClangCommandLineReference.html – Andrew Feb 14 '21 at 04:16
  • the command line reference only references -W but with the diagnostics reference page, you can find that it takes -Wdeprecated-objc-isa-usage, for example. – Jake Mar 07 '21 at 01:07
7

There are many hidden options in LLVM:

clang --help-hidden
opt --help-hidden
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
DTharun
  • 683
  • 6
  • 15