xref: /llvm-project/clang/docs/FAQ.rst (revision 50e5924e434c3c521c2b3949871535e2e03b8a2d)
14077efc1SDmitri Gribenko================================
24077efc1SDmitri GribenkoFrequently Asked Questions (FAQ)
34077efc1SDmitri Gribenko================================
44077efc1SDmitri Gribenko
54077efc1SDmitri Gribenko.. contents::
64077efc1SDmitri Gribenko   :local:
74077efc1SDmitri Gribenko
84077efc1SDmitri GribenkoDriver
94077efc1SDmitri Gribenko======
104077efc1SDmitri Gribenko
114077efc1SDmitri GribenkoI run ``clang -cc1 ...`` and get weird errors about missing headers
124077efc1SDmitri Gribenko-------------------------------------------------------------------
134077efc1SDmitri Gribenko
144077efc1SDmitri GribenkoGiven this source file:
154077efc1SDmitri Gribenko
164077efc1SDmitri Gribenko.. code-block:: c
174077efc1SDmitri Gribenko
184077efc1SDmitri Gribenko  #include <stdio.h>
194077efc1SDmitri Gribenko
204077efc1SDmitri Gribenko  int main() {
214077efc1SDmitri Gribenko    printf("Hello world\n");
224077efc1SDmitri Gribenko  }
234077efc1SDmitri Gribenko
244077efc1SDmitri Gribenko
254077efc1SDmitri GribenkoIf you run:
264077efc1SDmitri Gribenko
274077efc1SDmitri Gribenko.. code-block:: console
284077efc1SDmitri Gribenko
294077efc1SDmitri Gribenko  $ clang -cc1 hello.c
304077efc1SDmitri Gribenko  hello.c:1:10: fatal error: 'stdio.h' file not found
314077efc1SDmitri Gribenko  #include <stdio.h>
324077efc1SDmitri Gribenko           ^
334077efc1SDmitri Gribenko  1 error generated.
344077efc1SDmitri Gribenko
354077efc1SDmitri Gribenko``clang -cc1`` is the frontend, ``clang`` is the :doc:`driver
364077efc1SDmitri Gribenko<DriverInternals>`.  The driver invokes the frontend with options appropriate
374077efc1SDmitri Gribenkofor your system.  To see these options, run:
384077efc1SDmitri Gribenko
394077efc1SDmitri Gribenko.. code-block:: console
404077efc1SDmitri Gribenko
414077efc1SDmitri Gribenko  $ clang -### -c hello.c
424077efc1SDmitri Gribenko
434077efc1SDmitri GribenkoSome clang command line options are driver-only options, some are frontend-only
44cc8fbbf1SSean Silvaoptions.  Frontend-only options are intended to be used only by clang developers.
4518d8a461SDmitri GribenkoUsers should not run ``clang -cc1`` directly, because ``-cc1`` options are not
4618d8a461SDmitri Gribenkoguaranteed to be stable.
474077efc1SDmitri Gribenko
484077efc1SDmitri GribenkoIf you want to use a frontend-only option ("a ``-cc1`` option"), for example
494077efc1SDmitri Gribenko``-ast-dump``, then you need to take the ``clang -cc1`` line generated by the
504077efc1SDmitri Gribenkodriver and add the option you need.  Alternatively, you can run
514077efc1SDmitri Gribenko``clang -Xclang <option> ...`` to force the driver pass ``<option>`` to
524077efc1SDmitri Gribenko``clang -cc1``.
534077efc1SDmitri Gribenko
54*50e5924eSDmitri GribenkoI get errors about some headers being missing (``stddef.h``, ``stdarg.h``)
5590ccd44eSDmitri Gribenko--------------------------------------------------------------------------
5690ccd44eSDmitri Gribenko
57*50e5924eSDmitri GribenkoSome header files (``stddef.h``, ``stdarg.h``, and others) are shipped with
5890ccd44eSDmitri GribenkoClang --- these are called builtin includes.  Clang searches for them in a
5990ccd44eSDmitri Gribenkodirectory relative to the location of the ``clang`` binary.  If you moved the
6090ccd44eSDmitri Gribenko``clang`` binary, you need to move the builtin headers, too.
6190ccd44eSDmitri Gribenko
6290ccd44eSDmitri GribenkoMore information can be found in the :ref:`libtooling_builtin_includes`
6390ccd44eSDmitri Gribenkosection.
6490ccd44eSDmitri Gribenko
65